Solved

Candidate Keys - Primary keys in Oracle

Posted on 2013-12-10
5
438 Views
Last Modified: 2013-12-10
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?
0
Comment
Question by:d27m11y
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 23

Assisted Solution

by:David
David earned 250 total points
ID: 39708999
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
 

Author Comment

by:d27m11y
ID: 39709090
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
 
LVL 23

Expert Comment

by:David
ID: 39709170
Correct.  Candidate key is the classroom term, I'm told.  Oracle does not use the term, but does use the concept.
0
 
LVL 32

Accepted Solution

by:
awking00 earned 250 total points
ID: 39709412
>>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
 

Author Closing Comment

by:d27m11y
ID: 39709430
Understood.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
dbms_crypto.decrypt   errors out 6 58
Function to return one result based on data in first query 11 62
SQL Workhours Count beetween Workhours 3 48
plsql job on oracle 18 106
Have you ever had to make fundamental changes to a table in Oracle, but haven't been able to get any downtime?  I'm talking things like: * Dropping columns * Shrinking allocated space * Removing chained blocks and restoring the PCTFREE * Re-or…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question