- Learning PostgreSQL 11
- Salahaldin Juba Andrey Volkov
- 281字
- 2021-07-02 13:11:38
Entity integrity constraint
In the relational model, a relation is defined as a set of tuples. This means that all the tuples in a relation must be distinct. The entity integrity constraint is enforced by having a primary key, which is an attribute/set of attributes with the following characteristics:
- The attribute should be unique
- The attributes should be not null
Each relation must have only one primary key, but can have many unique keys. A candidate key is a minimal set of attributes that can identify a tuple. All unique, not null attributes can be candidate keys. The set of all attributes form a super key. In practice, we often pick up a single attribute to be a primary key instead of a compound key (a key that consists of two or more attributes that uniquely identify a tuple) to simplify the joining of the relations with each other.
If the primary key is generated by the DBMS, then it is called a surrogate key or synthetic key. Otherwise, it is called a natural key. The surrogate key candidates can be sequences and universal unique identifiers (UUIDs). A surrogate key has many advantages such as performance, requirement change tolerance, agility, and compatibility with object-relational mappers. The chief disadvantage of surrogate keys is that it makes redundant tuples possible.
- C語(yǔ)言程序設(shè)計(jì)實(shí)訓(xùn)教程
- Modern JavaScript Applications
- 深入理解Elasticsearch(原書(shū)第3版)
- JavaScript應(yīng)用開(kāi)發(fā)實(shí)踐指南
- Raspberry Pi Robotic Projects(Third Edition)
- Python自然語(yǔ)言理解:自然語(yǔ)言理解系統(tǒng)開(kāi)發(fā)與應(yīng)用實(shí)戰(zhàn)
- 算法圖解
- 嵌入式Linux C語(yǔ)言程序設(shè)計(jì)基礎(chǔ)教程
- Android編程權(quán)威指南(第4版)
- 給產(chǎn)品經(jīng)理講技術(shù)
- iOS程序員面試筆試真題與解析
- Java面向?qū)ο蟪绦蛟O(shè)計(jì)(第3版)
- 看漫畫(huà)學(xué)Python:有趣、有料、好玩、好用(全彩版)
- Metasploit for Beginners
- Penetration Testing Bootcamp