Quiz 3 (Midterm) Flashcards
Projection
A subset of columns. Denoted by Proj (π)
Selection
A subset of rows. SELECT (σ)
Union
A logical ‘or’ used to compare or combine two sets of data. Both sets MUST have the same schema.
Intersection
A logical ‘and’ used to compare or combine two sets of data. Both sets MUST have the same schema.
Set-difference
What is not common between the two sets. What’s in one and not the other.
Cross-product
Joining (multiplying) two sets together.
If the rows in Student are row1, row2 and row3, and the rows in University are row4, row5 and row6, then the cartesian product will contain
row1row4, row1row5, row1row6, row2row4, row2row5, row2row6, row3row4, row3row5, row3row6
Join
Cross product followed by a selection and then maybe a projection. (⋈)
Division
Division identifies the attribute values from a relation that are found to be paired with all of the values from another relation.
Used when you need to find the values that do not belong in the answer, and remove them from the list of possible answers. Opposite of cross/cartesian product.
- Compute all possible attribute pairings
- Remove the existing pairings
- Remove the non–answers from the possible answers
Relational Algebra vs. Relational Calculus
Algebra is procedural in that it gives the steps to get the result. Calculus is declarative in that it gives you the result so that you can find the steps.
Relational Calculus Format
{T | p(T)} where p(T) is a recursively defined formula and is true for all T