Sponsored Links
-->

Thursday, May 24, 2018

Super Key, Candidate Key and Primary Key | Database Management ...
src: i.ytimg.com

A superkey or super-key is defined in the relational model of database organization as a set of attributes of a relation variable 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. It can be defined as a set of attributes of a relation schema upon which all attributes of the schema are functionally dependent.

The set of all attributes is a trivial superkey, because in relational algebra duplicate rows are not permitted: rows are a set (no duplicates), not a multiset (duplicates allowed).

If attribute set K is a superkey of relation R, then at all times it is the case that the projection of R over K has the same cardinality as R itself.

A superkey is a set of attributes within a table whose values can be used to uniquely identify a tuple. A candidate key is a minimal set of attributes necessary to identify a tuple; this is also called a minimal superkey. Given an employee schema consisting of the attributes employeeID, name, job, and departmentID, we could use the employeeID in combination with any or all other attributes of this table to uniquely identify a tuple in the table. Examples of superkeys in this schema would be {employeeID, Name}, {employeeID, Name, job}, and {employeeID, Name, job, departmentID}. The last example is known as trivial superkey, because it uses all attributes of this table to identify the tuple.

In a real database we do not need values for all of those attributes to identify a tuple. We only need, per our example, the set {employeeID}. This is a minimal superkey--that is, a minimal set of attributes that can be used to identify a single tuple. employeeID is a candidate key.


Video Superkey



Example

First, list out all the sets of attributes:

o {}  
o {Monarch Name}  
o {Monarch Number}  
o {Royal House}
o {Monarch Name, Monarch Number}
o {Monarch Name, Royal House}
o {Monarch Number, Royal House}
o {Monarch Name, Monarch Number, Royal House}

Second, eliminate all the sets which do not meet superkey's requirement. For example, {Monarch Name, Royal House} cannot be a superkey because for the same attribute values (Edward, Plantagenet), there are two distinct tuples:

  • (Edward, II, Plantagenet)
  • (Edward, III, Plantagenet)

Finally, after elimination, the remaining sets of attributes are the only possible superkeys in this example:

  • {Monarch Name, Monarch Number} (Candidate Key)
  • {Monarch Name, Monarch Number, Royal House}

In reality, superkeys cannot be determined simply by examining one set of tuples in a relation. A superkey is a property of a relation variable which must hold for all possible values and can only be determined from the functional dependencies which apply to that relation variable.

If a relation contains 'n' attributes then maximum number of superkeys possible is 2n.


Maps Superkey



See also

  • Alternate key
  • Compound key
  • Foreign key
  • Primary key
  • Candidate Key

SuperKey Review | GBAtemp.net - The Independent Video Game Community
src: gbatemp.net


References

  • Silberschatz, Abraham (2011). Database System Concepts (6th ed.). McGraw-Hill. pp. 45-46. ISBN 978-0-07-352332-3. 

Super Key and Candidate Key in DBMS | Database Management System ...
src: i.ytimg.com


External links

  • Relation Database terms of reference, Keys: An overview of the different types of keys in an RDBMS

Source of article : Wikipedia