1 / 23

Datenbanktheorie VU

Datenbanktheorie VU. FO Queries; domain independence, algebra vs. calculus. FO-Queries. Relational domain calculus (FO queries) = relational algebra. Weed out meaningless queries in calculus – domain independence. “Relationally complete” query languages (Codd).

sdearborn
Download Presentation

Datenbanktheorie VU

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. Datenbanktheorie VU FO Queries; domain independence, algebra vs. calculus

  2. FO-Queries • Relational domain calculus (FO queries) = relational algebra. • Weed out meaningless queries in calculus – domain independence. • “Relationally complete” query languages (Codd). • Does not mean that all queries can be expressed.

  3. Relational Algebra • SPC + set union + set difference • SQL: select – from – where – union – difference. • select Name from Empdifference select Name from Manager;

  4. Relational (Domain) Calculus • First-order logic over the database relations • Same as SQL queryselect e.x from Emp ewhere e.y not in (select * from Manager);

  5. FO Examples: True or false? u v w

  6. FO Examples: True or false? u v w

  7. Domain Independence • Exclude “unsafe” queries.

  8. FO Beispiele: Wahr oder falsch? u v w

  9. FO Beispiele: Wahr oder falsch? u v w

  10. Domain Independence

  11. Domain Independence • We would like to be able to require domain independence in queries but… • Domain independence is an undecidable property for first-order queries. • Usual solution: syntactic restrictions. • E.g. the “range-restricted queries” • Sufficient condition for domain independence

  12. Range-restricted queries • Safe-range normal form (SRNF) • Var. substitution: no distinct pair of quantifiers may bind same variable. • Remove universal quantifiers • Remove implications • Flatten and/or

  13. Range restriction check

  14. Range restriction check • Input formula Q in SRNF • If all free variables of Q appear in rr(Q), then Q is range-restricted. • Fact: for every domain-independent FO query, there is an equivalent RR FO query.

  15. RR Examples

  16. Codd‘s Theorem

  17. From the Algebra to the Calculus • Almost by definition • Analogously for union and difference

  18. From RR Queries to the Algebra • Start with SRNF • Put into Relational-Algebra NF (RANF):Each subexpression of the formula must be self-contained = locally range-restricted. • This means that a relational algebra formulacan be computed by induction from leaf of the parse tree of the formula to the root.

  19. From RR Queries to the Algebra

  20. From RR Queries to the Algebra

  21. From RR Queries to the Algebra

  22. The End.

More Related