1. 程式人生 > >商城一 之設計數據庫

商城一 之設計數據庫

php def min cart edi eat 浮點數 操作 varchar

商城數據表設計


用戶:

user(用戶表)
id
name
password
email
create_date ---創建日期
login_date ---上次登陸日期
credit ---信用積分,買一塊錢一分
status ---是否啟用,默認1

admin(管理員表)
id
name
password
email
role ---管理員角色(三種角色, admin,1 :超級管理員,2:普通管理員)
admin:所有權限 1:所有權限(但不能操作超級管理員) 2:只能管理後臺
create_date ---創建日期
login_date ---上次登陸日期
status ---是否啟用,默認1
------------------------------------------------------------------------------------
商品:
goodsType(商品類型)
id
name ---商品類型的名稱

goods(商品表)
id
name
img ---縮略圖
desc ---商品描述
price ---價格
status ---是否啟用,默認1
goodsType_id ---商品類型id【外鍵】

goodsAttr(商品屬性,不同類型的商品有不同的屬性)
id
name ---屬性名
goodsType_id ---商品類型id【外鍵】

goodsVal(商品屬性值)
id
value ---屬性值
goodsAttr_id ---商品屬性id【外鍵】
goods_id ---對應的商品

----------------------------------------------------------------------------------
購物車:
cart(購物車)
id
goods_id ---對應的商品id【外鍵】
user_id ---對應的用戶id【外鍵】
count ---數量

-----------------------------------------------------------------------------------
訂單表:
orders(訂單)
id
create_date ---創建日期
user_id ---創建人id【外鍵】
status ---訂單狀態(6:已退款,5:已取消,1:未付款,2:已付款,3:已發貨,4:已簽收)
money ---訂單總價(浮點數)

ordersDetail(訂單詳情)
id
orders_id ---對應的訂單id【外鍵】
goods_id ---對應的商品id【外鍵】
count ---數量
money ---價格

-----------------------------------------------------------------------------------


user(用戶表)

create table user(
id int auto_increment primary key,
name varchar(20) not null,
password varchar(50) not null,
email varchar(50),
create_date int(11),
login_date int(11),
credit int(11) default 0,
status boolean default 1
)

admin(管理員表)

create table admin(
id int auto_increment primary key,
name varchar(20) not null,
password varchar(50) not null,
email varchar(50),
role boolean default 1,
create_date int(11),
login_date int(11),
status boolean default 1
)

goodsType(商品類型)
create table goodsType(
id int auto_increment primary key,
name varchar(20) not null unique,
)

goods(商品表)
create table goods(
id int auto_increment primary key,
name varchar(50) not null,
price decimal(11,2) not null,
img varchar(100) not null,
content varchar(999) not null,
status boolean default 1,
goodsType_id int
)

goodsAttr(商品屬性,不同類型的商品有不同的屬性)
create table goodsAttr(
id int auto_increment primary key,
name varchar(20) not null,
goodsType_id int
)

goodsVal(商品屬性值)
create table goodsVal(
id int auto_increment primary key,
value varchar(20) not null,
goodsType_id int,
goods_id int
)

cart(購物車)
create table cart(
id int auto_increment primary key,
goods_id int,
user_id int,
count int
)

orders(訂單)
create table orders(
id int auto_increment primary key,
create_date int(11),
user_id int,
status boolean default 1 not null,
money decimal(11,2) not null
)

ordersDetail(訂單詳情)
create table ordersDetail(
id int auto_increment primary key,
orders_id int,
goods_id int,
count int not null,
money decimal(11,2) not null
)

php think make:model index/user
php think make:model index/admin
php think make:model index/goodsType
php think make:model index/goods
php think make:model index/goodsAttr
php think make:model index/goodsVal
php think make:model index/cart
php think make:model index/orders
php think make:model index/ordersDetail

商城一 之設計數據庫