THE RELATIONAL MODEL. University of Waterloo

Similar documents
The Relational Model

SQL Part 3: Where Subqueries and other Syntactic Sugar Part 4: Unknown Values and NULLs

Multisets and Duplicates. SQL: Duplicate Semantics and NULL Values. How does this impact Queries?

Data Integration: Logic Query Languages

The Relational Model

Relational Databases

Database Theory VU , SS Introduction: Relational Query Languages. Reinhard Pichler

DATABASE DESIGN II - 1DL400

Lecture 1: Conjunctive Queries

CSC Discrete Math I, Spring Sets

COMP718: Ontologies and Knowledge Bases

Copyright 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley. Chapter 6 Outline. Unary Relational Operations: SELECT and

Range Restriction for General Formulas

Propositional Calculus: Boolean Functions and Expressions. CS 270: Mathematical Foundations of Computer Science Jeremy Johnson

Database Theory VU , SS Introduction: Relational Query Languages. Reinhard Pichler

Chapter 2 & 3: Representations & Reasoning Systems (2.2)

EMBEDDED SQL Part 1: Static Statements

Query formalisms for relational model relational calculus

Towards a Logical Reconstruction of Relational Database Theory

Chapter 24. Active Database Concepts and Triggers. Outline. Trigger Example. Event-Condition-Action (ECA) Model

Data Integration: Datalog

A Retrospective on Datalog 1.0

Notes. Notes. Introduction. Notes. Propositional Functions. Slides by Christopher M. Bourke Instructor: Berthe Y. Choueiry.

Relational model continued. Understanding how to use the relational model. Summary of board example: with Copies as weak entity

Propositional Calculus. CS 270: Mathematical Foundations of Computer Science Jeremy Johnson

Constraint Solving. Systems and Internet Infrastructure Security

Multi-agent and Semantic Web Systems: RDF Data Structures

Basic Structure Set Operations Aggregate Functions Null Values Nested Subqueries Derived Relations Views Modification of the Database Data Definition

DATABASE THEORY. Lecture 11: Introduction to Datalog. TU Dresden, 12th June Markus Krötzsch Knowledge-Based Systems

Computation Club: Gödel s theorem

Safe Stratified Datalog With Integer Order Does not Have Syntax

Programming Languages Third Edition

Pooya Saadatpanah, Michalis Famelis, Jan Gorzny, Nathan Robinson, Marsha Chechik, Rick Salay. September 30th, University of Toronto.

Lecture 3 SQL. Shuigeng Zhou. September 23, 2008 School of Computer Science Fudan University

Chapter 5: Other Relational Languages

Goals: Define the syntax of a simple imperative language Define a semantics using natural deduction 1

Fundamentals of Physical Design: State of Art

CS W Introduction to Databases Spring Computer Science Department Columbia University

B.H.GARDI COLLEGE OF MASTER OF COMPUTER APPLICATION. Ch. 1 :- Introduction Database Management System - 1

Knowledge Representation

1. true / false By a compiler we mean a program that translates to code that will run natively on some machine.

Description Logics. Description Logics and Databases

An Evolution of Mathematical Tools

v Conceptual Design: ER model v Logical Design: ER to relational model v Querying and manipulating data

Finite State Verification. CSCE Lecture 14-02/25/2016

CS 186, Fall 2002, Lecture 8 R&G, Chapter 4. Ronald Graham Elements of Ramsey Theory

IBM DB2 at UW. David Toman. University of Waterloo. (a mini-tutorial)

Recap Datalog Datalog Syntax Datalog Semantics. Logic: Datalog. CPSC 322 Logic 6. Textbook Logic: Datalog CPSC 322 Logic 6, Slide 1

CSCI.6962/4962 Software Verification Fundamental Proof Methods in Computer Science (Arkoudas and Musser) Chapter p. 1/27

Copyright 2016 Ramez Elmasri and Shamkant B. Navathe

Relational Calculus. Lecture 4B Kathleen Durant Northeastern University

7. Relational Calculus (Part I) 7.1 Introduction

Other Query Languages II. Winter Lecture 12

Ontology and Database Systems: Foundations of Database Systems

Chapter 1: Introduction

Three Query Language Formalisms

Today s topics. Null Values. Nulls and Views in SQL. Standard Boolean 2-valued logic 9/5/17. 2-valued logic does not work for nulls

Finite State Verification. CSCE Lecture 21-03/28/2017

Structural characterizations of schema mapping languages

