Relational Algebra Flashcards
Unary Relational Operations
Operations on one set:
Select: sigma: σ
Project: pi: π
Rename: rho: ρ
Select: σ
Selects entire entries from a table
Project: π
Selects only specified attributes
Rename: ρ
Renames attributes or entities
Binary Operations:
Operations on two sets:
Union: U
Intersection: ∩
Set Difference: -
Union
Includes all tuples from R and S, or R, or S
Intersection
Includes all tuples in R and S
Set Difference:
Includes all the tuples in R but not S (R-S)
Commutative Operatiosn
Union and Intersection
Joins:
Binary Operators:
Cross Product: X
Theta: Θ
Equi-join Θ=
Natural Join: *
Cartesian Product / Cross Product
Exhausting pairing
Theta Join
A join based on any sort of equality, can be combined with ANDs
Equijoin
A join based on only strict equality pairing
Natural Join
Removes superfluous attributes in an equijoin situation
Outer Joins
Keeps tuples in R even if they aren’t in S
Left Outer Join
Keep every tuple in the left relation, pad with nulls
Right Outer Join
Keep every tuple in the right relation, pad with nulls
Full Outer Join
Keeps every tuple in right and left relation regardless of matches, pad with nulls
Aggregate Functions
F(Max) F(Min) F(Sum) F(Count) F(Average)
Grouping with Aggregate Functions
Given a relation: EMP(EMPNO, DNO, SAL)
DNO F(AVERAGE)SAL(EMP)
Groups by the DNO
Query Trees
A data structure that corresponds to the relation algebra expression