Академический Документы
Профессиональный Документы
Культура Документы
(Relational Keys)
Recap
Terminology
Relation: Table Tuple: Row of the table Attribute: Column of the row Domain: a set of possible values for a given attribute Derived Relvar: view, query result, result set
Super key
Definition: no two distinct tuples (rows) that have the same values for the attributes in this set.
Example
Students Name Dennis Bock Yang Kian Yu Admin_No 1000001A 1000002B 1000003C Email Class E.g. of Superkeys (Name) (Admin_No) (Email) (Name,Admin_No) aaa@mail.co C1001 m bbb@mail.com C1001 ccc@mail.com C1001
Candidate Key
Definition: a minimal set of attributes necessary to identify a tuple 1 individual super key is counted as candidate key, but not in a combination.
Example
Students Name Dennis Bock Yang Kian Yu Admin_No 1000001A 1000002B 1000003C Email Class E.g. of Candidate keys (Name), (Admin_No), (Email),
Primary Key
A Primary key is the same as Candidate Key but there can only be 1 Primary key. a primary key is necessary as the target of any foreign keys which refer to it from other tables
Alternate Keys
Alternate keys are other Candidate keys that could also be Primary Key
Foreign Key
a set of one or more columns in any table (not necessarily a candidate key, let alone the primary key, of that table) which may hold the value(s) found in the primary key column(s) of some other table
Students Name Dennis Bock Yang Kian Yu Admin_No 1000001A 1000002B 1000003C
Example
In this case, Class is the Primary Key of aaa@mail.co C1001 the relation m Students and also the Foreign Key of bbb@mail.com C1001 the relation Lecturers, therefore ccc@mail.com C1001 forming a relationship between Foreign Key them. Email Class