Database Theory VU , SS Codd s Theorem. Reinhard Pichler

Operations of Relational Algebra

}Optimization Formalisms for recursive queries. Module 11: Optimization of Recursive Queries. Module Outline Datalog

}Optimization. Module 11: Optimization of Recursive Queries. Module Outline

(Refer Slide Time: 4:00)

Relational Algebra and Calculus. Relational Query Languages. Formal Relational Query Languages. Yanlei Diao UMass Amherst Feb 1, 2007

Logic and its Applications

Conceptual Design. The Entity-Relationship (ER) Model

Annoucements. Where are we now? Today. A motivating example. Recursion! Lecture 21 Recursive Query Evaluation and Datalog Instructor: Sudeepa Roy

Basant Group of Institution

Copyright 2016 Ramez Elmasri and Shamkant B. Navathe

This is already grossly inconvenient in present formalisms. Why do we want to make this convenient? GENERAL GOALS

Mahathma Gandhi University

Relational Algebra and Calculus

Propositional Calculus. Math Foundations of Computer Science

6.001 Notes: Section 6.1

Other Relational Languages

Part V. Working with Information Systems. Marc H. Scholl (DBIS, Uni KN) Information Management Winter 2007/08 1

INCONSISTENT DATABASES

Warm-Up Problem. Let L be the language consisting of as constant symbols, as a function symbol and as a predicate symbol. Give an interpretation where

Z Notation. June 21, 2018


Three Query Language Formalisms

Introduction to Databases

CIS 330: Applied Database Systems. ER to Relational Relational Algebra

ITCS 3160 DATA BASE DESIGN AND IMPLEMENTATION

Other Query Languages. Winter Lecture 11

Semantic Optimization of Preference Queries

Chapter 3: Relational Model

T h e incomplete database

Project Assignment 2 (due April 6 th, 2016, 4:00pm, in class hard-copy please)

Database System Concepts

DATABASE THEORY. Lecture 18: Dependencies. TU Dresden, 3rd July Markus Krötzsch Knowledge-Based Systems

Chapter 3: SQL. Database System Concepts, 5th Ed. Silberschatz, Korth and Sudarshan See for conditions on re-use

Introductory logic and sets for Computer scientists

Alloy: A Lightweight Object Modelling Notation

CSE 344 Midterm Exam

Chapter 3: SQL. Chapter 3: SQL

High Level Database Models

Incomplete Information: Null Values

Th(N, +) is decidable

Transcription:

THE RELATIONAL MODEL

1-1 List of Slides 1 2 The Relational Model 3 Relations and Databases 4 Example 5 Another Example 6 What does it mean? 7 Example Database 8 What can we do with it? 9 Variables and Answers 10... its just like Logic 11 Variables and Quantifiers 12 Selecting Things 13 Combining Relations 14 Negation and CWA 15 Safety 16 Relational Calculus 17 Properties of RC 18 Summary

The Relational Model Relational Model: 2 Entities: (names of) real-world objects customer, bank, account,... author, publication,... 1 (the number 1),... Relationships: relationships between entities has an account, located at,... wrote, author, book,... Attributes: properties of relationships (and, in turn, entities) address, account #, balance,... name, title,...

