資料庫具體的sql查詢檔案內容如下:
create database petstore;
use petstore
create table Client (
username varchar(25) not null,
passwd varchar(25) not null,
constraint pk_Client primary key (username)
);
create table account (
userid varchar(25) not null,
email varchar(80) not null,
fullname varchar(80) not null,
country varchar(20) not null,
city varchar(80) not null,
address varchar(80) not null,
zip varchar(20) not null,
phone varchar(80) not null,
constraint pk_account primary key (userid),
constraint fk_account foreign key (userid)
references Client (username)
)
create table category (
catid char(10) not null,
catname varchar(80) null,
descn varchar(255) null,
constraint pk_category primary key (catid)
)
create table product (
productid char(10) not null,
catid char(10) not null,
name varchar(80) null,
descn varchar(255) null,
pic varchar(255) null,
listprice decimal(10,2) null,
unitcost decimal(10,2) null,
qty int not null,
constraint pk_product primary key (productid),
constraint fk_product_1 foreign key (catid)
references category (catid)
)
create table orders (
orderid int not null AUTO_INCREMENT,
userid varchar(25) not null,
orderdate date not null,
ordertime time not null,
shiptoname varchar(80) not null,
shipcountry varchar(20) not null,
shipcity varchar(80) not null,
shipaddress varchar(80) not null,
shipzip varchar(20) not null,
shipphone varchar(80) not null,
billtoname varchar(80) not null,
billcountry varchar(20) not null,
billcity varchar(80) not null,
billaddress varchar(80) not null,
billzip varchar(20) not null,
billphone varchar(80) not null,
totalprice numeric(10,2) not null,
creditcard varchar(80) not null,
cardtype varchar(80) not null,
constraint pk_orders primary key (orderid),
constraint fk_orders_1 foreign key (userid)
references account (userid)
)
create table lineitem (
orderid int not null,
itemid char(10) not null,
quantity int not null,
unitprice numeric(10,2) not null,
constraint pk_lineitem primary key (orderid,itemid),
constraint fk_lineitem_1 foreign key (orderid)
references orders (orderid),
constraint fk_lineitem_2 foreign key (itemid)
references product (productid)
)
商務邏輯:
1、 使用者註冊:輸入使用者名稱、密碼、郵箱、全名、國家、城市、住址、郵編、電話 註冊成功後就可以進行按產品的分類瀏覽網站
2、 產品管理:為管理員所用,管理員可以增加產品分類,以及為每個分類增加產品,其中產品包括產品名,產品介紹,市場價格,當前價格,數量
3、 使用者訂購寵物:當使用者看重某個寵物時,可以加入使用者的購物車(用session實現)當使用者購物車寵物選擇完畢時,就可以進行預定,預定涉及到的表為orders,lineitem,product。其中orders表需要分別填寫帳單寄往處、物品寄往處,以及預定日期、總價錢,銀行卡號及類型。