A composite key is a candidate key that consists of two or more attributes (table columns) that together uniquely identify an entity occurrence (table row) in database design. It is also known as a compound key, and it can be defined on two or more columns in a table to uniquely identify any record. A composite key is often used when a non-composite key does not always uniquely identify a record.
Composite keys have advantages similar to that of a natural key as it is often composed of multiple natural key attributes. They 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.
However, composite keys have some disadvantages. The business requirements and rules can change, which can change the format of certain real-world entities. Composite keys are formed of multiple natural keys which are related to the real world, and with the change of their format in the real world, their format in the database will also be changed. This is inconvenient as the number of attributes of composite key will change, and all the foreign keys would need to be updated. A composite key consists of multiple attributes, and the composite key will be more complex than a single attribute key.
In summary, a composite key is a combination of two or more attributes that together uniquely identify an entity occurrence in database design. It is often used when a non-composite key does not always uniquely identify a record. While composite keys have advantages, they also have some disadvantages, such as complexity and inconvenience when business requirements and rules change.