2-1 A collection of data describing a real-world situation. Entities are (generally) real world things we want to store information about. In the database they re encoded using an identifier. Relationships tie entities with their other entities. Attributes form the observable properties of relationships; note that two tuples with identical values of attributes cannot be distinguished and are considered to be the same; that s why everyone has a SSN (SIN in Canada, CPR# in Denmark). In the above example, author is an entity. However, to associate author names and id s with the entities, we can use an author relationship.

Relational Model: 3 Relations and Databases Idea: All information is organized in relations. A RELATION has a name a schema a list of attribute names describing individual elements of tuples (and their types) an instance a finite set of tuples of (identifiers of) entities The attribute name denotes what role an entity plays in a relation(ship).

Relational Model: 4 Example publications pubid title author type year cref ChSa98 Logics for Databases and Information Systems Chomicki, Jan book 1998 ChTo98 Temporal Logic in Information Systems Chomicki, Jan chapter 1998 ChSa98 ChTo98 Temporal Logic in Information Systems Toman, David chapter 1998 ChSa98 JLP0398 Journal of Logic Programming journal 1998 ChTo98a Datalog with Integer Periodicity Constraints Toman, David article JLP0398 DOOD97 International Conference on Deductive and Object-Oriented Databases proceedings 1998 Tom97 Point-Based Temporal Extension of Temporal SQL Toman, David paper DOOD97

Relational Model: 5 Another Example author aid Name 1 Toman, David 2 Chomicki, Jan...... wrote AUTHOR PUBLICAT 1 ChTo98 1 ChTo98a 1 Tom97 2 ChTo98 2 ChTo98a...... publication pubid title ChTo98 Temporal Logic in Information Systems JLP-3-98 Journal of Logic Programming ChTo98a Datalog with Integer Periodicity Constraints DOOD97 International Conference on Deductive and Object... Tom97 Point-Based Temporal Extension of Temporal SQL......

Relational Model: 6 What does it mean? Membership (presence) of a tuple in a relation means that the relationship holds among in the given database instance. We write or. For example: DB wrote 1 ChTo98 means that, in the database DB, a publication identified by ChTo98 has been written by author with author id 1. Database modification (update) changes the relationships that are true/false in the database (for which a tuple is present/absent).

Relational Model: 7 Example Database Tables (in the DB database) used in examples: author(aid, name) wrote(author, publication) publication(pubid, title) book(pubid, publisher, year) journal(pubid, volume, no, year) proceedings(pubid, year) article(pubid, crossref, startpage, endpage)

Relational Model: 8 What can we do with it? Idea: Combine simple questions about what is true in the database into more complex questions using logical connectives. Yes/No queries: in DB, does the publication ChTo98 have a title Temporal Logic in Information Systems?... we could explore the database by asking (lots) of Yes/No queries. not efficient you can only verify statements... not quite satisfactory: we d like to retrieve all elements for which some statement holds in one shot.

Relational Model: 9 Variables and Answers Idea: we use logical variable(s) to range over values in the database. The values of these variable(s) form new relations. variables and answers: Yes/No queries are parametrized by variables. An answer is the set of all values that, when substituted for the variables, make the query true in. retrieve all such that is true in : queries may contain many parameters (variables).

Relational Model: 10... its just like Logic Don t panic! Statements about numbers: is true (in ) is false in (but true in ) (false in, true in ) Formation of sets: the set of all numbers bigger than 5 the roots of the equation! " a circle

Relational Model: 11 Variables and Quantifiers Often we don t care what value(s) a variable contains, as long as there is at least one such value. Moreover, we often do not want such values to appear in the answer. Questions of the form there is a value for is true in the database : DB such that note that may contain other variables (e.g., ).

Relational Model: 12 Selecting Things If we need to retrieve only answers that satisfy some additional predicate we use built-in predicates. equality:,, string, etc. other predicates (depending on the data type, e.g., for numerical values) The built-in predicates also define tables, but are not stored in the database: the DBMS computes the value of the predicate. the arguments have to be bound in a base relation.

Relational Model: 13 Combining Relations We can ask about what is true in several relations: conjunction ( ) of formulas (usually atomic) use of shared variables: forces equality on parts of tuples. use of quantification to hide uninteresting variables: by far the most common pattern in queries

Relational Model: 14 Negation and CWA Idea: Only relationships explicitly stored in the database are true. everything not in the database is false: to find out that DB wrote 5 ChTo98 we simply see that DB wrote 5 ChTo98 i.e., the tuple (5,ChTo98) is not in wrote. Closed World Assumption.

Relational Model: 15 Safety Answers to a queries have to be finite. Not completely clear for negation, compare the following two queries: List the names of all authors (good). List the names of all non-authors (bad). Only Range-Restricted queries allowed all SQL queries are range-restricted.

Relational Model: 16 Relational Calculus The language we formulate statements about truth in the database is based on first-order (predicate) logic (with few restrictions that guarantee safety): for for for where is the set of free variables of.

Relational Model: 17 Properties of RC Clean semantics Results do NOT depend on implementation Efficient implementation (Relational Algebra) All queries terminate not Turing complete (in PTIME, LOGSPACE) estimation of execution time possible Expressiveness results it is known what questions can be formulated in RC sufficient for most busines applications, but no transitive closure, cardinality, counting,...

Relational Model: 18 Summary A Relational database stores information about relationships between entities in finite relations. Entities are denoted by constants which the DBMS does NOT understand. A relationship can be true: a tuple is present, or false: a tuple is absent (CWA). A query language allows us to combine simple facts into complex statements: The statements may be parametric: The result is a set of values that, when substituted for parameters, make the statement true. Results of queries are relations themselves. We use (safe) relational calculus to formulate queries. SQL is just a (strange) syntax for RC.