Junior — Middle
What restrictions does using a primary key impose in a database?
sobes.tech AI
Answer from AI
A primary key in a database imposes several constraints:
- Uniqueness: each primary key value must be unique to unambiguously identify a record.
- Cannot be NULL: the primary key field must contain a value.
- Immutability: changing the primary key value is undesirable, as it may affect related tables through foreign keys.
For example, if in the "Users" table the "id" field is a primary key, then it is not allowed to add two users with the same "id" or leave this field empty.