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