Lably
Skip to content

Composite key

Candidate key with two or more attributes in a database

  • 2 min read
  • 3 chapters

Related on Lably

Through Data modeling, Foreign key and Primary key

A compound key is a composite key for which each attribute that makes up the key is a foreign key in its own right.

Advantages

Composite keys have advantages similar to that of a natural key as it is often composed of multiple natural key attributes.

Storage

Composite keys use less disk space as compared to defining a surrogate key column, this is because the composite key already exists as attributes in the table and does not need to be defined in the table just for the purpose of unique identification. This simplifies the table and also saves space.

Easier to implement and use

Composite keys are easy to implement in a database schema as their component parts are already named items in the database. When they are also natural keys, they are often intuitive for real world scenarios. They are often used when a non-composite key does not always uniquely identify a record. For example, a personal name may often, but not always, be unique in a given database, and some other field such as date of birth may be added to make uniqueness much more probable.

Sign in to keep reading

2 more chapters are free with a Lably account.

More in Computing and communication