DATABASE DESIGN I - 1DL300

Similar documents
DATABASTEKNIK - 1DL116

BİL 354 Veritabanı Sistemleri. Relational Algebra (İlişkisel Cebir)

INF1383 -Bancos de Dados

RELATIONAL MODEL.

Learning Goals. Relational Query Languages. Formal Relational Query Languages. Formal Query Languages: Relational Algebra and Relational Calculus

Coalgebra, Lecture 15: Equations for Deterministic Automata

Intermediate Math Circles Wednesday, November 14, 2018 Finite Automata II. Nickolas Rollick a b b. a b 4

Bases for Vector Spaces

Boolean Algebra. Boolean Algebra

Chapter 2 Finite Automata

Overview of Today s Lecture:

Chapter 3 MATRIX. In this chapter: 3.1 MATRIX NOTATION AND TERMINOLOGY

CS 373, Spring Solutions to Mock midterm 1 (Based on first midterm in CS 273, Fall 2008.)

Lecture 3: Equivalence Relations

NFAs and Regular Expressions. NFA-ε, continued. Recall. Last class: Today: Fun:

Matrix Algebra. Matrix Addition, Scalar Multiplication and Transposition. Linear Algebra I 24

CS12N: The Coming Revolution in Computer Architecture Laboratory 2 Preparation

The area under the graph of f and above the x-axis between a and b is denoted by. f(x) dx. π O

DEFINITION The inner product of two functions f 1 and f 2 on an interval [a, b] is the number. ( f 1, f 2 ) b DEFINITION 11.1.

1B40 Practical Skills

CSE : Exam 3-ANSWERS, Spring 2011 Time: 50 minutes

Designing Information Devices and Systems I Discussion 8B

378 Relations Solutions for Chapter 16. Section 16.1 Exercises. 3. Let A = {0,1,2,3,4,5}. Write out the relation R that expresses on A.

Jim Lambers MAT 169 Fall Semester Lecture 4 Notes

Riemann Sums and Riemann Integrals

Quadratic Forms. Quadratic Forms

Finite Automata-cont d

Lecture 08: Feb. 08, 2019

How do we solve these things, especially when they get complicated? How do we know when a system has a solution, and when is it unique?

More on automata. Michael George. March 24 April 7, 2014

IST 4 Information and Logic

CHAPTER 1 Regular Languages. Contents

Introduction to Electrical & Electronic Engineering ENGG1203

Riemann Sums and Riemann Integrals

Boolean algebra.

CS 310 (sec 20) - Winter Final Exam (solutions) SOLUTIONS

Linear Inequalities. Work Sheet 1

Anatomy of a Deterministic Finite Automaton. Deterministic Finite Automata. A machine so simple that you can understand it in less than one minute

Homework 3 Solutions

Reasoning and programming. Lecture 5: Invariants and Logic. Boolean expressions. Reasoning. Examples

Geometric Sequences. Geometric Sequence a sequence whose consecutive terms have a common ratio.

Lecture Solution of a System of Linear Equation

Minimal DFA. minimal DFA for L starting from any other

CM10196 Topic 4: Functions and Relations

CS 330 Formal Methods and Models

Vectors , (0,0). 5. A vector is commonly denoted by putting an arrow above its symbol, as in the picture above. Here are some 3-dimensional vectors:

Revision Sheet. (a) Give a regular expression for each of the following languages:

Things to Memorize: A Partial List. January 27, 2017

Recitation 3: More Applications of the Derivative

Ehrenfeucht-Fraïssé Games: Applications and Complexity. Department of Mathematics and Computer Science University of Udine, Italy ESSLLI 2010 CPH

AUTOMATA AND LANGUAGES. Definition 1.5: Finite Automaton

UNIT 1 FUNCTIONS AND THEIR INVERSES Lesson 1.4: Logarithmic Functions as Inverses Instruction

Before we can begin Ch. 3 on Radicals, we need to be familiar with perfect squares, cubes, etc. Try and do as many as you can without a calculator!!!

