0
我有3個表客戶,存儲和收據。收據表必須包含一個作爲主鍵的收據號。此外,Receipt表具有屬性customerid和storeid,如何指定customerid是在客戶表中引用customerid的外鍵,而storeid是引用storeid在Stores表中的外鍵?有沒有辦法讓一個表有兩列是外鍵引用兩個其他表?
我有3個表客戶,存儲和收據。收據表必須包含一個作爲主鍵的收據號。此外,Receipt表具有屬性customerid和storeid,如何指定customerid是在客戶表中引用customerid的外鍵,而storeid是引用storeid在Stores表中的外鍵?有沒有辦法讓一個表有兩列是外鍵引用兩個其他表?
create table Customer (customerid int primary key);
create table Store (storeid int primary key);
create table Receipt
(
receiptno int primary key
,customerid int references Customer (customerid)
,storeid int references Store (storeid)
);
你將如何指定一個外鍵? – Ted