Like normal projection, but can create new columns
$\pi_{M \leftarrow A+B*C,\; N \leftarrow 2}(R)$produces 1 row for every row of R, with 2 columns: M and N
... but first
NULL
ValuesNULL
value for these casesNULL makes things more complicated.
What happens if Trees.SPC_COMMON is NULL?
Unknown | AND | Unknown | $\equiv$ | Unknown |
Unknown | AND | True | $\equiv$ | Unknown |
Unknown | AND | False | $\equiv$ | False |
Unknown | OR | Unknown | $\equiv$ | Unknown |
Unknown | OR | True | $\equiv$ | True |
Unknown | OR | False | $\equiv$ | Unknown |
NOT | Unknown | $\equiv$ | Unknown |
WHERE
clauses eliminate all non-True rows
What happens if some streets have no trees?
$$\tau_{A}(R)$$ The tuples of $R$ in ascending order according to 'A'
$$\textbf{L}_{n}(R)$$ The first $n$ tuples of R
Pick your favorite sort algorithm.
What happens if you don't have enough memory?
Key Idea: Merging 2 sorted lists requires $O(1)$ memory.
Repeat Pass 2 As Needed.
What's the bottleneck?
IO Cost: $O(N \cdot \lceil\log_2(N)\rceil)$
(with $N$ blocks)
On average, we'll get runs of size $2 \cdot |WS|$