Finite-State Automata: Recap

CSCI 340: Computational Models. Kleene s Theorem. Department of Computer Science

Formal Languages and Automata

4 VECTORS. 4.0 Introduction. Objectives. Activity 1

Continuous Random Variables

Non-deterministic Finite Automata

Parse trees, ambiguity, and Chomsky normal form

AT100 - Introductory Algebra. Section 2.7: Inequalities. x a. x a. x < a

Lecture 9: LTL and Büchi Automata

Analytically, vectors will be represented by lowercase bold-face Latin letters, e.g. a, r, q.

KNOWLEDGE-BASED AGENTS INFERENCE

Farey Fractions. Rickard Fernström. U.U.D.M. Project Report 2017:24. Department of Mathematics Uppsala University

IST 4 Information and Logic

p-adic Egyptian Fractions

DIRECT CURRENT CIRCUITS

The practical version

a,b a 1 a 2 a 3 a,b 1 a,b a,b 2 3 a,b a,b a 2 a,b CS Determinisitic Finite Automata 1

Bridging the gap: GCSE AS Level

DA 3: The Mean Value Theorem

CS 330 Formal Methods and Models Dana Richards, George Mason University, Spring 2016 Quiz Solutions

Resources. Introduction: Binding. Resource Types. Resource Sharing. The type of a resource denotes its ability to perform different operations

Designing Information Devices and Systems I Spring 2018 Homework 7

Convert the NFA into DFA

Symbolic enumeration methods for unlabelled structures

Infinite Geometric Series

Matrices. Elementary Matrix Theory. Definition of a Matrix. Matrix Elements:

Combinational Logic. Precedence. Quick Quiz 25/9/12. Schematics à Boolean Expression. 3 Representations of Logic Functions. Dr. Hayden So.

CHAPTER 1 PROGRAM OF MATRICES

Closure Properties of Regular Languages

Simplifying Algebra. Simplifying Algebra. Curriculum Ready.

Theory of Computation Regular Languages. (NTU EE) Regular Languages Fall / 38

September 13 Homework Solutions

Harvard University Computer Science 121 Midterm October 23, 2012

Properties of Integrals, Indefinite Integrals. Goals: Definition of the Definite Integral Integral Calculations using Antiderivatives

Fachgebiet Rechnersysteme1. 1. Boolean Algebra. 1. Boolean Algebra. Verification Technology. Content. 1.1 Boolean algebra basics (recap)

CMPSCI 250: Introduction to Computation. Lecture #31: What DFA s Can and Can t Do David Mix Barrington 9 April 2014

CS375: Logic and Theory of Computing

Riemann Integrals and the Fundamental Theorem of Calculus

Chapter 1: Fundamentals

AP Calculus AB Summer Packet

Section 6.1 INTRO to LAPLACE TRANSFORMS

CS311 Computational Structures Regular Languages and Regular Grammars. Lecture 6

Chapter Five: Nondeterministic Finite Automata. Formal Language, chapter 5, slide 1

5.2 Exponent Properties Involving Quotients

W. We shall do so one by one, starting with I 1, and we shall do it greedily, trying

Thomas Whitham Sixth Form

Bernoulli Numbers Jeff Morton

Transcription:

DATABASE DESIGN I - DL300 Fll 00 An introductory course on dtse systems http://www.it.uu.se/edu/course/homepge/dstekn/ht0/ Mnivskn Sesn Uppsl Dtse Lortory Deprtment of Informtion Technology, Uppsl University, Uppsl, Sweden 00--

Introduction to Reltionl Alger Elmsri/Nvthe ch 6 Pdron-McCrthy/Risch ch 0 Mnivskn Sesn Deprtment of Informtion Technology Uppsl University, Uppsl, Sweden 00--

Query lnguges Lnguges where users cn express wht informtion to retrieve from the dtse. Ctegories of query lnguges: Procedurl Non-procedurl (declrtive) Forml ( pure ) lnguges: Reltionl lger Reltionl clculus Tuple-reltionl clculus Domin-reltionl clculus Forml lnguges form underlying sis of query lnguges tht people use. 00-- 3

