Table Key


The following slides introduce some database terms.

student
sid lname fname class phone
1 Jones Allan 2 555-1234
2 Smith John 3 555-4321
3 Brown Harry 2 555-1122
5 White Edward 3 555-3344
enrollment
sid cno major
1 101 No
1 108 Yes
2 105 No
3 101 Yes
3 108 No
5 102 No
5 105 No
Superkey
An attribute (or combination of attributes) that uniquely identifies each record in a table; e.g., {sid, lname} is a superkey for the student table.

Key (Candidate Key)
A minimal superkey. A superkey that does not contain a subset of attributes that is itself a superkey; e.g., sid is a candidate key for the student table.

Primary Key
A candidate key selected to uniquely identify all other attribute values in any given record. A secondary key is a candidate key which is not selected as a primary key.

Foreign Key
An attribute (or combination of attributes) in one table whose values must either match the primary key in another table or be NULL; e.g., cno is a foreign key for enrollment table.

Restriction
Given a table T with Head(T)=A1…An, and a tuple t in T, the restriction of the tuple t is a subset {Ai1, ..., Aik} of {A1, ..., An}, denoted t[Ai1, ..., Aik], as the k-tuple of t in the columns named. For example, the restriction of the tuple

  t = (c003, Allied, Dallas, 12.00)
from the table customer to the set {cid, cname} is denoted by
  t[cid, cname] = (c003, Allied) .
customer
cid cname city discnt
c001 TipTop Duluth 10.00
c002 Basics Dallas 12.00
c003 Applied Dallas 12.00
c004 ACME Duluth 12.00
c006 ACME Kyoto 0.00



      Our holiday party is such a bore.    
      Year in, year out (annually without change)    
      the owner makes the same dumb jokes.