2016-11-21 12 views
0

私は3つのテーブル顧客、店舗と領収書を持っています。レシートテーブルには、主キーであるreceiptnoが必要です。また、領収書テーブルには属性customeridとstoreidがあります。顧客IDは顧客テーブル内のcustomeridを参照する外部キーで、storeidはストアテーブル内のstoreidを参照する外部キーです。他の2つのテーブルを参照する外部キーである2つの列を持つテーブルを持つ方法はありますか?

+0

どのように外部キーを指定しますか? – Ted

答えて

1
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) 
); 
関連する問題