Database Normalisation Questions Medium
In the context of database normalization, a composite key and a candidate key are both types of keys used to uniquely identify records in a relational database. However, there are some differences between them.
A candidate key is a minimal set of attributes (columns) that can uniquely identify each record in a table. It means that no subset of the candidate key can uniquely identify a record. In other words, if any attribute is removed from the candidate key, it will no longer be able to uniquely identify the records. A table can have multiple candidate keys, and one of them is chosen as the primary key.
On the other hand, a composite key is a key that consists of two or more attributes (columns) combined together to uniquely identify records. Unlike a candidate key, a composite key can be formed by combining multiple attributes. It is used when a single attribute cannot uniquely identify the records, but the combination of multiple attributes can. Each attribute in a composite key contributes to the uniqueness of the key.
To summarize, the main difference between a composite key and a candidate key is that a candidate key is a minimal set of attributes that can uniquely identify records, while a composite key is formed by combining multiple attributes to achieve uniqueness.