Relational Algebra Flashcards
Fundamental operations to retrieve and manipulate tuples in a relation
Relational Algebra
Identify:
Generate a relation with tuples that contains only specified attributes
- Can rearrange order if attributes
- Can manipulate values
Projection
Identify:
choose a subset of the tuple from a relation that satisfies a selection predicate
Select
Identify:
Act as a filter to retain only tuples that fulfill its qualifying requirement
Predicate
Identify:
Can combine multiple predicates using conjunction/disjunctions
Select
Identify:
Generate relation that contains only the tuples that appear in both of the input relations
Intersection
Identify:
Generate a relation that contains all tuples that appear in either only one or both input relations
Union
Identify:
Generate a relation that contains only the tuples that appear in the first and not the second of the input relations
Difference
Identify:
Generate a relation that contains all tuples that are a combination of of two tuples with common values for one or more attributes
Join
Identify:
Generate a relation that contains all positive combinations of tuple from the input relations
Product
Syntax:
Product
R x S
SELECT * FROM R CROSS JOIN S;
Syntax:
Join
R = S
SELECT * FROM R NATURAL JOIN S;
Syntax:
Difference
R - S
(SELECT * FROM R)
EXCEPT
(SELECT * FROM S);
Except operation is not supported in mySQL, use alternative: Not in ()
Syntax:
Union
R U S
(SELECT * FROM R)
UNION ALL
(SELECT * FROM S);
Syntax:
Intersection
R n S
(SELECT * FROM R)
INTERSECT
(SELECT * FROM S);