Datalog Educational System V4.2 User's Manual
Total Page:16
File Type:pdf, Size:1020Kb
Universidad Complutense de Madrid Datalog Educational System Datalog Educational System V4.2 User’s Manual Fernando Sáenz-Pérez Grupo de Programación Declarativa (GPD) Departamento de Ingeniería del Software e Inteligencia Artificial (DISIA) Universidad Complutense de Madrid (UCM) September, 25th, 2016 Fernando Sáenz-Pérez 1/341 Universidad Complutense de Madrid Datalog Educational System Copyright (C) 2004-2016 Fernando Sáenz-Pérez Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in Appendix A, in the section entitled " Documentation License ". Fernando Sáenz-Pérez 2/341 Universidad Complutense de Madrid Datalog Educational System Contents 1. Introduction........................................................................................................................... 9 1.1 Novel Extensions in DES ......................................................................................... 10 1.2 Highlights for the Current Version ........................................................................ 11 1.3 Features of DES in Short .......................................................................................... 11 1.4 Future Enhancements............................................................................................... 14 1.5 Related Work............................................................................................................. 14 1.5.1 Deductive Database Systems............................................................................ 14 1.5.2 Technological Transfers..................................................................................... 16 1.5.3 Systems with Formal Relational Query Languages ...................................... 16 2. Installation........................................................................................................................... 17 2.1 Downloading DES .................................................................................................... 17 2.1.1 Source Distribution ............................................................................................ 17 2.1.2 Executable Distribution..................................................................................... 18 2.1.2.1 Windows ..................................................................................................... 18 2.1.2.2 DES+ACIDE Bundle.................................................................................. 20 2.1.2.3 Linux............................................................................................................ 20 2.1.2.4 Mac OS X..................................................................................................... 21 2.1.3 Other Interfaces .................................................................................................. 23 2.1.3.1 Emacs........................................................................................................... 23 2.1.3.2 Crimson Editor 3.70................................................................................... 24 2.2 Installing and Executing DES.................................................................................. 26 2.2.1 MS Windows....................................................................................................... 26 2.2.1.1 Executable Distribution............................................................................. 26 2.2.1.2 Source Distribution.................................................................................... 26 2.2.2 Linux .................................................................................................................... 26 2.2.2.1 Executable Distribution............................................................................. 26 2.2.2.2 Source Distribution.................................................................................... 27 2.2.3 Starting DES from a Prolog Interpreter........................................................... 27 3. Getting Started.................................................................................................................... 27 3.1 Datalog Mode............................................................................................................ 29 3.2 SQL Mode .................................................................................................................. 32 3.3 Relational Algebra Mode......................................................................................... 35 3.4 Tuple Relational Calculus Mode ............................................................................ 40 3.5 Domain Relational Calculus Mode......................................................................... 43 3.6 Prolog Mode .............................................................................................................. 46 3.7 Caveats ....................................................................................................................... 47 3.8 Getting Help .............................................................................................................. 48 4. Query Languages................................................................................................................ 48 4.1 Datalog ....................................................................................................................... 49 4.1.1 Syntax................................................................................................................... 49 4.1.2 Rules..................................................................................................................... 52 4.1.3 Programs ............................................................................................................. 52 4.1.4 Queries................................................................................................................. 52 4.1.5 Temporary Views............................................................................................... 53 4.1.6 Automatic Temporary Views ........................................................................... 53 4.1.7 Underscored Variables ...................................................................................... 54 4.1.8 Negation .............................................................................................................. 56 Fernando Sáenz-Pérez 3/341 Universidad Complutense de Madrid Datalog Educational System 4.1.9 Duplicates............................................................................................................ 58 4.1.10 Null Values.......................................................................................................... 61 4.1.11 Outer Joins........................................................................................................... 62 4.1.12 Aggregates .......................................................................................................... 64 4.1.12.1 Aggregate Functions ................................................................................. 64 4.1.12.2 Group_by Predicate................................................................................... 64 4.1.12.3 Aggregate Predicates................................................................................. 67 4.1.12.4 Aggregates and Duplicates....................................................................... 69 4.1.13 Disjunctive Bodies.............................................................................................. 71 4.1.14 Relational Division in Datalog ......................................................................... 72 4.1.15 Existential Quantification.................................................................................. 73 4.1.16 Integrity Constraints.......................................................................................... 74 4.1.16.1 Type ............................................................................................................. 75 4.1.16.1.1 Types on the Intensional Database .................................................. 77 4.1.16.1.2 Types on Propositional Relations..................................................... 78 4.1.16.1.3 Type Casting........................................................................................ 78 4.1.16.2 Nullability (Existency Constraint)........................................................... 80 4.1.16.3 Primary Key................................................................................................ 80 4.1.16.4 Candidate Key (Uniqueness Constraint)................................................ 81 4.1.16.5 Foreign Key................................................................................................. 81 4.1.16.6 Functional Dependency ............................................................................ 83 4.1.16.7 User-defined Integrity Constraints ......................................................... 83 4.1.16.8 Dropping Constraints................................................................................ 87 4.1.16.9 Caveats ........................................................................................................ 87 4.1.17 Restricted Predicates.........................................................................................