×
FREE ASSISTANCE FOR THE INQUISITIVE PEOPLE
Tutorial Topics
X
softetechnologies
SQL - Structured Query Language Super key - RDBMS
Composite key - RDBMS - SQL
1040    Arnab De    21/11/2021

Sometimes more than one attribute needs to create a key that uniquely represents a tuple. That keys are known as a composite key or compound key.

Any>super key,>primary key,>candidate key>can be called a composite key if it has more than one attribute.

Example

Lets consider a table Sales with four attributes or columns – customer_id, order_id, pcode and qty.

Sales
customer_id order_id pcode Qty
C001 O922 P006 20
C002 O889 P007 5
C003 O876 P005 34
C003 O777 P006 66
softetechnologies

Here, none of these columns can declare as a primary key that uniquely identifies a tuple. Because

  1. One customer can place multiple orders, so customer_id>alone cannot become a key.
  2. One order may contain multiple products, So order_id>alone cannot become a primary key
  3. More than one customer can order the same product, So pcode>alone cannot become a primary key.
  4. More than one order can be placed with the same qty value, so Qty>alone cannot become a primary key.
softetechnologies

Here only the combination of customer_id and order_id can uniquely identify a tuple and can be declared as the primary key. That is why the said set of keys known as a composite key.

SQL - Structured Query Language Super key - RDBMS
softetechnologies
Author Details
Arnab De
I have over 16 years of experience working as an IT professional, ranging from teaching at my own institute to being a computer faculty at different leading institute across Kolkata. I also work as a web developer and designer, having worked for renowned companies and brand. Through tutorialathome, I wish to share my years of knowledge with the readers.
Enter New Comment
Comment History
No Comment Found Yet.
Rabindranath Tagore
Everything comes to us if we create the capacity to receive it.
Rabindranath Tagore
1197
57.24
Today So Far
Total View (Lakh)
softetechnologies
26/05/2018     43527
01/01/2018     36478
25/06/2018     35475
28/06/2017     34547
02/08/2017     32975
01/08/2017     27458
06/07/2017     27205
15/05/2017     26841
14/07/2017     22455
21/04/2018     21107
softetechnologies