ALERT

[WEBINAR] Application Running Slowly? Time to Get Precise

Composite Key

Definition - What does Composite Key mean?

A composite key, in the context of relational databases, is a combination of two or more columns in a table that can be used to uniquely identify each row in the table. Uniqueness is only guaranteed when the columns are combined; when taken individually the columns do not guarantee uniqueness.

Techopedia explains Composite Key

Any column(s) that can guarantee uniqueness is called a candidate key; however a composite key is a special type of candidate key that is only formed by a combination of two or more columns. Sometimes the candidate key is just a single column, and sometimes it's formed by joining multiple columns.

Let us consider an example of a certain table in the database of a commercial bank. This table is used to store records of individuals' bank accounts. Now assume that the table has separate columns for the account type (C for checking, S for savings and so on), followed by another column for the year and month of the account’s creation, and another column for a sequential number within that month. It is obvious that any one of these columns by itself cannot identify an account - for instance you can deduce that there would be several C’s in the “Account Type” column, there would be several entries for May 2008 in the “Date of Creation” column, and so on. However, if, you combine all the three columns, then you do end up with a unique record for each and every account. A hypothetical account number in our example would be "C 200807 001" for the first account created in July 2008, which is a checking account. Another is "S 201003 004" for the fourth account created in March 2010, this time a savings account. This is a composite key, that is, a candidate key that guarantees uniqueness only when two or more columns are joined together.

A composite key can be defined as the primary key. This is done using SQL statements at the time of table creation. It means that data in the entire table is defined and indexed on the set of columns defined as the primary key.

Connect with us

Techopedia on Linkedin
Techopedia on Linkedin
Tweat cdn.techopedia.com
"Techopedia" on Twitter


'@Techopedia'
Sign up for Techopedia's Free Newsletter!

Email Newsletter

Join thousands of others with our weekly newsletter

Resources

JOIN US AT THWACKCAMP 2016:
THWACKcamp is an annual IT knowledge share event hosted by THWACK, the SolarWinds community of 130,000+ members. It's a two day event (September 14 -...
Free Whitepaper: The Path to Hybrid Cloud
Free Whitepaper: The Path to Hybrid Cloud:
The Path to Hybrid Cloud: Intelligent Bursting To Amazon Web Services & Microsoft Azure
Free E-Book: Public Cloud Guide
Free E-Book: Public Cloud Guide:
This white paper is for leaders of Operations, Engineering, or Infrastructure teams who are creating or executing an IT roadmap.
Free Tool: Virtual Health Monitor
Free Tool: Virtual Health Monitor:
Virtual Health Monitor is a free virtualization monitoring and reporting tool for VMware, Hyper-V, RHEV, and XenServer environments.
Free 30 Day Trial – Turbonomic
Free 30 Day Trial – Turbonomic:
Turbonomic delivers an autonomic platform where virtual and cloud environments self-manage in real-time to assure application performance.