一个属性可以有两个外键吗?

时间:2012-09-05 07:45:37

标签: database attributes foreign-keys relational

只做一些关系数据库工作。 快速问题,一个属性可以有两个外键吗?

例如,这是合法的吗?

PERSONAL_RECORDS.Date_of_birth在CASUAL.Date_of_birth中有一个外键,在MANAGER.Date_of_birth中有一个外键

基本上,一个属性是否可以使用另外两个属性的外键?

提前谢谢! :)

2 个答案:

答案 0 :(得分:0)

实际上棘手的问题,我会阅读:http://office.microsoft.com/en-us/access-help/design-the-tables-for-a-new-database-RZ101772996.aspx?section=9以获取有关该主题的更多信息。从我从学校的校园里回忆起来,这是不可能的。但是可能有办法做到这一点?

Multiple Foreign keys to a single table and single key pointing to more than one table也详细介绍了这一点。

祝你好运:)

答案 1 :(得分:0)

单个列可以引用多个表。

create table t1 (
  t1_id integer primary key
);

create table t2 (
  t2_id integer primary key
);

create table t3 (
  t3_id integer primary key,
  foreign key (t3_id) references t1 (t1_id),
  foreign key (t3_id) references t2 (t2_id)
);
相关问题