Composite Key (Entity-Relationship Diagram)
A composite key is a type of key that consists of two or more attributes. The combination of specified attributes uniquely identifies the instance of the entity (in relational databases, a row in a table). The composite keys are often composed of natural key attributes. It is used when a single column is not sufficient to uniquely identify a row in a table.
Example of Composite Key
The example below shows a Phone Contact entity with a composite key that consists of two attributes: Country Code and Number. These two attributes uniquely specify a phone contact. The other entity (Account) refers to the Phone Contact using the foreign key, which consists of two attributes.
How to Create a Composite Key
If you want to create a composite primary key using our ERD tool, just mark multiple attributes as primary keys. You can do it for each attribute separately or select all the attributes of the composite key and mark them as the primary key.
To mark an attribute as a primary key, right-click on the attribute and choose the Primary key from the context menu.