adjacent concept / 主键与候选键
Primary and Candidate Keys
候选键是能唯一识别一行且不可再缩减的属性组合;从候选键中选作主要标识的称为主键。
Key fields
Identity
- Subtype
- 关系
- Parent Taxonomy
- Database Design
What
- Definition
- 候选键是能唯一识别一行且不可再缩减的属性组合;从候选键中选作主要标识的称为主键。
Why
- Core Question
- 如何稳定、唯一地识别一行数据,并让其他表引用它?
- Mechanism
- 主键要求唯一且非空;候选键表达业务上的其他唯一性,通常通过 UNIQUE 约束保留。
Where
- Manifestation
- 常见主键是不可变的整数或 UUID;自然业务字段如 ISBN、邮箱也可能是候选键,但要评估是否稳定。
How
- Primary Use
- 消除歧义、建立引用目标、支持更新和关联查询。
Evidence
- Limitations
- 自动递增 ID 只解决技术标识,不自动保证业务事实唯一;主键选得不当会导致重复或难以维护。
Lifecycle
- Status
- 草稿
Additional content
- Legacy Tags
- 关系型数据库 · 键
Related content
Relationships come from the local knowledge graph and include reverse links.