[英]Is there a way to have a table having 2 columns that are foreign keys referencing 2 other tables?
I have 3 tables Customer, Store and Receipt. 我有3个表Customer,Store和Receipt。 The Receipt table must have a receiptno which is the primary key.
收据表必须有一个收据编号,它是主键。 Also the Receipt table has attributes customerid and storeid, how to I specify that customerid is a foreign key that references customerid in the customer table AND storeid is a foreign key that references storeid in the Stores table?
另外,收据表还具有customerid和storeid属性,如何指定customerid是在customer表中引用customerid的外键,而storeid是在Stores表中引用storeid的外键?
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)
);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.