INFO 340 L05
Read ch 3 and 4
Next week 9,11,12
project deliverable 1 due April 19
see FAQ on website
Assignment 2 updated script for loading tables is available online
due April 21 - Wed
Cardinality - Number of Rows
Degree - Number of Attributes
Every attribute belongs to a domain
A domain specifies the allowable values that an attribute can take
Two or more attributes may share the same domain
Database is nothing but a collection of relations with distinct names
We can thing about tables in terms of mathematical relations and apply set theory
Cartesian product: all the values of relations that can exist
Write the SQL query for:
S = {(x,y)|x ’àà D1, y ’àà D2, y = 3}
S = {(2,3),(4,3)}
Select x, y //projection
From (D1 X D2) //cross product take these two relations and make a 3rd relation
Where Y = 3 //selection
Relational Schema
A named relation defined by a set of attribute domain name pairs
Keys are used to uniquely identify rows in a relation
Relational Keys
Superkey
- Theoretical construct
- An attribute or a _Set_ of attributes that uniquely identify the row
Candidate Key
- Minimal number of attributes that uniquely defines a row
- Two properties:
* Uniqueness
* Irreducibility
Primary Key
- The candidate key that is actually used to identify the tuples
- Alternative keys are the candidate keys that were not selected
Foreign Key
- An attribute or a set of attributes that exist in another table
- Matches a candidate key of some other relation
by convention underlined attributes are the primary keys, more than one combine