Powered By Blogger

Monday 27 February 2012

Candidate & Composite Key


Candidate key - A candidate key is any key that could be used as the primary key. This comes with two requirements: it cannot be null, and its values must be unique.
Example,
In a table Customer, suppose you have fields Customer ID, Customer Name, Address, Mobile Number here Customer ID and Mobile

Number is called as candidate Key because those fields can be unique,


Composite key - A composite key contains more than one column Sometimes you may create primary key with the combination of two or more fileds in such cases it is called composite key.
Example,
In an Order table, suppose you have OrderID, ItemID, price. Here Primary key field will be the combination of OrderID and

ItemID because in a single order you can have multiple items.

No comments: