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 aEasier to implement and use
Composite keys are easy to implement in aDisadvantages
Requirement Changes
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.Complexity and Storage
A composite key consists of multiple attributes and the composite key will be referenced in multiple tables as the foreign key, this uses a lot of disk space as multiple columns are being stored as the foreign key instead of just possibly one. This makes the schema complex and the queries become more CPU expensive as for every join the DBMS will need to compare three attributes instead of just possibly one in case of a single natural key.Example
An example is an entity that represents the modules each student is attending at University. The entity has a ''studentID'' and a ''moduleCode'' as its primary key. Each of the attributes that makes up the primary key is a simple key because each represents a unique reference when identifying a student in one instance and a module in the other, so this key is a compound key. In contrast, using the same example, imagine we identified a student by their ''firstName'' + ''lastName''. In a table representing students our primary key would now be ''firstName'' + ''lastName''. Because students can have the same firstNames or the same lastNames these attributes are not simple keys. The primary key ''firstName'' + ''lastName'' for students is a composite key.See also
*External links