/*==============================================================*/
/* Table: tbl_order */
/*==============================================================*/
create table tbl_order
(
orderId varchar(50) not null,
account varchar(20),
totalPrice NUMBER,
orderDate date,
orderState int,
constraint PK_TBL_ORDER primary key (orderId)
);
/*==============================================================*/
/* Table: tbl_order_goods */
/*==============================================================*/
create table tbl_order_goods
(
orderId varchar(50) not null,
goodsCode varchar(50) not null,
constraint PK_TBL_ORDER_GOODS primary key (orderId, goodsCode)
);
alter table tbl_cart
add constraint FK_TBL_CART_REFERENCE_TBL_CUST foreign key (account)
references tbl_customer (account);
alter table tbl_goods
add constraint FK_TBL_GOOD_REFERENCE_TBL_CATE foreign key (cateId)
references tbl_category (cateId);
alter table tbl_order
add constraint FK_TBL_ORDE_REFERENCE_TBL_CUST foreign key (account)
references tbl_customer (account);
alter table tbl_order_goods
add constraint FK_TBL_ORDE_REFERENCE_TBL_ORDE foreign key (orderId)
references tbl_order (orderId);
alter table tbl_order_goods
add constraint FK_TBL_ORDE_REFERENCE_TBL_GOOD foreign key (goodsCode)
references tbl_goods (goodsCode);