Operator | Operation | Example |
---|---|---|
Selection | ||
Projection | ||
Cross-Product | ||
Natural Join | ||
Theta Join | ||
Rename | ||
Eliminate Duplicates | ||
Sort Tuples | ||
Grouping & Aggregation |
selection
idea: picking certain row
is the condition refers to attribute in
def: is all those tuples of that satisfies C
projection
idea: picking certain column
is the list of attributes from
products
theta-join
idea: product of and then apply to results
think of where
natural join
- equating attributes of the same name
- projecting out one copy of each pair of equated attributes
renaming
set operators
union compatible
two relations are said to be union compatible if they have the same set of attributes and types (domain) of the attributes are the same
i.e: Student(sNumber, sName)
and Course(cNumber, cName)
are not union compatible
bags
definition
modification of a set that allows repetition of elements
Think of is a bags, whereas is also considered a bag.
Lien vers l'originalin a sense, happens to also be a set.
Set Operations on Relations
For relations and that are union compatible, here’s how many times a tuple appears in the result:
Operation | Symbol | Result (occurrences of tuple ) |
---|---|---|
Union | ||
Intersection | ||
Difference |
where is the number of times appears in and is the number of times it appears in .
sequence of assignments
precedence of relational operators:
expression tree
extended algebra
: eliminate duplication from bags
: sort tuples
grouping and aggregation
outerjoin: avoid dangling tuples
duplicate elimination
Think of it as converting it to set
sorting
with is a list of some attributes of
basically for ascending order, for descending order then use
applying aggregation
or
-
group accordingly to all grouping attributes on
-
per group, compute
AGG(A)
for each aggrgation on -
result has one tuple for each group: grouping attributes and aggregations
aggregation is applied to an entire column to produce a single results
outerjoin
essentially padding missing attributes with NULL
bag operations
remember that bag and set operations are different
set union is idempotent, whereas bags union is not.rightarrow
bag union:
bag intersection:
bag difference: