pet store宠物商店数据库设计

数据库具体的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表需要分别填写帐单寄往处、物品寄往处,以及预定日期、总价钱,银行卡号及类型。

你可能感兴趣的:(database)