Reltionl lger Reltionl lger is procedurl lnguge Opertions in reltionl lger tkes two or more reltions s rguments nd return new reltion. Reltionl lgeric opertions: Opertions from set theory: Union, Intersection, Difference, Crtesin product Opertions specificlly introduced for the reltionl dt model: Select, Project, Join It hve een shown tht the select, project, union, difference, nd Crtesin product opertions form complete set. Tht is ny other reltionl lger opertion cn e expressed in these. 00-- 4

Opertions from set theory Reltions re required to e union comptile to e le to tke prt in the union, intersection nd difference opertions. Two reltions R nd R is sid to e union-comptile if: R D D... D n nd R D D... D n i.e. if they hve the sme degree nd the sme domins. 00--

Union opertion The union of two union-comptile reltions R nd S is the set of ll tuples tht either occur in R, S, or in oth. Nottion: R S Defined s: R S = {t t R or t S} For exmple: R S A B U A B 3 = A B 3 00-- 6

Difference opertion The difference etween two union-comptile sets R nd S is the set of ll tuples tht occur in R ut not in S. Nottion: R S Defined s: R S = {t t R nd t S} For exmple: R S A B A B 3 = A B 00-- 7

Intersection The intersection of two union-comptile sets R nd S, is the set of ll tuples tht occur in oth R nd S. Nottion: R S Defined s: R S = {t t R nd t S} For exmple: R S A B A B 3 = A B 00-- 8

Crtesin product Let R nd S e reltions with k nd k rities resp. The Crtesin product of R nd S is the set of ll possile k +k tuples where the first k components constitute tuple in R nd the lst k components tuple in S. Nottion: R S Defined s: R S = {t q t R nd q S} Assume tht ttriutes of r(r) nd s(s) re disjoint. (i.e. R ) S = ). If ttriutes of r(r) nd s(s) re not disjoint, then renming must e used. X = 00-- 9

Crtesin product exmple A B C D c 6 = A B C D c 6 00-- 0 c c c 6

Selection opertion The selection opertor, σ, selects specific set of tuples from reltion ccording to selection condition (or selection predicte) P. Nottion: σ P (R) Defined s: σ P (R) = {t t R nd P(t) } (i.e. the set of tuples t in R tht fulfills the condition P) Where P is logicl expression (*) consisting of terms connected y: (nd), (or), (not) nd ech term is one of: <ttriute> op <ttriute> or <constnt>, where op is one of: =,, >,, <, Exmple: σ SALARY>30000 (EMPLOYEE) (*) formul in propositionl clculus 00--

Selection exmple = A B C D 4 7 7 3 9 R 00-- 4 9 σ A=B D > (R) = A B C D 4 7 9

Projection opertion The projection opertor, Π, picks out (or projects) listed columns from reltion nd cretes new reltion consisting of these columns. Nottion: Π A,A,...,Ak (R), where A, A R is reltion nme. The result is new reltion of k columns. re ttriute nmes nd Duplicte rows removed from result, since reltions re sets. Exmple: Π LNAME,FNAME,SALARY (EMPLOYEE) 00-- 3

Projection exmple = A B 3 4 C R 00-- 4 4 Π A,C (R) = A C = A C

Join opertor The join opertor, (lmost, correct ), cretes new reltion y joining relted tuples from two reltions. Nottion: R C S C is the join condition which hs the form A r θ A s, where θ is one of {=, <, >,,, }. Severl terms cn e connected s C C...C k. A join opertion with this kind of generl join condition is clled Thet join. 00--

Exmple Thet join θ A F = A B C D 3 A B C 3 D E 3 F 4 R θ A F S E 3 F 4 R S 00-- 6 6 9 7 7 3 3 8 8 7 7 7 7 6 9 7 7 8 8 7 7 3 8 9 3 8 8 8 9 9 9

