Relational Algebra and Expression Trees
Explain selection, projection and join as typed transformations of rows and identify which variables must remain available to later operators.
- Source
- Anbloq
- Language
- English
- Created
- Updated
- Chapters
- 2
- Reading time
- 1 min
In this article2 chapters
A schema is part of an expression’s output
Selection keeps rows satisfying a predicate and retains the schema. Projection keeps selected attributes. Under classical set semantics it also removes duplicates. A join combines matching tuples, commonly from relations with disambiguated attribute names. For an orders relation joined to customers, a customer identifier may be needed for matching even when the final output shows only order date and customer name.
Compare an equivalent expression before optimizing it
Filtering orders by a date condition first can reduce join input when that predicate mentions only order fields and the context permits the rewrite. Removing the identifier before the join would instead remove information the operator uses. Query rewrite laws justify such changes formally. Bag semantics explains why SQL can require multiplicity reasoning even for similarly shaped plans.[1][2]