这是我到目前为止所做的!!
创建数据库 MyWebDB ;
创建表用户
( UserID Int Primary Key,
EmailAddress Varchar(50) Not Null,
FirstName Varchar(50) Not Null,
LastName Varchar(50) Not Null)
创建表下载
( DownloadID int Primary Key,
DownloadDate SmallDatetime Null,
FileNames Varchar(100) Not Null,
Foreign Key (UserID) References Users(UserID),
Foreign Key (ProductID) References Products(ProductID))
创建表产品
(ProductID int primary key, ProductName Varchar(50))
我的Sql查询
答案 0 :(得分:0)
您必须为下载表UserID和ProductID
设置数据类型 Userid int FOREIGN KEY REFERENCES Users(UserID)
Productid int FOREIGN KEY REFERENCES Products(ProductID)
或
Userid int,
Productid int,
FOREIGN KEY (Userid) REFERENCES Users(UserID),
FOREIGN KEY (Productid) REFERENCES Products(ProductID))
喜欢:
创建表下载
( DownloadID int Primary Key,
DownloadDate SmallDatetime Null,
FileNames Varchar(100) Not Null,
Userid int,
Productid int,
FOREIGN KEY (Userid) REFERENCES Users(UserID),
FOREIGN KEY (Productid) REFERENCES Products(ProductID))