Last answered:

22 Jun 2020

Posted on:

20 Jun 2020

0

Resolved: Relationships between Tables in SQL

Little bit confused as I know that we can have only one primary key per table. I still need to understand why the definition of Primary key mentions (set of columns).
1 answers ( 1 marked as helpful)
Instructor
Posted on:

22 Jun 2020

0
Hi Gilles! Thanks for reaching out. Yes, a table can have only one primary key. And this key can be composed either by a single column (e.g. customer_id), or by several columns, in which case it will be called a composite primary key. In that case, the uniqueness of the key will not be defined by the value of a single column, but by the combination of the values of several columns.  As an example of a composite primary key can be considered the combination of the playing card suit (Diamonds, Spades, Clubs, Hearts) and the playing card value (2, 3, 4, ..., Jack, Queen, Kind, Ace). Neither the suit nor the value are sufficient to identify a unique value for the playing card. But in combination, the suit and the value can. Hope this helps.
Best,
Martin  

Submit an answer