Wikia

Database Management

Relational Database: Keys

Talk0
108pages on
this wiki

Introduction Edit

Primary and foreign keys play an important roll in the existence of the relational database. It is the ability to link tables with keys that allows for the logical representation of information relational databases provide. Each table has a primary key that uniquely identifies tuples in that table. By including a primary key from one table in another a foreign key is implemented, joining the two tables, creating a relationship.

Ryan L. Prongco


Key Types Edit

Definition of a Key- Simply consists of one or more attributes that determine other attributes.

Role- based on the concept of Determination.

Determination- Which can be explained by having two attributes, A and B. The statement that “A determines B” means that knowing the value of A means that you can also determine the value of attribute B.


There are 3 rules that apply to primary keys:

· Exist

· Be unique

· Not change over time (unique sustained existence)


In relational model notation the primary key is first, underlined and bold.

    Employee (Emp_ID, Emp_Fname, Lname, Phone )

Types of Keys in a Relational DatabaseEdit

1. Superkey- An attribute that uniquely identifies each entity in a table.

2. Candidate Key- Similar to a superkey, but does not contain a subset of attributes that is itself a superkey.

3. Primary Key (PK) - Candidate Key selected to uniquely identify all other attribute values in any given row. A primary key cannot contain null values.

        "Every table must have a primary key, an attribute or combination of attributes that are guaranteed to be unique and not null.
      The entity integrity rule states that for every instance of an entity, the value of the primary key must exist, be unique, and cannot be null."


4. Secondary Key- An attribute or combination, used strictly for data retrieval purposes.

5. Foreign Key (FK)- An Attribute or combination, in one table whose values must either match the primary Key (PK) in another table or be null.

        "A foreign key exists in a table to identify a primary key in another. The join of two relations is made at the foreign key and with   
      the referential integrity rule applied creates reliable navigation of relations and data integrity.
      The referential integrity rule states that every foreign key value must match a primary key value in an associated table.
      When designing and establishing relationships, the cardinality needs to be considered. Always use the primary key from the 1 side of 
      the relationship to be the foreign key in the N side."[[File:]]

Around Wikia's network

Random Wiki