×
FREE ASSISTANCE FOR THE INQUISITIVE PEOPLE
Tutorial Topics
X
softetechnologies
SQL - Structured Query Language Super key - RDBMS
Composite key - RDBMS - SQL
1540    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.
Albert Einstein
Do not worry about your difficulties in Mathematics. I can assure you mine are still greater.
Albert Einstein
4218
75.03
Today So Far
Total View (Lakh)
softetechnologies
26/05/2018     52292
25/06/2018     44059
01/01/2018     42983
28/06/2017     40718
02/08/2017     39573
01/08/2017     33743
06/07/2017     33559
15/05/2017     32837
14/07/2017     29128
11/09/2018     29121
softetechnologies