Candidate Keys - Primary keys in Oracle

This was the interview question I had :

What are candidate keys? Suppose three candidate keys have been identified. Which one will become the primary key? Can all three candidate keys be made into composite primary key?
d27m11yAsked:
Who is Participating?
 
awking00Connect With a Mentor Commented:
>>Can I say that candidate key is the key column that uniquely identifies the data in a row<<
I would say it slightly differently -
A candidate key is a column or combination of columns that will always define a unique row.
Assume table x has cola, colb, and colc with the following values:
a1, b1, c1
a2, b2, c2
a3, b3, c3
In this case uniqueness can be defined by [cola], [colb], [colc], [cola,colb], [cola,colc], [colb,colc), or [cola,colb,colc]
However, if table x could have a row such as a1, b2, c3, the only candidate key would be [cola,colb,colc]

>>and the candidate key could be composite primary key provided it is unique.<<
Correct as demonstrated above
0
 
DavidConnect With a Mentor Senior Oracle Database AdministratorCommented:
Second question, yes, provided the concatenated string that results is unique.

You answered the first question:  candidates are potential primary key fields.  Between the business requirements, and the architect, a selection must be made on what's the best choice.

An Internet search will yield you examples and specifics.

HTH
0
 
d27m11yAuthor Commented:
Can I say that candidate key is the key column that uniquely identifies the data in a row and the candidate key could be composite primary key provided it is unique.

Please confirm if I understand right !
0
 
DavidSenior Oracle Database AdministratorCommented:
Correct.  Candidate key is the classroom term, I'm told.  Oracle does not use the term, but does use the concept.
0
 
d27m11yAuthor Commented:
Understood.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.