×
FREE ASSISTANCE FOR THE INQUISITIVE PEOPLE
Tutorial Topics
X
softetechnologies
SQL - Structured Query Language Super key - RDBMS
Composite key - RDBMS - SQL
287    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
The only source of knowledge is experience.
Albert Einstein
1630
35.58
Today So Far
Total View (Lakh)
softetechnologies
01/01/2018     33880
28/06/2017     30126
26/05/2018     28037
02/08/2017     27820
15/05/2017     23768
25/06/2018     22412
06/07/2017     22314
01/08/2017     22297
21/04/2018     18818
14/07/2017     17257
softetechnologies