27,579
社区成员
发帖
与我相关
我的任务
分享
--订单
create Table Orders(
Id int Identity(1,1) primary key,
No varchar(50) not null,
DateCreate date
)
--订单明细
Create Table OrderDetails(
Id int Identity(1,1) primary key,
OrderId int not null,
ProductId int not null,
Quantity int not null,
DateCreate date
)
--产品表
Create Table Products(
Id int Identity(1,1) primary key,
CatagoryId int not null,
NumberPackNum int not null,
DateCreate date
)
--产品分类表
Create Table Catagory(
Id int Identity(1,1) primary key,
No char(2) not null,
DisplayName varchar(30) not null,
DateCreate date
)
ALTER TABLE OrderDetails ADD CONSTRAINT [PK_OrderDetails_Orders] FOREIGN KEY(OrderId)
REFERENCES Orders ([id])
ALTER TABLE OrderDetails ADD CONSTRAINT [PK_OrderDetails_Products] FOREIGN KEY(ProductId)
REFERENCES Products ([id])
ALTER TABLE Products ADD CONSTRAINT [PK_Products_Catagory] FOREIGN KEY(CatagoryId)
REFERENCES Catagory ([id])