1 / 6

The relational algebra and calculus

The relational algebra and calculus. … SQL. The big 3: . Selection and projection are unary ops Join is binary Selection is based on a formula and returns a table that contains all tuples from a given table where the formula is valid

wenda
Download Presentation

The relational algebra and calculus

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. The relational algebra and calculus … SQL

  2. The big 3: • Selection and projection are unary ops • Join is binary • Selection is based on a formula and returns a table that contains all tuples from a given table where the formula is valid • Projection returns a table consisting of a subset of attributes from a given table, with dupes removed • Join creates tuples with attributes from two given tables, where a specific attribute in one matches a specific attribute in another (often a PK, FK pair)

  3. Algebraic closure • Any relational algebra operation returns a legal derived table • The set operators are also part of the algebra • From a formal perspective, the join operator is not a minimal operator, and is therefore represented as a cross product followed by a selection (where the PK equals the FK) • Note that joins are symetric

  4. Joins can be generalized • Complex join conditions • Non-equi joins • A “natural” join is based on matching all attributes with equal names in both tables • “Outer” join creates null-packed tuples when tuples on the left do not match any on the right; there is also a right outer join

  5. The calculus • It is a tuple calculus, not a domain calculus • SQL is equivalent • Select From Where • The part after the Where is declarative • A tuple calculus (SQL) • Notice that the variables are indeed tuples • Note that set operators often act on tables that are being created in the query

  6. More • IN operator is “element of” • EXISTS • Nesting • FOR ALL • FOR SOME • Putting computations in the SELECT clause • COUNT, SUM, AVG, MAX, MIN operators

More Related