1 Introduction & Relational Model
- one-to-many relationships
- many numbers of many-to-many relationships
- introduced pointers
- acyclic directed graph
- records (vertices) and sets (edges)
- several items with the same kind of records will use linked lists
- many-to-many relationships
- decomposing many-to-many relationship into two one-to-many relationships using intersection record
- tuple: a row in a table (usually considered to be unordered and non-identical)
- relation: a two-dimensional table of data
- attribute: a column in a table (usually considered as unordered)
- domain: the set of permissible values for a given attribute
- schema: consisting of the name of the relation followed by its attributes
- component: an atomic single value of an attribute (structure NG)
- instance of a schema: the current contents of a relation
Keys in Relational Model
- primary key: one key that uniquely identify tuples in the relation
- secondary key: any key which is not primary
- superkey: any set of attributes which satisfies uniqueness condition
- key: a minimal superkey, no proper subset of the key is a superkey
ordinary set operations
the relation obtained by selecting attributes from the relation and remove others
the set of tuples in R which satisfy the condition C
Let and be two relations that has some attributes in common.
Then the natural join of R and S is:
The theta join of R and S on condition C is: the set of elements of the cartesian product which satisfy the join condition C.
rename R to S, with attributes rename to .
A bag is similar to a set, but allows multiple occurrences of an element.
If R is a relation then denotes duplicate elimination.
operators: COUNT, SUM, MAX, MIN, AVG
If R is a relation, then an expression using grouping is:
If R is a relation, then an expression using extended projection is:
Ordered by primary sort key then secondary sort key and so on.
Sometimes there is no matching tuple for some tuples and they got disappeared in the joined relation. So outerjoin would keep them leave the unmatched part a null value .
For R and S:
- in left outerjoin, only dangling tuples from R are added
- in right outerjoin, only dangling tuples from S are added
You could also define a outer theta-join using the same way as before.