UCLouvain / ICTEAM, 2015-2016 Bernard Lambeau
[email protected]
LINGI2172 – Databases Summary & Puzzle
Foundation of last week Logic AND
EXISTS
Tutorial D (relational) counterpart JOIN
WHERE (restriction, aka selection or σ) EXTEND (extension)
SUMMARIZE
and some more {...} (projection aka π)
OR UNION (AND) NOT MINUS (difference) NOT MATCHING (semi-difference) RENAME
Puzzle of the Day a typical exam question
Define the following operator using other operators of Tutorial D: Let s = r IMAGE { IN r1 AS A1, ... }. Then: • The heading of s consists of the attributes of the heading of r plus the attributes A1 … An. The declared type of Ak is a relation type. • The body of s consists of tuples formed from each tuple of r by adding n additional attributes A1 to An. • The value of attribute Ak is a subset of rk that matches the tuple of r, projected on all but common attributes of r and s.
SUPPLIERS IMAGE { IN SHIPMENTS AS Supplies } +------+-------+---------+--------+-----------------+ | Sid | Name | Status | City | Supplies | +------+-------+---------+--------+-----------------+ | S1 | Smith | 20 | London | +------+------+ | | | | | | | :pid | :qty | | | | | | | +------+------+ | | | | | | | P1 | 300 | | | | | | | | P2 | 200 | | | | | | | | ... | | | | | | | +------+------+ | | S2 | Jones | 10 | Paris | +------+------+ | | | | | | | :pid | :qty | | | | | | | +------+------+ | | | | | | | P1 | 300 | | | | | | | | P2 | 400 | | | | | | | +------+------+ | | ... | | S5 | Adams | 30 | Athens | +------+------+ | | | | | | | :pid | :qty | | | | | | | +------+------+ | | | | | | +------+------+ | +------+-------+---------+--------+-----------------+
Learn more about how awesome relational databases could be on www.try-alf.org/blog