×
FREE ASSISTANCE FOR THE INQUISITIVE PEOPLE
Tutorial Topics
X
softetechnologies
SQL - Structured Query Language Super key - RDBMS
Composite key - RDBMS - SQL
83    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
Don't limit a child to your own learning, for he was born in another time.
Rabindranath Tagore
1820
25.81
Today So Far
Total View (Lakh)
softetechnologies
01/01/2018     31582
28/06/2017     26609
02/08/2017     23328
26/05/2018     21522
15/05/2017     20222
06/07/2017     19001
01/08/2017     17462
21/04/2018     17234
01/07/2017     14866
25/04/2018     14109
softetechnologies