Deduction in Datalog and SQL Deduction in Datalog And

Deduction in Datalog and SQL Deduction in Datalog And

Chap. 2: Datalog and SQL 2 IntelligentIntelligent Information Information Systems Systems WS 2018/19 DeductionDeductionDeduction ininin DatalogDatalogDatalog andandand SQLSQLSQL Chapter 2 © 201 8 Prof. Dr. Rainer Manthey Intelligent Information Systems 1 At the Core of Intelligent Databases: Managing Derived Data 2 • The essential topic of this lecture is to understand the importance of the idea of using the concept of derived data (and of the corresponding technology). derivedderived • We already learnt last week, that data - bases „containing “stored as well as derived data are called deductive databases in scientific terminology. • In order to manage derived data, we need special abilities of our DBMS that turn it into a deductive DBMS . • Managing derived data means • designing a deductive DB schema • incl. specifying derivation rules • evaluating queries over derived data storedstored • controlling consequences of changes of derived data © 201 8 Prof. Dr. Rainer Manthey Intelligent Information Systems 2 Stored or Derived (or both?) 2 • Storing data is the „normal “ way of keeping data (in some storage device). • Every data element can be stored (in principle). derivedderived • But there are data elements that do not (necessarily) have to be stored , but (possibly) can be computed from stored (or other) derived data elements instead. We call such pieces of data „derived “ data (elements). • It would be more precise to speak about „derivable “ data, because may be a derivable piece of data is actually never derived later on (or has never been derived up till now). We will use the term „derived “ data nevertheless. • Part of the derivable data can redundantly be stored (after having been derived first) in order storedstored to avoid costly rederivation. We call such data materialized (derived) data. © 201 8 Prof. Dr. Rainer Manthey Intelligent Information Systems 3 Another Topic of the Lecture: How to Derive Data? 2 derivedderived DBMS Inference Engine How do inference (derivation) engines look like? Should they be part of a DBMS or external tools? storedstored WeWe follow follow a a specific specificapproach approach in in IIS! IIS! © 201 8 Prof. Dr. Rainer Manthey Intelligent Information Systems 4 Learning by Doing 2 IntelligentIntelligent InformationInformation SystemsSystems WS 2018/19 2.2. Datalog Datalog and and SQL SQL 2.12.1 Datalog Datalog and and SQL: SQL: Learning Learning by by Doing Doing 2.22.2 Datalog: Datalog: Syntax Syntax and and (Basic) (Basic) Semantics Semantics 2.32.3 From From SQL SQL to to Datalog Datalog (and (and Back) Back) © 201 8 Prof. Dr. Rainer Manthey Intelligent Information Systems 5 Case Study: The British Royal Family 2 A case study on using derived data will give us a concrete start into using the techniques of Deductive Database technology: A Genealogical Database © 2017201 8 Prof. Dr. Rainer Manthey Intelligent Information Systems 6 The Royal Family Tree: Our Example Application Domain 2 Husband -Wife Parent -Child TheThe current current family family tree tree of of the the BritishBritish royal royal family family (starting (starting fromfrom the the Queen Queen and and her her husband) husband) © 2017201 8 Prof. Dr. Rainer Manthey Intelligent Information Systems 7 The Royal Family Tree: More Recent Updates 2 Husband -Wife Parent -Child SinceSince last last year, year, several several „ „updates“updates “ happened: happened: ••William William and and Kate Kate have have a a third third child, child, Louis Louis ••Harry Harry married married Meghan Meghan ••Eugenie Eugenie married married Jack Jack ••(to (to come: come: Meghan Meghan is is pregnant pregnant...) ...) © 2017201 8 Prof. Dr. Rainer Manthey Intelligent Information Systems 8 From Family Tree to Genealogical Database? 2 ?? HowHow to to „ „putput a a family family tree tree into into a a (relational) (relational) database database“?“? (i.e., how to design a basic genealogical database) © 2017201 8 Prof. Dr. Rainer Manthey Intelligent Information Systems 9 Conceptual Modeling of the Family Tree DB 2 • Traditional way of designing a relational DB: Start by conceptually modelling the resp. application domain • Corresponding ER diagram (Entity -Relationship approach): father husband parents child person marriage wife married mother title divorced name birth death sex • Basic technique for logical design : deriving a relational DB schema from an ER diagram • per entity type one table: Each attribute of the E -type turned into attribute of table • per relationship type on table, too: Each attribute of the R -type into attribute of corr. table, plus key attributes of of participating E -types (as foreign keys) © 2017201 8 Prof. Dr. Rainer Manthey Intelligent Information Systems 10 Logical Modeling of the Family Tree DB (1) 2 • The basic relational schema for this ER diagram looks as follows: • person (title, name , birth, death, sex) • parents ( father , mother , child ) • marriage ( husband , wife , married , divorced) • Roles in R -types are turned into attributes of the corr. R -table. father husband parents child person marriage wife married mother title divorced name birth death sex © 2017201 8 Prof. Dr. Rainer Manthey Intelligent Information Systems 11 Logical Modeling of the Family Tree DB (2) 2 • person (title, name , birth, death, sex) • parents (father, mother, child ) • marriage ( husband , wife , married , divorced) The initial design can be improved by integrating certain relati onship tables into entity tables in case of 1:N functionalities : father husband 1 N M parents child person marriage N wife 1 mother • person (title, name , birth, death, sex , father, mother) • marriage ( husband , wife , married , divorced) © 2017201 8 Prof. Dr. Rainer Manthey Intelligent Information Systems 12 Corresponding Genealogical Database 2 Person Key One possible (initial) relational format for family trees: just two tables! Title Marriage The entire family tree is „in “ these two tables. Disadvantage(?): Many empty cells ( „nulls “) © 201 8 Prof. Dr. Rainer Manthey Intelligent Information Systems 13 Just Stored Data in Our Genealogical DB – Up Till Now 2 • All the data representing what we know about the Royal family members (in the family tree) have to be stored in tables Title of our relational DB. • All the information in these two tables are „given “ data reported from the „real world “. • None of this could have been derived from other parts of the database. CanCan we we turn turn this this DB DB intointo a a deductive deductiveDB DB byby extending extending it it with with Marriage additionaladditional derived derived data data?? HowHowto to do do this, this, ... ... Person ...if...if we we can? can? © 2017201 8 Prof. Dr. Rainer Manthey Intelligent Information Systems 14 Genealogical Terminology: Potential for Deduction 2 Blood relation (or: consanguinity) only! Numbers indicate percentage of „common blood “ In this graph, relatives from the maternal side are given only – paternal relatives analogously. • Data about „existence “ (birth, death, sex, name etc.) cannot be derived , but have to be entered manually and stored in tables . The same applies to marriage and divorce. • All other data about family relationships, however, are derivable from these stored data, provided we can express them using suitable derivation rules . © 2017201 8 Prof. Dr. Rainer Manthey Intelligent Information Systems 15 Example: Deriving Uncle Data from the Stored Family Tree Data 2 e.g.: HowHow to to derive derive data data about about the the unclesunclesof of a a person? person? (Aunts could be treated analogously.) UncleUncle (from(from Latin: Latin: avunculus avunculus "little"little grandfather", grandfather", the the diminutive diminutive of of avus avus "grandfather")"grandfather") isis a a family family relationship relationship or or kinship, kinship, between between a a person person and and his his or or her her parent's parent's brother brother,, parent'sparent's brother-in-law brother-in-law or or parent's parent's cousin. cousin. (from: en/wikipedia) (Here we restrict ourselves to uncle in the narrow sense) © 2017201 8 Prof. Dr. Rainer Manthey Intelligent Information Systems 16 „Uncle “ as a Derived Table 2 Person UncleUncle Title ItIt would would be be nice nice to to havehave the the data data about about unclesuncles in in the the Royal Royal familyfamily in in a a table table of of itsits own own – –best best in in a a derivedderived table table!! (If(Ifpossible!) possible!) stored derived (Uncles of Charlotte and Mia still missing.) © 2017201 8 Prof. Dr. Rainer Manthey Intelligent Information Systems 17 Uncle Relationships in the Royal Family Tree? ?? AnAn uncleuncle ofofa a person person is is (one (one of) of) hishis (or (or her) her) parent's parent's brothers brothers.. © 201 8 Prof. Dr. Rainer Manthey Uncle Relationships in the Royal Family Tree! 2 !! AndAnd several several additional additionaluncle uncle relationshipsrelationships – –how how many? many? (Do Savannah and Isla have any uncles?) © 201 8 Prof. Dr. Rainer Manthey How to Derive a Particular Uncle Row? 2 UncleUncle Person HowHow to to derive derive the Uncle table Title the Uncle table fromfrom the the Person Person table?table? A derivation strate - gy a human would use, might serve as a suitable strategy of a deduction „engine “. (Is this some kind of „artificial intelligence “ ?) © 2017201 8 Prof. Dr. Rainer Manthey Intelligent Information Systems 20 Relational Views as Specifications of a Derivation Strategy 2 Derived tables in a relational DB are Title obtainable

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    117 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us