ER Modelling: Summary

Size: px
Start display at page:

Download "ER Modelling: Summary"

Transcription

1 ER Modelling: Summary ER describes the world (the set of possible worlds) what it is and the laws of this world ER is static: it does not describe (legal) transitions Useful for two purposes build software to answer questions about the world judge whether something is legal or illegal Use Case 1: build software to answer questions we will learn that methodology next (ER->relational) Use Case 2: judge what is legal you need a mapping from ER to the real world What does drink mean? What does has mean? you need to be consistent with that mapping. Not easy in a model with 30,000 entities and 70,000 relationships Main tools of modelling: scissors (abstraction & classification) 1

2 Relational Data Model Relation: R D 1 x... x D n D 1, D 2,..., D n are domains Example: AddressBook string x string x integer Tuple: t R Example: t = ( Mickey Mouse, Main Street, 4711) Schema: associates labels to domains Example: AddrBook: {[Name: string, Address: string, Tel#:integer]} 2

3 AddrBook Name Street Tel# Mickey Mouse Main Street 4711 Minnie Mouse Broadway Donald Duck Broadway Instance: the state of the database Key: minimal set of attributes that identify each tuple uniquely E.g., {Tel#} or {Name, BirthDate} Primary Key: (marked in schema by underlining) select one key use primary key for references 3

4 Uni-Schema Legi Name Student Semester N N requires followup prerequisite attends M N Lecture M M N Nr CP Title Grade tests gives PersNr 1 1 Level Name Assistant N Works-for 1 Professor Room Area PersNr Name 4

5 Rule #1: Implementation of Entities Student: {[Legi:integer, Name: string, Semester: integer]} Lecture: {[Nr:integer, Title: string, CP: integer]} Professor: {[PersNr:integer, Name: string, Level: string, Room: integer]} Assistant: {[PersNr:integer, Name: string, Area: string]} 5

6 Rule #2: Relationships A 21 A 2k 2 A 11 E 1... E 2 R... E n A 1k1 A R 1 R A k R A n1 A nk n R R A11,..., A1 k, A21,..., A2,..., 1,...,, 1,..., 1 k A 2 n Ank A A n kr R:{[ ]} Key of E 1 Key of E 2 Key of E n Attributesof R 6

7 Implementation of Relationships attends : {[Legi: integer, Nr: integer]} gives : {[PersNr: integer, Nr: integer]} works-for : {[AssistentPersNr: integer, ProfPersNr: integer]} requires: {[prerequisite: integer, follow-up: integer]} tests : {[Legi: integer, Nr: integer, PersNr: integer, Grade: decimal]} 7

8 Instance of attends Student Legi Legi Student N attends LegiNr Nr attends M Lecture Nr Nr Lecture 8

9 Rule 2: How to call the attributes If the ER specifies roles use the names of the roles Otherwise use the names of the key attributes in the entities in case of ambiguity, invent new names Example: friend : {[ProfNr: integer, AssiNr: integer]} Professor PersNr N friend M Assistant PersNr 9

10 Exercise Implement the following ER diagram using the rel. data model Number 1 1 plus 1 10

11 Rule #3: Merge relations with the same key Professor gives 1 N Lecture Implementation according to Rule #2 Lecture : {[Nr, Title, CP]} Professor : {[PersNr, Name, Level, Room]} gives: {[Nr, PersNr]} Merge according to Rule #3 Lecture : {[Nr, Title, CP, PersNr]} Professor : {[PersNr, Name, Level, Room]} Why is this better? When can this be done? Zusammenwachsen, was zusammen gehört! 1 11

12 Instance of Professor and Lecture Professor PersNr Name Level Room 2125 Sokrates FP Russel FP Kopernikus AP Popper AP Augustinus AP Curie FP Kant FP 7 Lecture Nr Title CP PersNr 5001 Grundzüge Ethik Erkenntnistheorie Mäeutik Logik Wissenschaftstheorie Bioethik Der Wiener Kreis Glaube und Wissen Die 3 Kritiken Professor gives 1 N Lecture 12

13 This will NOT work Professor PersNr Name Level Room gives 2125 Sokrates FP Sokrates FP Sokrates FP Augustinus AP Curie FP 36?? Lecture Nr Title CP 5001 Grundzüge Ethik Erkenntnistheorie Mäeutik Logik Wissenschaftstheorie Bioethik Der Wiener Kreis Glaube und Wissen Die 3 Kritiken 4 Professor gives 1 N Lecture 13

14 This will NOT work Professor PersNr Name Level Room gives 2125 Sokrates FP Sokrates FP Sokrates FP Augustinus AP Curie FP 36?? Lecture Nr Title CP 5001 Grundzüge Ethik Erkenntnistheorie Mäeutik Logik Wissenschaftstheorie Bioethik Der Wiener Kreis Glaube und Wissen Die 3 Kritiken 4 Problem: Redundancy and Anomalies PersNr is no longer key of Professor (issue will be revisited when we talk about normal forms) 14

15 Rule #4: Generalization Area Assistant is_a Employee Professor PersNr Name Room Level 15

16 Rule #4: Generalization Area Assistant is_a Employee Professor PersNr Name Room Level Employee: {[PersNr, Name]} Professor: {[PersNr, Level, Room]} Assistant: {[PersNr, Area]} 16

17 Rule #4: Generalization-alternative Area Assistant is_a Employee Professor PersNr Name Room Level What is better? Employee: {[PersNr, Name]} Professor: {[PersNr, Name, Level, Room]} Assistant: {[PersNr, Name, Area]} 17

18 Rule #5: Weak Entities Student 1 takes N Exam Grade Part Legi covers N N gives Nr M M PersNr Lecture Professor Exam: {[Legi: integer, Part: string, Grade: integer]} covers: {[Legi: integer, Part: string, Nr: integer]} gives: {[Legi: integer, Part: string, PersNr: integer]} 18

19 Weak Entities in detail: takes takes: {[StudiLegi: int, ExamLegi: int, Part: string, Nr: int]} What is/are the key(s) of the takes relation? Why can it be merged with the Exam relation (Rule #3)? What happened to the StudiLegi column as part of this merge? 19

20 Food for Thought: OO vs. Relations How do Java and C++ implement ER? Are they a better match than the relational model? Specifically, how do Java and C++ implement Generalization? Is it good or bad to have several possible ways? Concept of Reference: Compare Java and Relational Model Which one is better? Life-time of objects: Compare Java and Relational Model Why different? 20

21 Relational Model of Uni-DB Professor PersNr Name Level Room 2125 Sokrates FP Russel FP Kopernikus AP Popper AP Augustinus AP Curie FP Kant FP 7 requires Prerequisite Follow-up tests Legi Nr PersNr Grade Student Legi Name Semester Xenokrates Jonas Fichte Aristoxenos Schopenhauer Carnap Theophrastos Feuerbach 2 attends Legi Nr Lecture Nr Title CP PersNr 5001 Grundzüge Ethik Erkenntnistheorie Mäeutik Logik Wissenschaftstheorie Bioethik Der Wiener Kreis Glaube und Wissen Die 3 Kritiken Assistant PerslNr Name Area Boss 3002 Platon Ideenlehre Aristoteles Syllogistik Wittgenstein Sprachtheorie Rhetikus Planetenbewegung Newton Keplersche Gesetze Spinoza Gott und Natur

22 Selection Projection X Cartesian Product A Join Rename Set Minus Relational Division Union Intersection F Semi-Join (left) E Semi-Join (right) C left outer Join D right outer Join Relational Algebra 22

23 Formal Definition of Rel. Algebra Atoms (basic expressions) A relation in the database A constant relation Operators (composite expressions) Selection: p (E 1 ) Projection: S (E 1 ) Cartesian Product: E 1 x E 2 Rename: V (E 1 ), A B (E 1 ) Union: E 1 E 2 Minus: E 1 - E 2 23

24 Selection and Projection Selection Semester > 10 (Student) Semester > 10 (Student) Legi Name Semester Xenokrates Jonas 12 Projection Level (Professor) Rang (Professor) Level FP AP 24

25 Cartesian Product L A B C a 1 b 1 c 1 a 2 b 2 c 2 D R E x = d 1 e 1 d 2 e 2 Result A B C D E a 1 b 1 c 1 d 1 e 1 a 1 b 1 c 1 d 2 e 2 a 2 b 2 c 2 d 1 e 1 a 2 b 2 c 2 d 2 e 2 25

26 Cartesian Product (ctd.) Professor x attends Professoren attends PersNr Name Level Raum Legi Nr 2125 Sokrates FP Sokrates FP Kant FP Huge result set (n * m) Usually only useful in combination with a selection (-> Join) 26

27 Natural Join Two relations: R(A 1,..., A m, B 1,..., B k ) S(B 1,..., B k, C 1,..., C n ) R A S = A1,..., Am, R.B1,..., R.Bk, C1,..., Cn ( R.B1=S. B1... R.Bk = S.Bk (RxS)) R A S R S R S S R A 1 A 2... A m B 1 B 2... B k C 1 C 2... C n 27

28 Three-way natural Join (Student A attends) A Lecture (Student A attends) A Lecture Legi Name Semester Nr Title CP PersNr Fichte Grundzüge Jonas Glaube und Wissen Carnap Wissenschftstheorie

29 Two Relations: R(A1,..., An) S(B1,..., Bm) Theta-Join R R A S = (R x S) R A S R A S S A 1 A 2... A n B 1 B 2... B m 29

30 Theta Join Example Train(name, start, destination,, length) Track(station, number,, length) Find all possible tracks for the CIS Alpino in Zurich station= Zurich (Track) A Train.length < Track.length name= CIS (Train) Source: anonymous student from the 2011 class 30

31 natural join Join Variants L A B C a 1 b 1 c 1 a 2 b 2 c 2 A R C D E c 1 d 1 e 1 = c 3 d 2 e 2 Result A B C D E a 1 b 1 c 1 d 1 e 1 left outer join L R A B C C D E a 1 b 1 c C 1 c 1 d 1 e 1 = a 2 b 2 c 2 c 3 d 2 e 2 Result A B C D E a 1 b 1 c 1 d 1 e 1 a 2 b 2 c

32 Join Variants right outer join L R A B C C D E a 1 b 1 c D 1 c 1 d 1 e 1 = a 2 b 2 c 2 c 3 d 2 e 2 Resultat A B C D E a 1 b 1 c 1 d 1 e c 3 d 2 e 2 32

33 Join Variants (full) outer join L R A B C C D E a 1 b 1 c B 1 c 1 d 1 e 1 = a 2 b 2 c 2 c 3 d 2 e 2 Resultat A B C D E a 1 b 1 c 1 d 1 e 1 a 2 b 2 c c 3 d 2 e 2 left semi join L A B C a 1 b 1 c 1 a 2 b 2 c 2 E R C D E c 1 d 1 e 1 = c 3 d 2 e 2 Resultat A B C a 1 b 1 c 1 33

34 Join Variants right semi join L A B C a 1 b 1 c 1 a 2 b 2 c 2 F R C D E c 1 d 1 e 1 = c 3 d 2 e 2 Resultat C D E c 1 d 1 e 1 34

35 Rename operator: Rename Operator Renaming of relation names Needed to process self-joins and recursive relationships E.g., two-level dependencies of lectures ( grandparents ) L1.Prerequisite( L2. Follow-up=5216 L1.Follow-up = L2.Prerequisite ( L1 (requires) x L2 (requires))) Renaming of attribute names Requirement Prerequisite (requires) 35

36 Intersection PersNr (Lecture) PersNr ( Level=FP (Professor)) Only works if both relations have the same schema Same attribute names and attribute domains Intersection can be simulated with minus: R S = R (R S) 36

37 Relational Division Find students who attended all lectures with 4CP. attends Nr ( CP=4 (Lecture)) 37

38 Definition of Division t R S, iff for each ts S exists a tr R such that: tr.s = ts.s tr.(r-s) = t M R V m 1 v 1 m 1 v 2 m 1 v 3 m 2 v 2 m 2 v 3 Division can be simulated with other operators: S V = v 1 v 2 R S R S = (R S) (R) (R S) (( (R S) (R) x S) R) M m 1 38

39 Division: Example R S = (R S) (R) (R S) (( (R S) (R) x S) R) R = attends; S = Lecture Legi (attends) All students (who attend at least one lecture) Legi (attends) x Lecture All students attend all lectures ( Legi (attends) x Lecture) attends Lectures a student does not attend Legi (( Legi (attends) x Lecture) attends): Students who miss at least one lecture Legi (hören) - Legi (( Legi (attends) x Lecture) attends) Students who attend all lectures What happens if there are no lectures or no attendance? 39

40 Relational Calculus Queries have the following form: {t P(t)} with t a variable, P(t) a predicate. Examples: All full professors {p p Professor p.level = FP'} Students who attend at least one lecture of Curie {s s Student a attends(s.legi=a.legi l Lecture(a.Nr=l.Nr p Professor(p.PersNr=l.PersNr p.name = 'Curie')))} 40

41 Who attends all lectures with 4 CP? {s s Student l Lecture (l.cp=4 a attends(a.nr=l.nr a.legi= s.legi))} There are two variants of relational calculus: tuple relational calculus (as in examples above, tuple vars) domain relational calculus (variables iterate over domains) 41

42 Tuple Relational Calculus Atoms s R s is a tuple variable, R is a name of a relation s.a t.b or s. A c s and t tuple variables, A and B attribute names a comparison (i.e.,,,,...) c is a constant (i.e., 25) Formulas All atoms are legal formulas If P is a formula, then P and (P) are also formulas If P 1 and P 2 are formulas, then P 1 P 2, P 1 P 2 and P 1 P 2 If P(t) is a formula with a free variable t, then t R(P(t)) and t R(P(t)) 42

43 Safety Restrict formulas to queries with finite answers Semantic not syntactic property! Example: The following expression is not safe {n (n Professor)} Definition of safety result must be subset of the domain of the formula domain of the formula All constants used in the formula All domains of relations used in the formula 43

44 Domain Relational Calculus An expression has the following form {[v 1, v 2,..., v n ] P (v 1,..., v n )} each v 1,..., v n is either a domain variable or a constant. P is a formula. Example: Legi and Name of all students tested by Curie: {[l, n] s ([l, n, s] Student v, p, g ([l, v, p, g] tests a,r, b([p, a, r, b] Professor a = 'Curie')))} 44

45 Safety in the DRC Defined in same way as for tuple relational calculus Example: The following expression is not safe {[p,n,r,o] ([p,n,r,o] Professoren) } (see text book for exact definition of safety in DRC) 45

46 Codd`s Theorem The three languages 1. relational algebra, 2. tuple relational calculus (safe expressions only) 3. domain relational calculus (safe expressions only) are equivalent Impact of Codd`s theorem SQL is based on the relational calculus SQL implementation is based on relational algebra Codd`s theorem shows that SQL implementation is correct and complete. 46

Database Applications (15-415)

Database Applications (15-415) Database Applications (15-415) Relational Calculus Lecture 5, January 27, 2014 Mohammad Hammoud Today Last Session: Relational Algebra Today s Session: Relational algebra The division operator and summary

More information

Relational Algebra and Calculus

Relational Algebra and Calculus Topics Relational Algebra and Calculus Linda Wu Formal query languages Preliminaries Relational algebra Relational calculus Expressive power of algebra and calculus (CMPT 354 2004-2) Chapter 4 CMPT 354

More information

Database Applications (15-415)

Database Applications (15-415) Database Applications (15-415) Relational Calculus Lecture 6, January 26, 2016 Mohammad Hammoud Today Last Session: Relational Algebra Today s Session: Relational calculus Relational tuple calculus Announcements:

More information

7 RC Simulates RA. Lemma: For every RA expression E(A 1... A k ) there exists a DRC formula F with F V (F ) = {A 1,..., A k } and

7 RC Simulates RA. Lemma: For every RA expression E(A 1... A k ) there exists a DRC formula F with F V (F ) = {A 1,..., A k } and 7 RC Simulates RA. We now show that DRC (and hence TRC) is at least as expressive as RA. That is, given an RA expression E that mentions at most C, there is an equivalent DRC expression E that mentions

More information

Chapter 3 Relational Model

Chapter 3 Relational Model Chapter 3 Relational Model Table of Contents 1. Structure of Relational Databases 2. Relational Algebra 3. Tuple Relational Calculus 4. Domain Relational Calculus Chapter 3-1 1 1. Structure of Relational

More information

Relational Algebra on Bags. Why Bags? Operations on Bags. Example: Bag Selection. σ A+B < 5 (R) = A B

Relational Algebra on Bags. Why Bags? Operations on Bags. Example: Bag Selection. σ A+B < 5 (R) = A B Relational Algebra on Bags Why Bags? 13 14 A bag (or multiset ) is like a set, but an element may appear more than once. Example: {1,2,1,3} is a bag. Example: {1,2,3} is also a bag that happens to be a

More information

General Overview - rel. model. Carnegie Mellon Univ. Dept. of Computer Science /615 DB Applications. Motivation. Overview - detailed

General Overview - rel. model. Carnegie Mellon Univ. Dept. of Computer Science /615 DB Applications. Motivation. Overview - detailed Carnegie Mellon Univ. Dep of Computer Science 15-415/615 DB Applications C. Faloutsos & A. Pavlo Lecture#5: Relational calculus General Overview - rel. model history concepts Formal query languages relational

More information

Query Processing. 3 steps: Parsing & Translation Optimization Evaluation

Query Processing. 3 steps: Parsing & Translation Optimization Evaluation rela%onal algebra Query Processing 3 steps: Parsing & Translation Optimization Evaluation 30 Simple set of algebraic operations on relations Journey of a query SQL select from where Rela%onal algebra π

More information

Introduction to Data Management. Lecture #12 (Relational Algebra II)

Introduction to Data Management. Lecture #12 (Relational Algebra II) Introduction to Data Management Lecture #12 (Relational Algebra II) Instructor: Mike Carey mjcarey@ics.uci.edu Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 1 Announcements v HW and exams:

More information

COSC 430 Advanced Database Topics. Lecture 2: Relational Theory Haibo Zhang Computer Science, University of Otago

COSC 430 Advanced Database Topics. Lecture 2: Relational Theory Haibo Zhang Computer Science, University of Otago COSC 430 Advanced Database Topics Lecture 2: Relational Theory Haibo Zhang Computer Science, University of Otago Learning objectives and references You should be able to: define the elements of the relational

More information

Relational Algebra & Calculus

Relational Algebra & Calculus Relational Algebra & Calculus Yanlei Diao UMass Amherst Slides Courtesy of R. Ramakrishnan and J. Gehrke 1 Outline v Conceptual Design: ER model v Logical Design: ER to relational model v Querying and

More information

Databases 2011 The Relational Algebra

Databases 2011 The Relational Algebra Databases 2011 Christian S. Jensen Computer Science, Aarhus University What is an Algebra? An algebra consists of values operators rules Closure: operations yield values Examples integers with +,, sets

More information

CS632 Notes on Relational Query Languages I

CS632 Notes on Relational Query Languages I CS632 Notes on Relational Query Languages I A. Demers 6 Feb 2003 1 Introduction Here we define relations, and introduce our notational conventions, which are taken almost directly from [AD93]. We begin

More information

P Q1 Q2 Q3 Q4 Q5 Tot (60) (20) (20) (20) (60) (20) (200) You are allotted a maximum of 4 hours to complete this exam.

P Q1 Q2 Q3 Q4 Q5 Tot (60) (20) (20) (20) (60) (20) (200) You are allotted a maximum of 4 hours to complete this exam. Exam INFO-H-417 Database System Architecture 13 January 2014 Name: ULB Student ID: P Q1 Q2 Q3 Q4 Q5 Tot (60 (20 (20 (20 (60 (20 (200 Exam modalities You are allotted a maximum of 4 hours to complete this

More information

Databases. Exercises on Relational Algebra

Databases. Exercises on Relational Algebra Databases Exercises on Relational Algebra The Lab Sessions Giacomo Bergami (giacomo.bergami2@unibo.it) bergami.co.nr 2016/10/07 Keys and Superkeys Relational Algebra (I) Negation Minimum 2016/10/14 Relational

More information

Plan of the lecture. G53RDB: Theory of Relational Databases Lecture 2. More operations: renaming. Previous lecture. Renaming.

Plan of the lecture. G53RDB: Theory of Relational Databases Lecture 2. More operations: renaming. Previous lecture. Renaming. Plan of the lecture G53RDB: Theory of Relational Lecture 2 Natasha Alechina chool of Computer cience & IT nza@cs.nott.ac.uk Renaming Joins Definability of intersection Division ome properties of relational

More information

UVA UVA UVA UVA. Database Design. Relational Database Design. Functional Dependency. Loss of Information

UVA UVA UVA UVA. Database Design. Relational Database Design. Functional Dependency. Loss of Information Relational Database Design Database Design To generate a set of relation schemas that allows - to store information without unnecessary redundancy - to retrieve desired information easily Approach - design

More information

INTRODUCTION TO RELATIONAL DATABASE SYSTEMS

INTRODUCTION TO RELATIONAL DATABASE SYSTEMS INTRODUCTION TO RELATIONAL DATABASE SYSTEMS DATENBANKSYSTEME 1 (INF 3131) Torsten Grust Universität Tübingen Winter 2017/18 1 THE RELATIONAL ALGEBRA The Relational Algebra (RA) is a query language for

More information

From Constructibility and Absoluteness to Computability and Domain Independence

From Constructibility and Absoluteness to Computability and Domain Independence From Constructibility and Absoluteness to Computability and Domain Independence Arnon Avron School of Computer Science Tel Aviv University, Tel Aviv 69978, Israel aa@math.tau.ac.il Abstract. Gödel s main

More information

CS54100: Database Systems

CS54100: Database Systems CS54100: Database Systems Relational Algebra 3 February 2012 Prof. Walid Aref Core Relational Algebra A small set of operators that allow us to manipulate relations in limited but useful ways. The operators

More information

10/12/10. Outline. Schema Refinements = Normal Forms. First Normal Form (1NF) Data Anomalies. Relational Schema Design

10/12/10. Outline. Schema Refinements = Normal Forms. First Normal Form (1NF) Data Anomalies. Relational Schema Design Outline Introduction to Database Systems CSE 444 Design theory: 3.1-3.4 [Old edition: 3.4-3.6] Lectures 6-7: Database Design 1 2 Schema Refinements = Normal Forms 1st Normal Form = all tables are flat

More information

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska LECTURE 1 Course Web Page www3.cs.stonybrook.edu/ cse303 The webpage contains: lectures notes slides; very detailed solutions to

More information

EECS-3421a: Test #2 Electrical Engineering & Computer Science York University

EECS-3421a: Test #2 Electrical Engineering & Computer Science York University 18 November 2015 EECS-3421a: Test #2 1 of 16 EECS-3421a: Test #2 Electrical Engineering & Computer Science York University Family Name: Given Name: Student#: CSE Account: Instructor: Parke Godfrey Exam

More information

Fuzzy and Rough Sets Part I

Fuzzy and Rough Sets Part I Fuzzy and Rough Sets Part I Decision Systems Group Brigham and Women s Hospital, Harvard Medical School Harvard-MIT Division of Health Sciences and Technology Aim Present aspects of fuzzy and rough sets.

More information

Functional Dependencies and Normalization. Instructor: Mohamed Eltabakh

Functional Dependencies and Normalization. Instructor: Mohamed Eltabakh Functional Dependencies and Normalization Instructor: Mohamed Eltabakh meltabakh@cs.wpi.edu 1 Goal Given a database schema, how do you judge whether or not the design is good? How do you ensure it does

More information

Functional Dependencies. Chapter 3

Functional Dependencies. Chapter 3 Functional Dependencies Chapter 3 1 Halfway done! So far: Relational algebra (theory) SQL (practice) E/R modeling (theory) HTML/Flask/Python (practice) Midterm (super fun!) Next up: Database design theory

More information

CS 4604: Introduc0on to Database Management Systems. B. Aditya Prakash Lecture #3: SQL---Part 1

CS 4604: Introduc0on to Database Management Systems. B. Aditya Prakash Lecture #3: SQL---Part 1 CS 4604: Introduc0on to Database Management Systems B. Aditya Prakash Lecture #3: SQL---Part 1 Announcements---Project Goal: design a database system applica=on with a web front-end Project Assignment

More information

CSE 562 Database Systems

CSE 562 Database Systems Outline Query Optimization CSE 562 Database Systems Query Processing: Algebraic Optimization Some slides are based or modified from originals by Database Systems: The Complete Book, Pearson Prentice Hall

More information

Advanced DB CHAPTER 5 DATALOG

Advanced DB CHAPTER 5 DATALOG Advanced DB CHAPTER 5 DATALOG Datalog Basic Structure Syntax of Datalog Rules Semantics of Nonrecursive Datalog Safety Relational Operations in Datalog Recursion in Datalog The Power of Recursion A More

More information

Design Theory: Functional Dependencies and Normal Forms, Part I Instructor: Shel Finkelstein

Design Theory: Functional Dependencies and Normal Forms, Part I Instructor: Shel Finkelstein Design Theory: Functional Dependencies and Normal Forms, Part I Instructor: Shel Finkelstein Reference: A First Course in Database Systems, 3 rd edition, Chapter 3 Important Notices CMPS 180 Final Exam

More information

Information Systems for Engineers. Exercise 8. ETH Zurich, Fall Semester Hand-out Due

Information Systems for Engineers. Exercise 8. ETH Zurich, Fall Semester Hand-out Due Information Systems for Engineers Exercise 8 ETH Zurich, Fall Semester 2017 Hand-out 24.11.2017 Due 01.12.2017 1. (Exercise 3.3.1 in [1]) For each of the following relation schemas and sets of FD s, i)

More information

Languages. Theory I: Database Foundations. Relational Algebra. Paradigms. Projection. Basic Operators. Jan-Georg Smaus (Georg Lausen)

Languages. Theory I: Database Foundations. Relational Algebra. Paradigms. Projection. Basic Operators. Jan-Georg Smaus (Georg Lausen) Languages Theory I: Database Foundations Jan-Georg Smaus (Georg Lausen) Paradigms 1. Languages: Relational Algebra Projection Union and Difference Summary 26.7.2011 Relational algebra Relational calculus

More information

Homework Assignment 2. Due Date: October 17th, CS425 - Database Organization Results

Homework Assignment 2. Due Date: October 17th, CS425 - Database Organization Results Name CWID Homework Assignment 2 Due Date: October 17th, 2017 CS425 - Database Organization Results Please leave this empty! 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 2.10 2.11 2.12 2.15 2.16 2.17 2.18 2.19 Sum

More information

CSE 544 Principles of Database Management Systems

CSE 544 Principles of Database Management Systems CSE 544 Principles of Database Management Systems Lecture 3 Schema Normalization CSE 544 - Winter 2018 1 Announcements Project groups due on Friday First review due on Tuesday (makeup lecture) Run git

More information

Constraints: Functional Dependencies

Constraints: Functional Dependencies Constraints: Functional Dependencies Fall 2017 School of Computer Science University of Waterloo Databases CS348 (University of Waterloo) Functional Dependencies 1 / 42 Schema Design When we get a relational

More information

Introduction to Database Systems CSE 414. Lecture 20: Design Theory

Introduction to Database Systems CSE 414. Lecture 20: Design Theory Introduction to Database Systems CSE 414 Lecture 20: Design Theory CSE 414 - Spring 2018 1 Class Overview Unit 1: Intro Unit 2: Relational Data Models and Query Languages Unit 3: Non-relational data Unit

More information

Data Dependencies in the Presence of Difference

Data Dependencies in the Presence of Difference Data Dependencies in the Presence of Difference Tsinghua University sxsong@tsinghua.edu.cn Outline Introduction Application Foundation Discovery Conclusion and Future Work Data Dependencies in the Presence

More information

Computational Logic. Relational Query Languages with Negation. Free University of Bozen-Bolzano, Werner Nutt

Computational Logic. Relational Query Languages with Negation. Free University of Bozen-Bolzano, Werner Nutt Computational Logic Free University of Bozen-Bolzano, 2010 Werner Nutt (Slides adapted from Thomas Eiter and Leonid Libkin) Computational Logic 1 Queries with All Who are the directors whose movies are

More information

Fundamentals of Software Engineering

Fundamentals of Software Engineering Fundamentals of Software Engineering First-Order Logic Ina Schaefer Institute for Software Systems Engineering TU Braunschweig, Germany Slides by Wolfgang Ahrendt, Richard Bubel, Reiner Hähnle (Chalmers

More information

Relational Database Design

Relational Database Design Relational Database Design Jan Chomicki University at Buffalo Jan Chomicki () Relational database design 1 / 16 Outline 1 Functional dependencies 2 Normal forms 3 Multivalued dependencies Jan Chomicki

More information

Information Systems for Engineers. Exercise 5. ETH Zurich, Fall Semester Hand-out Due

Information Systems for Engineers. Exercise 5. ETH Zurich, Fall Semester Hand-out Due Information Systems for Engineers Exercise 5 ETH Zurich, Fall Semester 2017 Hand-out 27.10.2017 Due 03.11.2017 Reading material: Chapter 2.4 in [1]. Lecture slides 4. 1. Given the two tables below, write

More information

Fundamentals of Software Engineering

Fundamentals of Software Engineering Fundamentals of Software Engineering First-Order Logic Ina Schaefer Institute for Software Systems Engineering TU Braunschweig, Germany Slides by Wolfgang Ahrendt, Richard Bubel, Reiner Hähnle (Chalmers

More information

Relations. Relations of Sets N-ary Relations Relational Databases Binary Relation Properties Equivalence Relations. Reading (Epp s textbook)

Relations. Relations of Sets N-ary Relations Relational Databases Binary Relation Properties Equivalence Relations. Reading (Epp s textbook) Relations Relations of Sets N-ary Relations Relational Databases Binary Relation Properties Equivalence Relations Reading (Epp s textbook) 8.-8.3. Cartesian Products The symbol (a, b) denotes the ordered

More information

First Steps in Relational Lattice

First Steps in Relational Lattice First Steps in Relational Lattice MARSHALL SPIGHT Marshall.Spight@gmai1.com VADIM TROPASHKO Vadim.Tropashko@orcl.com Relational lattice reduces the set of si classic relational algebra operators to two

More information

Logic in Computer Science. Frank Wolter

Logic in Computer Science. Frank Wolter Logic in Computer Science Frank Wolter Meta Information Slides, exercises, and other relevant information are available at: http://www.liv.ac.uk/~frank/teaching/comp118/comp118.html The module has 18 lectures.

More information

6 The Relational Data Model: Algebraic operations on tabular data

6 The Relational Data Model: Algebraic operations on tabular data 6 The Relational Data Model: Algebraic operations on tabular data 6.1 Basic idea of relational languages 6.2 Relational Algebra operations 6.3 Relational Algebra: Syntax and Semantics 6.4. More Operators

More information

Schema Refinement & Normalization Theory: Functional Dependencies INFS-614 INFS614, GMU 1

Schema Refinement & Normalization Theory: Functional Dependencies INFS-614 INFS614, GMU 1 Schema Refinement & Normalization Theory: Functional Dependencies INFS-614 INFS614, GMU 1 Background We started with schema design ER model translation into a relational schema Then we studied relational

More information

CS5300 Database Systems

CS5300 Database Systems CS5300 Database Systems Relational Algebra A.R. Hurson 323 CS Building hurson@mst.edu This module is intended to introduce: relational algebra as the backbone of relational model, and set of operations

More information

SCHEMA NORMALIZATION. CS 564- Fall 2015

SCHEMA NORMALIZATION. CS 564- Fall 2015 SCHEMA NORMALIZATION CS 564- Fall 2015 HOW TO BUILD A DB APPLICATION Pick an application Figure out what to model (ER model) Output: ER diagram Transform the ER diagram to a relational schema Refine the

More information

Relational Calculus. Dr Paolo Guagliardo. University of Edinburgh. Fall 2016

Relational Calculus. Dr Paolo Guagliardo. University of Edinburgh. Fall 2016 Relational Calculus Dr Paolo Guagliardo University of Edinburgh Fall 2016 First-order logic term t := x (variable) c (constant) f(t 1,..., t n ) (function application) formula ϕ := P (t 1,..., t n ) t

More information

6.830 Lecture 11. Recap 10/15/2018

6.830 Lecture 11. Recap 10/15/2018 6.830 Lecture 11 Recap 10/15/2018 Celebration of Knowledge 1.5h No phones, No laptops Bring your Student-ID The 5 things allowed on your desk Calculator allowed 4 pages (2 pages double sided) of your liking

More information

The Meaning of Entity-Relationship Diagrams, part II

The Meaning of Entity-Relationship Diagrams, part II (1/23) Logic The Meaning of Entity-Relationship Diagrams, part II Enrico Franconi franconi@inf.unibz.it http://www.inf.unibz.it/ franconi Faculty of Computer Science, Free University of Bozen-Bolzano (2/23)

More information

EECS 1028 M: Discrete Mathematics for Engineers

EECS 1028 M: Discrete Mathematics for Engineers EECS 1028 M: Discrete Mathematics for Engineers Suprakash Datta Office: LAS 3043 Course page: http://www.eecs.yorku.ca/course/1028 Also on Moodle S. Datta (York Univ.) EECS 1028 W 18 1 / 24 Course policies

More information

Exam 1. March 12th, CS525 - Midterm Exam Solutions

Exam 1. March 12th, CS525 - Midterm Exam Solutions Name CWID Exam 1 March 12th, 2014 CS525 - Midterm Exam s Please leave this empty! 1 2 3 4 5 Sum Things that you are not allowed to use Personal notes Textbook Printed lecture notes Phone The exam is 90

More information

CS411 Notes 3 Induction and Recursion

CS411 Notes 3 Induction and Recursion CS411 Notes 3 Induction and Recursion A. Demers 5 Feb 2001 These notes present inductive techniques for defining sets and subsets, for defining functions over sets, and for proving that a property holds

More information

Recognizing Safety and Liveness by Alpern and Schneider

Recognizing Safety and Liveness by Alpern and Schneider Recognizing Safety and Liveness by Alpern and Schneider Calvin Deutschbein 17 Jan 2017 1 Intro 1.1 Safety What is safety? Bad things do not happen For example, consider the following safe program in C:

More information

Gerwin Klein, June Andronick, Ramana Kumar S2/2016

Gerwin Klein, June Andronick, Ramana Kumar S2/2016 COMP4161: Advanced Topics in Software Verification {} Gerwin Klein, June Andronick, Ramana Kumar S2/2016 data61.csiro.au Content Intro & motivation, getting started [1] Foundations & Principles Lambda

More information

Relational completeness of query languages for annotated databases

Relational completeness of query languages for annotated databases Relational completeness of query languages for annotated databases Floris Geerts 1,2 and Jan Van den Bussche 1 1 Hasselt University/Transnational University Limburg 2 University of Edinburgh Abstract.

More information

Information Systems (Informationssysteme)

Information Systems (Informationssysteme) Information Systems (Informationssysteme) Jens Teubner, TU Dortmund jens.teubner@cs.tu-dortmund.de Summer 2015 c Jens Teubner Information Systems Summer 2015 1 Part VII Schema Normalization c Jens Teubner

More information

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska LECTURE 3 CHAPTER 1 SETS, RELATIONS, and LANGUAGES 6. Closures and Algorithms 7. Alphabets and Languages 8. Finite Representation

More information

Query answering using views

Query answering using views Query answering using views General setting: database relations R 1,...,R n. Several views V 1,...,V k are defined as results of queries over the R i s. We have a query Q over R 1,...,R n. Question: Can

More information

Information Systems for Engineers. Exercise 5. ETH Zurich, Fall Semester Hand-out Due

Information Systems for Engineers. Exercise 5. ETH Zurich, Fall Semester Hand-out Due Information Systems for Engineers Exercise 5 ETH Zurich, Fall Semester 2017 Hand-out 27.10.2017 Due 03.11.2017 Reading material: Chapter 2.4 in [1]. Lecture slides 4. 1. Given the two tables below, write

More information

Sets are one of the basic building blocks for the types of objects considered in discrete mathematics.

Sets are one of the basic building blocks for the types of objects considered in discrete mathematics. Section 2.1 Introduction Sets are one of the basic building blocks for the types of objects considered in discrete mathematics. Important for counting. Programming languages have set operations. Set theory

More information

1 Predicates and Quantifiers

1 Predicates and Quantifiers 1 Predicates and Quantifiers We have seen how to represent properties of objects. For example, B(x) may represent that x is a student at Bryn Mawr College. Here B stands for is a student at Bryn Mawr College

More information

INF1383 -Bancos de Dados

INF1383 -Bancos de Dados INF1383 -Bancos de Dados Prof. Sérgio Lifschitz DI PUC-Rio Eng. Computação, Sistemas de Informação e Ciência da Computação Projeto de BD e Formas Normais Alguns slides são baseados ou modificados dos originais

More information

GAV-sound with conjunctive queries

GAV-sound with conjunctive queries GAV-sound with conjunctive queries Source and global schema as before: source R 1 (A, B),R 2 (B,C) Global schema: T 1 (A, C), T 2 (B,C) GAV mappings become sound: T 1 {x, y, z R 1 (x,y) R 2 (y,z)} T 2

More information

I am trying to keep these lessons as close to actual class room settings as possible.

I am trying to keep these lessons as close to actual class room settings as possible. Greetings: I am trying to keep these lessons as close to actual class room settings as possible. They do not intend to replace the text book actually they will involve the text book. An advantage of a

More information

Entity-Relationship Diagrams and FOL

Entity-Relationship Diagrams and FOL Free University of Bozen-Bolzano Faculty of Computer Science http://www.inf.unibz.it/ artale Descrete Mathematics and Logic BSc course Thanks to Prof. Enrico Franconi for provoding the slides What is a

More information

A Dichotomy. in in Probabilistic Databases. Joint work with Robert Fink. for Non-Repeating Queries with Negation Queries with Negation

A Dichotomy. in in Probabilistic Databases. Joint work with Robert Fink. for Non-Repeating Queries with Negation Queries with Negation Dichotomy for Non-Repeating Queries with Negation Queries with Negation in in Probabilistic Databases Robert Dan Olteanu Fink and Dan Olteanu Joint work with Robert Fink Uncertainty in Computation Simons

More information

Movies Title Director Actor

Movies Title Director Actor Movies Title Director Actor The Trouble with Harry Hitchcock Gwenn The Trouble with Harry Hitchcock Forsythe The Trouble with Harry Hitchcock MacLaine The Trouble with Harry Hitchcock Hitchcock Cries and

More information

Advanced Counting Techniques

Advanced Counting Techniques . All rights reserved. Authorized only for instructor use in the classroom. No reproduction or further distribution permitted without the prior written consent of McGraw-Hill Education. Advanced Counting

More information

CSE 20. Lecture 4: Introduction to Boolean algebra. CSE 20: Lecture4

CSE 20. Lecture 4: Introduction to Boolean algebra. CSE 20: Lecture4 CSE 20 Lecture 4: Introduction to Boolean algebra Reminder First quiz will be on Friday (17th January) in class. It is a paper quiz. Syllabus is all that has been done till Wednesday. If you want you may

More information

CIS 375 Intro to Discrete Mathematics Exam 3 (Section M004: Blue) 6 December Points Possible

CIS 375 Intro to Discrete Mathematics Exam 3 (Section M004: Blue) 6 December Points Possible Name: CIS 375 Intro to Discrete Mathematics Exam 3 (Section M004: Blue) 6 December 2016 Question Points Possible Points Received 1 12 2 14 3 14 4 12 5 16 6 16 7 16 Total 100 Instructions: 1. This exam

More information

CS54100: Database Systems

CS54100: Database Systems CS54100: Database Systems Keys and Dependencies 18 January 2012 Prof. Chris Clifton Functional Dependencies X A = assertion about a relation R that whenever two tuples agree on all the attributes of X,

More information

Central European University Department of Economics

Central European University Department of Economics Central European University Department of Economics Fall 2018 1. Name of Course: Mathematical Methods 2. Lecturers: Imre Fekete (IF), Tamás Briglevics (TB), Dániel Molnár (DM, Teaching Assistant) 3. Number

More information

CSE 303: Database. Outline. Lecture 10. First Normal Form (1NF) First Normal Form (1NF) 10/1/2016. Chapter 3: Design Theory of Relational Database

CSE 303: Database. Outline. Lecture 10. First Normal Form (1NF) First Normal Form (1NF) 10/1/2016. Chapter 3: Design Theory of Relational Database CSE 303: Database Lecture 10 Chapter 3: Design Theory of Relational Database Outline 1st Normal Form = all tables attributes are atomic 2nd Normal Form = obsolete Boyce Codd Normal Form = will study 3rd

More information

Relational-Database Design

Relational-Database Design C H A P T E R 7 Relational-Database Design Exercises 7.2 Answer: A decomposition {R 1, R 2 } is a lossless-join decomposition if R 1 R 2 R 1 or R 1 R 2 R 2. Let R 1 =(A, B, C), R 2 =(A, D, E), and R 1

More information

Chapter 8: Relational Database Design

Chapter 8: Relational Database Design Chapter 8: Relational Database Design Database System Concepts, 6 th Ed. See www.db-book.com for conditions on re-use Chapter 8: Relational Database Design Features of Good Relational Design Atomic Domains

More information

Software Engineering using Formal Methods

Software Engineering using Formal Methods Software Engineering using Formal Methods First-Order Logic Wolfgang Ahrendt 26th September 2013 SEFM: First-Order Logic 130926 1 / 53 Install the KeY-Tool... KeY used in Friday s exercise Requires: Java

More information

Schema Refinement and Normal Forms. Chapter 19

Schema Refinement and Normal Forms. Chapter 19 Schema Refinement and Normal Forms Chapter 19 1 Review: Database Design Requirements Analysis user needs; what must the database do? Conceptual Design high level descr. (often done w/er model) Logical

More information

Chapter 7: Relational Database Design

Chapter 7: Relational Database Design Chapter 7: Relational Database Design Chapter 7: Relational Database Design! First Normal Form! Pitfalls in Relational Database Design! Functional Dependencies! Decomposition! Boyce-Codd Normal Form! Third

More information

THE AUSTRALIAN NATIONAL UNIVERSITY Second Semester COMP2600 (Formal Methods for Software Engineering)

THE AUSTRALIAN NATIONAL UNIVERSITY Second Semester COMP2600 (Formal Methods for Software Engineering) THE AUSTRALIAN NATIONAL UNIVERSITY Second Semester 2012 COMP2600 (Formal Methods for Software Engineering) Writing Period: 3 hours duration Study Period: 15 minutes duration Permitted Materials: One A4

More information

CIS 375 Intro to Discrete Mathematics Exam 3 (Section M001: Green) 6 December Points Possible

CIS 375 Intro to Discrete Mathematics Exam 3 (Section M001: Green) 6 December Points Possible Name: CIS 375 Intro to Discrete Mathematics Exam 3 (Section M001: Green) 6 December 2016 Question Points Possible Points Received 1 12 2 14 3 14 4 12 5 16 6 16 7 16 Total 100 Instructions: 1. This exam

More information

Relational algebra. Bence Molnár

Relational algebra. Bence Molnár Relational algebra Bence Molnár Introduction About relational algebra Basic properties of relational algebra: Well defined mathematical background Based on set theory Can be introduced through Armstrong

More information

Chapter 7: Relational Database Design. Chapter 7: Relational Database Design

Chapter 7: Relational Database Design. Chapter 7: Relational Database Design Chapter 7: Relational Database Design Chapter 7: Relational Database Design First Normal Form Pitfalls in Relational Database Design Functional Dependencies Decomposition Boyce-Codd Normal Form Third Normal

More information

Lecture 3: Miscellaneous Techniques

Lecture 3: Miscellaneous Techniques Lecture 3: Miscellaneous Techniques Rajat Mittal IIT Kanpur In this document, we will take a look at few diverse techniques used in combinatorics, exemplifying the fact that combinatorics is a collection

More information

Formal Semantics of SQL (and Cypher) Paolo Guagliardo

Formal Semantics of SQL (and Cypher) Paolo Guagliardo Formal Semantics of SQL (and Cypher) Paolo Guagliardo SQL Standard query language for relational databases $30B/year business Implemented in all major RDBMSs (free and commercial) First standardized in

More information

Complexity of Reasoning in Entity Relationship Models

Complexity of Reasoning in Entity Relationship Models Complexity of Reasoning in Entity Relationship Models A. Artale 1, D. Calvanese 1, R. Kontchakov 2, V. Ryzhikov 1, M. Zakharyaschev 2 1 Faculty of Computer Science Free University of Bozen-Bolzano I-39100

More information

Data Cleaning and Query Answering with Matching Dependencies and Matching Functions

Data Cleaning and Query Answering with Matching Dependencies and Matching Functions Data Cleaning and Query Answering with Matching Dependencies and Matching Functions Leopoldo Bertossi 1, Solmaz Kolahi 2, and Laks V. S. Lakshmanan 2 1 Carleton University, Ottawa, Canada. bertossi@scs.carleton.ca

More information

Linear Algebra. Instructor: Justin Ryan

Linear Algebra. Instructor: Justin Ryan Linear Algebra Instructor: Justin Ryan ryan@math.wichita.edu Department of Mathematics, Statistics, and Physics Wichita State University Wichita, Kansas Summer 2014 DRAFT 3 June 2014 Preface These lecture

More information

Theory of Computation 1 Sets and Regular Expressions

Theory of Computation 1 Sets and Regular Expressions Theory of Computation 1 Sets and Regular Expressions Frank Stephan Department of Computer Science Department of Mathematics National University of Singapore fstephan@comp.nus.edu.sg Theory of Computation

More information

Functional Dependencies and Normalization

Functional Dependencies and Normalization Functional Dependencies and Normalization There are many forms of constraints on relational database schemata other than key dependencies. Undoubtedly most important is the functional dependency. A functional

More information

Math 6/7 Honors - Expectations for Exit Exam/Testing Out

Math 6/7 Honors - Expectations for Exit Exam/Testing Out Math 6/7 Honors - Expectations for Exit Exam/Testing Out The purpose of the exit exam is to give current fifth grade students who have already mastered the Math 6/7 Honors curriculum the opportunity to

More information

Data Cleaning and Query Answering with Matching Dependencies and Matching Functions

Data Cleaning and Query Answering with Matching Dependencies and Matching Functions Data Cleaning and Query Answering with Matching Dependencies and Matching Functions Leopoldo Bertossi Carleton University Ottawa, Canada bertossi@scs.carleton.ca Solmaz Kolahi University of British Columbia

More information

1 Introduction. 2 Recap The Typed λ-calculus λ. 3 Simple Data Structures

1 Introduction. 2 Recap The Typed λ-calculus λ. 3 Simple Data Structures CS 6110 S18 Lecture 21 Products, Sums, and Other Datatypes 1 Introduction In this lecture, we add constructs to the typed λ-calculus that allow working with more complicated data structures, such as pairs,

More information

Schema Refinement: Other Dependencies and Higher Normal Forms

Schema Refinement: Other Dependencies and Higher Normal Forms Schema Refinement: Other Dependencies and Higher Normal Forms Spring 2018 School of Computer Science University of Waterloo Databases CS348 (University of Waterloo) Higher Normal Forms 1 / 14 Outline 1

More information

Introduction to Logic

Introduction to Logic Introduction to Logic L. Marizza A. Bailey June 21, 2014 The beginning of Modern Mathematics Before Euclid, there were many mathematicians that made great progress in the knowledge of numbers, algebra

More information

Problems and Solutions

Problems and Solutions 46 th Canadian Mathematical Olympiad Wednesday, April 2, 204 Problems and Solutions. Let a, a 2,..., a n be positive real numbers whose product is. Show that the sum a a 2 + + a ( + a )( + a 2 ) + a 3

More information

Design Theory for Relational Databases. Spring 2011 Instructor: Hassan Khosravi

Design Theory for Relational Databases. Spring 2011 Instructor: Hassan Khosravi Design Theory for Relational Databases Spring 2011 Instructor: Hassan Khosravi Chapter 3: Design Theory for Relational Database 3.1 Functional Dependencies 3.2 Rules About Functional Dependencies 3.3 Design

More information

Schema Refinement and Normal Forms. Why schema refinement?

Schema Refinement and Normal Forms. Why schema refinement? Schema Refinement and Normal Forms Why schema refinement? Consider relation obtained from Hourly_Emps: Hourly_Emps (sin,rating,hourly_wages,hourly_worked) Problems: Update Anomaly: Can we change the wages

More information