1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

superkey and candidate kay

Discussion in 'Database' started by carox, Nov 25, 2007.

  1. carox

    carox New Member

    Joined:
    Nov 22, 2007
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    0
    can anyone explain me what is the difference between superkey and candidate key.
    I have read the definition but could'nt understand.
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,285
    Likes Received:
    364
    Trophy Points:
    83
    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
     
  3. carox

    carox New Member

    Joined:
    Nov 22, 2007
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    0
    Thanks for the reply.
    (1) Below is the extract from wikipedia:

    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)
    Is it neccessary that Unique key has to be combined with some Non Unique key to be called as a super key.
     
  4. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,285
    Likes Received:
    364
    Trophy Points:
    83
    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.
     
  5. mayjune

    mayjune New Member

    Joined:
    Jun 14, 2009
    Messages:
    817
    Likes Received:
    33
    Trophy Points:
    0
    Occupation:
    Student
    Location:
    Pune,Delhi
    what is the point of having a superkey if my primary key is doing its job?
     
  6. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,285
    Likes Received:
    364
    Trophy Points:
    83
    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
     
  7. mayjune

    mayjune New Member

    Joined:
    Jun 14, 2009
    Messages:
    817
    Likes Received:
    33
    Trophy Points:
    0
    Occupation:
    Student
    Location:
    Pune,Delhi
    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!! :)
     
  8. NikiDaSilva

    NikiDaSilva New Member

    Joined:
    May 12, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    Teacher
    Location:
    Indonesia
    Great! At last I got some thing for this thing.

    Very sorry on my rudeness. Just a new member.
     
  9. payun

    payun New Member

    Joined:
    Jul 19, 2011
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    explain candidate key with eg? what is data redundency in that case?
     
  10. jhon786

    jhon786 New Member

    Joined:
    Oct 12, 2011
    Messages:
    46
    Likes Received:
    0
    Trophy Points:
    0
    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.
     
  11. khushboo652

    khushboo652 Banned

    Joined:
    Jan 9, 2012
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    0
    Different set of attributes which are able to identify any row in the database is known as super key. And minimal super key is termed as candidate key.


     

Share This Page