×
FREE ASSISTANCE FOR THE INQUISITIVE PEOPLE
Tutorial Topics
X
softetechnologies
SQL - Structured Query Language Super key - RDBMS
Composite key - RDBMS - SQL
355    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.
Swami Vivekananda
All that man has to do is to take care of three things; good thought, good word, good deed.
Swami Vivekananda
1999
38.76
Today So Far
Total View (Lakh)
softetechnologies
01/01/2018     34311
28/06/2017     30951
26/05/2018     30901
02/08/2017     28863
25/06/2018     26242
15/05/2017     24615
01/08/2017     23466
06/07/2017     23189
21/04/2018     19221
14/07/2017     18486
softetechnologies