CSC 675 Review 4 - Relational Algebra and SQL Flashcards
What is the purpose of the relational algebra select operation?
Restriction - The SELECT operation is used to choose a subset of the tuples from a relation that satisfies a selection condition.
What is the purpose of the relation algebra project operation?
Selects certain columns from the table and discards the other columns.
What is the purpose of the relational algebra join operation?
Is used to combine related tuples from two relations into single “longer” tuples.
What is the purpose of the relation algebra union operation?
A collection of tuples is the set of all distinct elements.
What is the purpose of the relational algebra difference operation?
Produces a relation that includes all the tuples in R1 that are not in R2; R1 and R2 must be union compatible.
What is the purpose of the relation algebra intersection operation?
Produces a relation that includes all the tuples in both R1 and R2; R1 and R2 must be union compatible.
What is the purpose of the relational algebra division operation?
Division identifies the attribute values from a relation that are found to be paired with all of the values from another relation.
What is the purpose of the relational algebra cartesian product operation?
All ordered pairs of tuples from the two relations.
Explain how join can be expressed using the other relational operation.
a join can be expressed as multiple selects
Explain how division can be expressed using the relational operation.
division can be expressed as multiple selects
What is union compatibility? *
• Relations have the same number of
attributes
• Corresponding attributes have the same domains
Why do the union, intersection and difference operations require that the relations on which they are applied be union compatible? *
Union, intersection, and difference require union compatibility because these operation require direct comparison of the individual tuples.
what is the standard definition of a natural join?
Produces all the combinations of tuples from R1 and R2 that satisfy a join condition with only equality comparisons. Without the duplicate columns.
What is the standard definition of an equijoin?
Produces all the combinations of tuples from R1 and R2 that satisfy a join condition with only equality comparisons.
Under what circumstances are outer joins useful? *
We wan to use outer joins when we want to know all the information from a join. When you do an outer join all the tuples not contained within the join are completed with null values. This is the reason why outer joins are not considered part of the relational algebra. In “pure” relation algebra, there are no null values.