Midterms - Relational algebra Flashcards
Identification
Fundamental operations to retrieve and manipulate tuples in a relation
Relational Algebra
Identification
Generate a relation with tuples that contains only speciefied attributes
- Can rearrange order of attributes
- Can manipulate values
Projection
Identification
Choose a subset of the tuples from a relation that satisfies a selection predicate
Select
Identification
acts as a filter to retain only tuples that fulfill its qualifying requirement
Predicate
Identification
Can combine multiple predicates using conjuctions/disjunctions
Select
Identification
Generate relation that contains only the tuples that appear in both of the input relations
Intersection
Identification
Generate a relation that contains all tuples that appear in either only one or both input relations
Union
Identification
Generate a relation that contains only the tuples that appear in the first and not the second of the input relations
Difference
Identification
Generate a relation that contains all tuples that are a combination of two tuples with common values for one or more attributes
Join
Identification
Generate a relation that contains all possible combinations of tuples from the input relations
Product
Relational Algebra: Syntax
Product
R × S
SELECT * FROM R CROSS JOIN S;
Relational Algebra: Syntax
Join
R ⋈ S
SELECT * FROM R NATURAL JOIN S;
Relational Algebra: Syntax
Difference
R - S
(SELECT * FROM R) EXCEPT (SELECT * FROM S);
Except operation is not supported in mysql, use alternative: Not in ()
Relational Algebra: Syntax
Union
R ∪ S
(SELECT * FROM R) UNION ALL (SELECT * FROM S);
Relational Algebra: Syntax
Intersection
R ∩ S
(SELECT * FROM R) INTERSECT (SELECT * FROM S);
Intersect is not supported in mysql, use alternative: Inner Join