【发布时间】:2010-10-21 21:05:11
【问题描述】:
假设您在 Artists 和 Fans 之间有一个 Many-Many 表。在设计桌子的时候,你是不是这样设计桌子的:
ArtistFans
ArtistFanID (PK)
ArtistID (FK)
UserID (FK)
(ArtistID and UserID will then be contrained with a Unique Constraint
to prevent duplicate data)
或者您是否为两个相关字段构建使用复合 PK:
ArtistFans
ArtistID (PK)
UserID (PK)
(The need for the separate unique constraint is removed because of the
compound PK)
使用以前的模式有什么优势(可能是索引?)?
【问题讨论】:
-
警告:如果没有特定的数据库标签,这里所说的大部分内容都是可疑的。不同的引擎工作方式不同!
标签: sql database-design