Equijoin The sme s join ut it is required tht ttriute A r nd ttriute A s should hve the sme vlue. Nottion: R C S C is the join condition which hs the form A r = A s. Severl terms cn e connected s C C...C k. 00-- 7

Exmple Equijoin R S R B=C S A B C D E B=C = A B d 4 4 d 9 d e e e C D d 4 4 d E e e 00-- 8

Nturl join Nturl join is equivlent with the ppliction of join to R nd S with the equlity condition A r = A s (i.e. n equijoin) nd then removing the redundnt column A s in the result. Nottion: R * Ar,As S A r,a s re ttriute pirs tht should fulfill the join condition which hs the form A r = A s. Severl terms cn e connected s C C...C k. 00-- 9

Exmple Nturl join R S R B=C S A B C D E B=C = A B d 4 4 d 9 d e e e D d 4 d E e e 00-- 0

Composition of opertions Expressions cn e uilt y composing multiple opertions Exmple: σ A=C (R S) A B C D = A B C D R S = 00-- σ A=C (R S) = c 6 c c 6 6 A B C D 6

Assignment opertion The ssignment opertion ( ) mkes it possile to ssign the result of n expression to temporry reltion vrile. Exmple: temp σ dno = (EMPLOYEE) result fnme,lnme,slry (temp) The result to the right of the is ssigned to the reltion vrile on the left of the. The vrile my e used in susequent expressions. 00--

Renming reltions nd ttriute The ssignment opertion cn lso e used to renme reltions nd ttriutes. Exmple: NEWEMP σ dno = (EMPLOYEE) R(FIRSTNAME,LASTNAME,SALARY) fnme,lnme,slry (NEWEMP) 00-- 3

Division opertion Suited to queries tht include the phrse for ll. Let R nd S e reltions on schems R nd S respectively, where R = (A,...,A m,b,...,b n ) S = (B,...,B n ) The result of R S is reltion on the schem R - S = (A,...,A m ) R S = {t t Π R-S (R) u S tu R} 00-- 4

Exmple of Division opertion = A e A B 3 B R S R S 00-- c d d d d e e 3 3 4 6

Additionl reltionl opertions Outer join nd outer union (presented together with SQL) Aggregtion opertions (presented together with SQL) Updte opertions (presented together with SQL) (not prt of pure query lnguge) 00-- 6

Aggregtion opertions Presented together with SQL lter Exmples of ggregtion opertions vg min mx sum count 00-- 7

Updte opertions Presented together with SQL lter Opertions for dtse updtes re normlly prt of the DML insert (of new tuples) updte (of ttriute vlues) delete (of tuples) Cn e expressed y mens of the ssignment opertor 00-- 8

Outer join/union opertion Extensions of the join/union opertions tht void loss of informtion. Computes the join/union nd then dds tuples from one reltion tht do not mtch tuples in the other reltion to the result of the join. Fills out with null vlues: null signifies tht the vlue is unknown or does not exist. All comprisons involving null re flse y definition. 00-- 9

Exmple Outer join Reltion lon rnch-nme Downtown Redwood Perryridge lon-numer -70 L-30 L-60 mount 3000 4000 700 Reltion orrower customer-nme Jones Smith Hyes lon-numer -70 L-30 L- 00-- 30

Exmple Outer join cont... lon orrower (nturl join) rnch-nme lon-numer mount customer-nme Downtown Redwood -70 L-30 3000 4000 Jones Smith lon left orrower (left outer join) rnch-nme lon-numer mount customer-nme lon-numer Downtown Redwood Perryridge -70 L-30 L-60 3000 4000 700 Jones Smith null -70 L-30 null 00-- 3

Exmple Outer join cont... lon right orrower (nturl right outer join) rnch-nme Downtown Redwood null lon-numer L-70 L-30 L- mount 3000 4000 null lon full orrower (nturl full outer join) customer-nme Jones Smith Hyes rnch-nme lon-numer mount customer-nme Downtown Redwood Perryridge null L-70 L-30 L-60 L- 3000 4000 700 null Jones Smith null Hyes 00-- 3