Composite Key
A composite key is a candidate key consisting of two or more attributes(table columns) that uniquely identify a record/tuple (table row) or a relation. A compound key is a composite key for which each attribute that makes up the key is a foreign key in its own right.
Examples
Consider we have a table Orders with three attributes Customer id, Product id, Quantity.The key
Customer id needs to be entered every time the order is placed, hence Customer id can repeat in the table and can not serve as a primary key. Also, Product id and Quantity cannot be chosen as primary key because multiple customers can buy same product and the same quantity. Here any of the three attributes can not be used as primary key, hence combination of these attributes need to be used.
For example, [Customer id + Product id] can be used to identify the records uniquely.
Composite Key in Database
A database is a structured collection of data organized and stored electronically in a computer system. It is designed to efficiently manage, retrieve, and manipulate large volumes of data according to specific requirements and criteria.
In a relational database, the key plays an important role. The key is used to identify a record or a tuple of the table uniquely. Keys are also used to establish and identify the relationships between the tables.
Contact Us