Home > Ask the Oracle Database / Applications Experts > Questions & Answers > Candidate keys
Ask The Oracle Expert: Questions & Answers
EMAIL THIS

Candidate keys

Rudy Limeback EXPERT RESPONSE FROM: Rudy Limeback

Pose a Question
Other Oracle Categories
Meet all Oracle Experts
Become an Expert for this site
>
QUESTION POSED ON: 07 October 2004
What is a candidate key?

>

A candidate key is any column, or combination of columns, which would uniquely identify each row of the table. In other words, a candidate key is a potential primary key.

Once you've selected and defined a primary key from amongst the candidate keys, then the ones that were not chosen are usually referred to as alternate keys. Note that candidate and alternate are conceptual terms, and will not be found in the DDL (data definition language).

In the following example, two alternate keys are given unique constraints:

create table users
( id       integer     not null
, username varchar(16) not null
, userpswd varchar(16) not null
, emplno   integer     not null
, constraint users_pkey primary key ( id )
, constraint uneek_name unique ( username )
, constraint uneek_enum unique ( emplno )
)

Note that since username and emplno are both unique, the combination will be, too. Thus the combination of username and emplno would be another alternate key. So, too, would the combination of id and emplno, or the combination of id and username and userpswd. Even though userpswd is not unique, any combination with a unique column would be unique. In fact, there are many alternate keys, when combinations are considered. Any of these could have been selected as the primary key. However, it would be unusual to see, in practice, someone chosing such a "superkey" combination as the primary key.


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   



RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary



Search and Browse the Expert Answer Center
Search and browse more than 25,000 question and answer pairs from more than 250 TechTarget industry experts.
Browse our Expert Advice



Oracle White Papers: Fusion Middleware
HomeNewsTopicsTipsAsk the ExpertsMultimediaWhite PapersProductsBlogs
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 2003 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts