tmall_sql语句表

CREATE TABLE category (
  id int identity(1,1) primary key,
  name varchar(255) null,

CREATE TABLE users (
  id int identity(1,1) primary key,
  name varchar(255) null,
  passwords varchar(255) null,

--依赖用户表
CREATE TABLE order_ (
  id int identity(1,1) primary key,
  orderCode varchar(255) NULL,
  useraddress varchar(255) DEFAULT NULL,
  post varchar(255) DEFAULT NULL,
  receiver varchar(255) DEFAULT NULL,
  mobile varchar(255) DEFAULT NULL,
  userMessage varchar(255) DEFAULT NULL,
  createDate datetime DEFAULT NULL,
  payDate datetime DEFAULT NULL,
  deliveryDate datetime DEFAULT NULL,
  confirmDate datetime DEFAULT NULL,
  uid int DEFAULT NULL,
  status varchar(255) DEFAULT NULL,
  CONSTRAINT fk_order_user FOREIGN KEY (uid) REFERENCES users (id)

--依赖分类表
CREATE TABLE product (
  id int identity(1,1) primary key,
  name varchar(255) DEFAULT NULL,
  subTitle varchar(255) DEFAULT NULL,
  orignalPrice float DEFAULT NULL,
  promotePrice float DEFAULT NULL,
  stock int DEFAULT NULL,
  cid int DEFAULT NULL,
  createDate datetime DEFAULT NULL,
   CONSTRAINT fk_product_category FOREIGN KEY (cid) REFERENCES category (id)

--依赖产品表
CREATE TABLE productimage (
  id int identity(1,1) primary key,
  pid int DEFAULT NULL,
  type varchar(255) DEFAULT NULL,
  CONSTRAINT fk_productimage_product FOREIGN KEY (pid) REFERENCES product (id)

--依赖分类表
CREATE TABLE property (
  id int identity(1,1) primary key,
  cid int DEFAULT NULL,
  name varchar(255) DEFAULT NULL,
  CONSTRAINT fk_property_category FOREIGN KEY (cid) REFERENCES category (id)

--依赖属性表
CREATE TABLE propertyvalue (
  id int identity(1,1) primary key,
  ptid int DEFAULT NULL,
  value varchar(255) DEFAULT NULL,
  CONSTRAINT fk_propertyvalue_property FOREIGN KEY (ptid) REFERENCES property (id)
  

--依赖用户和产品表
CREATE TABLE review (
  id int identity(1,1) primary key,
  content varchar(4000) DEFAULT NULL,
  uid int DEFAULT NULL,
  pid int DEFAULT NULL,
  createDate datetime DEFAULT NULL,
  CONSTRAINT fk_review_product FOREIGN KEY (pid) REFERENCES product (id),
  CONSTRAINT fk_review_user FOREIGN KEY (uid) REFERENCES users (id)

--依赖用户和产品表
CREATE TABLE orderitem (
  id int identity(1,1) primary key,
  pid int DEFAULT NULL,
  oid int DEFAULT NULL,
  uid int DEFAULT NULL,
  number int DEFAULT NULL,
  CONSTRAINT fk_orderitem_user FOREIGN KEY (uid) REFERENCES users (id),
  CONSTRAINT fk_orderitem_product FOREIGN KEY (pid) REFERENCES product (id)
)
 

猜你喜欢

转载自blog.csdn.net/wolflikeinnocence/article/details/81138592
今日推荐