<aside> πΊ RA β the basic set of operations for relational model
</aside>
Important for:
<aside> πΊ Binary operation β two relations $R_1(A_1,...,A_n)$ and $R_2(B_1,...,B_n)$ are said to be union compatible if they have the same degree n and if $dom(A_i)=dom(B_i)$ for $1\le i\le n$.
</aside>
Union compatibility are required for union, intersection, and set difference operators. Operators like cartesian product and join doesn't need union compatibility.
Set operations
combining each tuple in $R_1$ with each tuple in $R_2$
$R_1 \times R_2$
π $Employee \times Dependents$
π $People \times Students$
mainly used to express joins
useful when followed by a selection condition
Operations for specific relational DB
Select β $\sigma$ (unary operation)
returns all tuples which satisfy a condition
$\sigma_{<condition>}R$
π $\sigma_{salary>40000}(Employee)$
π $\sigma_{name="smith"}(Employee)$
select *
from students
where gpa > 3.5;
$$ \sigma_{gpa>3.5}(students) $$
clauses can be connected by the standard boolean operatiors and, or, not, to form a general selection condition
π $\sigma_{(Dno=4 \text{ and } salary>25000) \text{ or } (Dno=5 \text{ and } salary>30000)} (Employee)$
a sequence of selects can be applied in any order and any cascade of select operations can then be combined into a single select operations with conjunctive AND condition.
select operation is commutative
Project β $\pi$ (unary operation)
select certain columns and eliminates the other columns, then removes duplicates
$\pi_{<attribute \ list>}(R)$
π $\pi_{sname,gpa}(Students)$
π $\pi_{name,salary}(Employee)$
select distinct sname, gpa
from students;
$$ \pi_{sname, gpa}(students) $$
Rename β $\rho$ (unary operation)
select sid as studId, sname as name, gpa as gradePtAvg
from students;
$$ \rho_{(studId, name, gradePtAvg)}(Students) $$
Join β (binary operation)
(Theta) Join
to combine related tuples from two relations into single tuples
allows us to process relationship among relations
$R_1 β_{<join \ condition>}R_2$
π $Result = (People)β_{<Pname=Sname>}(Students)$
this join example is called equijoin β a join operation that uses only equality comparison operator
(Natural) Join
(Semi) Join β
$Rβ_{<join \ condition>}S$ or $\pi_{A_1,...,A_n}(RβS)$
π $People β_{pname=sname}(Students)$
select distinct ssn, pname, address
from people, students
where pname = sname;
$$ Peopleβ_{pname,sname}Students $$
Other
Things to note: