Go4Expert

Go4Expert (http://www.go4expert.com/)
-   Database (http://www.go4expert.com/forums/database-forum/)
-   -   superkey and candidate kay (http://www.go4expert.com/forums/superkey-candidate-kay-t7532/)

carox 25Nov2007 21:15

superkey and candidate kay
 
can anyone explain me what is the difference between superkey and candidate key.
I have read the definition but could'nt understand.

shabbir 25Nov2007 22:13

Re: superkey and candidate kay
 
A superkey is defined as a set of attributes of a relation for which it holds that in all relations assigned to that variable there are no two distinct tuples (rows) that have the same values for the attributes in this set.
As an example
Code:

+-------------+------------+------------+
| Roll Number | First Name | Last Name  |
+-------------+------------+------------+
| CSU0001    | Shabbir    | Bhimani    |
| CSU0002    | SomeName  | SurName    |
| CSU0003    | Larry      | page      |
+-------------+------------+------------+

Now here we have the following as super keys

1. Roll Number | First Name
2. Roll Number | First Name | Last Name

Now in plain language Any Unique key with some Non Unique key combination is called a super key of the relationship.

A candidate key of a relationship is a set of attributes of that relationship such that there are no two distinct tuples with the same values for these attributes. In simple example candidate key is a minimal superkey, i.e. a superkey of which no proper subset is also a superkey.

Since a relation is a set(no duplicate elements), it holds that every relation will have at least one candidate key (because the entire heading is always a superkey). For practical reasons RDBMSs usually require that for each relation one of its candidate keys is declared as the primary key

carox 26Nov2007 22:30

Re: superkey and candidate kay
 
Thanks for the reply.
(1) Below is the extract from wikipedia:

Quote:

For example, Given an employee table consisting of the columns:
employeeID
name
job and
departmentID

we could use the employeeID in combination with any or all other columns of this table to uniquely identify a row in the table. Examples of superkeys in this table would be {employeeID, Name}, {employeeID, Name, job}, and {employeeID, Name, job, departmentID}.
In a real database we don't need values for all of those columns to identify a row. We only need, per our example, the set {employeeID}. This is a minimal superkey that is, a minimal set of columns that can be used to identify a single row. So, employeeID is a candidate key.
Now, if employeeID is a candidate key then why not it is the superkey. Because employeeID can also uniquely identify the tuples.

(2) In your example why Roll number is not the superkey as it is uniquely identifying the tuples?

(3)
Quote:

Any Unique key with some Non Unique key combination is called a super key of the relationship
Is it neccessary that Unique key has to be combined with some Non Unique key to be called as a super key.

shabbir 26Nov2007 23:26

Re: superkey and candidate kay
 
Unique key is also a super key but the minimal super key is called candidate key and all candidate keys are super keys but the reverse is not true.

mayjune 7Aug2009 01:47

Re: superkey and candidate kay
 
what is the point of having a superkey if my primary key is doing its job?

shabbir 7Aug2009 03:59

Re: superkey and candidate kay
 
Quote:

Originally Posted by mayjune (Post 54403)
what is the point of having a superkey if my primary key is doing its job?

Its couple of years old thread but anyway.

We can have multiple super keys but not multiple primary keys.

As an example we have userid which is primary key but email and username are also unique for any user and so they are also super keys

mayjune 7Aug2009 04:02

Re: superkey and candidate kay
 
get your point...
well i have to submit a synopsis for DBMS project, so fired this question....

by the way, looks like you got up quite early today, never seen you here so early!! :)

NikiDaSilva 12May2010 09:02

Re: superkey and candidate kay
 
Great! At last I got some thing for this thing.

Very sorry on my rudeness. Just a new member.

payun 19Jul2011 13:20

Re: superkey and candidate kay
 
explain candidate key with eg? what is data redundency in that case?

jhon786 27Oct2011 11:51

Re: superkey and candidate kay
 
Super key and candidate keys are the most important terms in DBMS. A superkey is defined in the RDBMS organization as a set of attributes of a relation variable for which it holds that in all relations assigned to that variable.
And if we talk about the candidate key.....
In RDBMS, a candidate key of a relation is a minimal superkey for that relation; that is, a set of attributes such that, two distinct tuples.


All times are GMT +5.5. The time now is 13:20.