当我有多个列的主键时,如何定义多个表之间的关系?
how to define relations between many tables while I have multiple columns primary key?
我有一个table它的名字是(DataInfo),包含数据信息"this table will be linked to every table in the database"
DataID,DataName
我还有两个 table
第一个是:
DataID,CurrencyID,CurrencyName
第二个是:
DataID,TransID,TransDec,TransAmount,CurrencyID
我的问题是如何定义这些 table 之间的关系?
DataID 将是除"DataInfo" 之外的两个table 的外键。对于第一个 table CurrencyID 将是主键,DataID 将是外键。第二个 table TransID 将是主键,DataID 和 CurrencyID 将是外键。 table 都不需要列的元组作为它们的主键,因为 TransID 对于每笔交易都是唯一的,因此对于每种货币来说都是唯一的 CurrencyID
我有一个table它的名字是(DataInfo),包含数据信息"this table will be linked to every table in the database"
DataID,DataName
我还有两个 table
第一个是:
DataID,CurrencyID,CurrencyName
第二个是:
DataID,TransID,TransDec,TransAmount,CurrencyID
我的问题是如何定义这些 table 之间的关系?
DataID 将是除"DataInfo" 之外的两个table 的外键。对于第一个 table CurrencyID 将是主键,DataID 将是外键。第二个 table TransID 将是主键,DataID 和 CurrencyID 将是外键。 table 都不需要列的元组作为它们的主键,因为 TransID 对于每笔交易都是唯一的,因此对于每种货币来说都是唯一的 CurrencyID