create table A (
id int(10) not null,
val1 varchar(255),
primary key (id)
);
方法[A]:我是否需要在一對多關係中使用代理鍵?
create table B (
a_id int(10) not null,
val2 varchar(255),
foreign key (a_id) references A(id)
);
方法[B]:
create table B (
id int(10) not null,
a_id int(10) not null,
val2 varchar(255),
foreign key (a_id) references A(id),
primary key (id)
);
通過選擇並[a],我能避免在表中的 「ID」 代理鍵的創建「B 」。從建模角度創建表'B'的首選方法是哪一種?
我想在這裏建模一對多的關係。但即使選項[a]與您的陳述相反,我也可以在'B'中爲'A'中的條目創建多行。因此,混亂? – Joe 2009-07-13 07:31:56