CSE 311 Foundations of Computing I Lecture 22 Relations, Database Autumn 2012 CSE 311 1 TexPoint fonts used in EMF. Read the TexPoint manual before you.

Slides:



Advertisements
Similar presentations
Min-Max Relations, Hall’s Theorem, and Matching-Algorithms Graphs & Algorithms Lecture 5 TexPoint fonts used in EMF. Read the TexPoint manual before you.
Advertisements

CSE 311 Foundations of Computing I
Lecture 17 Path Algebra Matrix multiplication of adjacency matrices of directed graphs give important information about the graphs. Manipulating these.
8.4 Closures of Relations. Intro Consider the following example (telephone line, bus route,…) abc d Is R, defined above on the set A={a, b, c, d}, transitive?
My Academic Genealogy. Kevin Shang UC Irvine 2002 Jeannette Song Columbia Univ Paul Zipkin Yale Univ
The double-dimer model and skew Young diagrams Richard W. Kenyon David B. Wilson Brown University Microsoft Research TexPoint fonts used in EMF. Read the.
CS2210(22C:19) Discrete Structures Relations Spring 2015 Sukumar Ghosh.
CSE115/ENGR160 Discrete Mathematics 04/24/12 Ming-Hsuan Yang UC Merced 1.
Functional Dependencies Definition: If two tuples agree on the attributes A, A, … A 12n then they must also agree on the attributes B, B, … B 12m Formally:
CSE 421 Algorithms Richard Anderson Lecture 10 Minimum Spanning Trees.
CSE 311 Foundations of Computing I Lecture 19 Relations Autumn 2011 CSE 3111.
Lecture 11 CSE 331 Sep 25, Homeworks Please hand in your HW 2 now HW 3 and graded HW 1 at the end of class.
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Sixth Edition, Mc Graw-Hill, 2007 Chapter 8: Relations Relations(8.1) n-any Relations &
Planar Graphs: Euler's Formula and Coloring Graphs & Algorithms Lecture 7 TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.:
Module #18: Relations, part I
Lecture 14 Relations CSCI – 1900 Mathematics for Computer Science Fall 2014 Bill Pine.
CSE 311 Foundations of Computing I Lecture 23 Finite State Machines Autumn 2012 CSE 3111.
Relations and Their Properties
CSE 311 Foundations of Computing I Lecture 21 Finite State Machines Autumn 2011 CSE 3111.
CSE 311 Foundations of Computing I Lecture 21 Finite State Machines Spring
CSC-2259 Discrete Structures
1 Closures of Relations: Transitive Closure and Partitions Sections 8.4 and 8.5.
Chapter 7: Relations Relations(7.1) Relations(7.1) n-any Relations & their Applications (7.2) n-any Relations & their Applications (7.2)
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Relations.
Discrete Mathematics Relation.
CSE 311: Foundations of Computing Fall 2014 Lecture 20: Relations and Directed Graphs.
Relations and their Properties
1 Problem of the Day: Describe using set descriptor notation the complements of (a) { , a, aa, aaa} over ∑ = {a} (b) { , a, aa, aaa} over ∑ = {a,b} (c)
Relations. Important Definitions We covered all of these definitions on the board on Monday, November 7 th. Definition 1 Definition 2 Definition 3 Definition.
Lecture on Relations 1Developed by CSE Dept., CIST Bhopal.
DISCRETE COMPUTATIONAL STRUCTURES
CSE 311 Foundations of Computing I Lecture 20 Relations, Graphs, Finite State Machines Autumn 2011 CSE 3111 TexPoint fonts used in EMF. Read the TexPoint.
Problem Statement How do we represent relationship between two related elements ?
Chapter Relations and Their Properties
Jost Burgi ( Jost Burgi ( Geronimo Cardano ( )
CSE 421 Algorithms Richard Anderson Winter 2009 Lecture 5.
8.4 Closures of Relations Definition: The closure of a relation R with respect to property P is the relation obtained by adding the minimum number of.
CSE 311 Foundations of Computing I Lecture 24 FSM Limits, Pattern Matching Autumn 2011 CSE 3111.
Binary Relations Definition: A binary relation R from a set A to a set B is a subset R ⊆ A × B. Example: Let A = { 0, 1,2 } and B = {a,b} {( 0, a), (
CSE 421 Algorithms Richard Anderson Autumn 2015 Lecture 5.
1 Closures of Relations Based on Aaron Bloomfield Modified by Longin Jan Latecki Rosen, Section 8.4.
Lecture 7: Relations Dr Andrew Purkiss-Trew Cancer Research UK Mathematics for Computing.
Learn about relations and their basic properties
Aaron Bloomfield CS 202 Rosen, section 7.4
Richard Anderson Lecture 26 NP-Completeness
CSE 504 Discrete Structures & Foundations of Computer Science
CSE 311 Foundations of Computing I
Discrete Structures – CNS2300
Discrete Structures for Computer Science
CSE 311 Foundations of Computing I
CS2210 Discrete Structures Relations
CSE 311 Foundations of Computing I
Relations: representation and closures
CSE 321 Discrete Structures
CSE 321 Discrete Structures
CSE 321 Discrete Structures
Richard Anderson Autumn 2016 Lecture 7
CSE 321 Discrete Structures
CSE 311: Foundations of Computing
CSE 321 Discrete Structures
Discrete Math (2) Haiming Chen Associate Professor, PhD
CSE 311 Foundations of Computing I
CSE 321 Discrete Structures
Richard Anderson Lecture 5 Graph Theory
Closures of Relations Epp, section 10.1,10.2 CS 202.
CSE 311 Foundations of Computing I
CSE 311 Foundations of Computing I
CSE 311 Foundations of Computing I
Chapter 8 (Part 2): Relations
Autumn 2019 Lecture 11 Minimum Spanning Trees (Part II)
Presentation transcript:

CSE 311 Foundations of Computing I Lecture 22 Relations, Database Autumn 2012 CSE TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.: A A A A AA

Announcements Reading assignments – 7 th Edition, Sections 9.3 and 13.3 – 6 th Edition, Section 8.3 and 12.3 – 5 th Edition, Section 7.3 and 11.3 Autumn 2012CSE 311 2

Lecture highlights Autumn 2012CSE Let A and B be sets, A binary relation from A to B is a subset of A  B S  R = {(a, c) |  b such that (a,b)  R and (b,c)  S} R 1 = R; R n+1 = R n  R Matrix and graph representation of relations

Paths in relations Autumn 2012CSE Let R be a relation on a set A. There is a path of length n from a to b if and only if (a,b)  R n

Connectivity relation Autumn 2012CSE Let R be a relation on a set A. The connectivity relation R* consists of the pairs (a,b) such that there is a path from a to b in R.

Transitive-Reflexive Closure Autumn 2012CSE Add the minimum possible number of edges to make the relation transitive and reflexive The transitive-reflexive closure of a relation R is the connectivity relation R*

How is Anderson related to Bernoulli? Autumn 2012CSE Copernicus Anderson

How is Anderson related to Bernoulli? Autumn 2012CSE Copernicus Suciu

Autumn 2012CSE

BauerCaratheodoryMinkowski Klein LipschitzDirichletFourier LagrangeEuler Johann BernoulliJacob BernoulliLeibniz RheticusCopernicus Anderson Weigel Mayr

SuciuTannenMeyerFischerRogers ChurchVeblenMooreH.A.NewtonChasles PoissonLagrangeEulerJohann BernoulliJacob Bernoulli

Nicolaus Copernicus Georg Rheticus Moritz Steinmetz Christoph Meurer Philipp Muller Erhard Weigel Gottfried Leibniz Noclas Malebranache Jacob Bernoulli Johann Bernoulli Leonhard Euler Joseph Lagrange Jean-Baptiste Fourier Gustav Dirichlet Rudolf Lipschitz Felix Klein C. L. Ferdinand Lindemann Herman Minkowski Constantin Caratheodory Georg Aumann Friedrich Bauer Manfred Paul Ernst Mayr Richard Anderson Autumn 2012CSE Nicolaus Copernicus Georg Rheticus Moritz Steinmetz Christoph Meurer Philipp Muller Erhard Weigel Gottfried Leibniz Noclas Malebranache Jacob Bernoulli Johann Bernoulli Leonhard Euler Joseph Lagrange Michel Chasles H. A. (Hubert Anson) Newton E. H. (Eliakim Hastings) Moore Oswald Veblen Alonzo Church Hartley Rogers, Jr. Patrick Carl Fischer Albert Ronald da Silva Meyer Val Tannen Dan Suciu

n-ary relations Let A 1, A 2, …, A n be sets. An n-ary relation on these sets is a subset of A 1  A 2 ...  A n. Autumn 2012CSE 31113

Relational databases Student_NameID_NumberOfficeGPA Knuth Von Neuman Russell Einstein Newton Karp Bernoulli Autumn 2012CSE STUDENT

Relational databases Student_NameID_NumberOfficeGPACourse Knuth CSE311 Knuth CSE351 Von Neuman CSE311 Russell CSE312 Russell CSE344 Russell CSE351 Newton CSE312 Karp CSE311 Karp CSE312 Karp CSE344 Karp CSE351 Bernoulli CSE351 What wrong? STUDENT

Relational databases ID_NumberCourse CSE CSE CSE CSE CSE CSE CSE CSE CSE CSE CSE CSE351 Better Student_NameID_NumberOfficeGPA Knuth Von Neuman Russell Einstein Newton Karp Bernoulli STUDENT TAKES

Database Operations: Projection Autumn 2012CSE Find all offices: Π Office (STUDENT) Office Find offices and GPAs: Π Office,GPA (STUDENT) OfficeGPA

Database Operations: Selection Autumn 2012CSE Find students with GPA > 3.9 : σ GPA>3.9 (STUDENT) Student_NameID_NumberOfficeGPA Knuth Karp Retrieve the name and GPA for students with GPA > 3.9 : Π Student_Name,GPA (σ GPA>3.9 (STUDENT)) Student_NameGPA Knuth4.00 Karp3.98

Database Operations: Natural Join Student_NameID_NumberOfficeGPACourse Knuth CSE311 Knuth CSE351 Von Neuman CSE311 Russell CSE312 Russell CSE344 Russell CSE351 Newton CSE312 Karp CSE311 Karp CSE312 Karp CSE344 Karp CSE351 Bernoulli CSE351 Student ⋈ Takes

Disambiguating Attribute Names Names of students who share an office with Einstein: Π STUDENT1.Student_Name (STUDENT ⋈ STUDENT1.Office = STUDENT2.Office (σ Student_Name=‘Einstein’ (STUDENT))) Student_NameID_NumberOfficeGPA Knuth Von Neuman Russell Einstein Newton Karp Bernoulli STUDENT Student_Name Knuth Russell Einstein Karp Bernoulli Student_NameID_NumberOfficeGPA Knuth Von Neuman Russell Einstein Newton Karp Bernoulli STUDENT Answer:

Database Operations: Relational Algebra Find the names and GPAs of all students who take 311 Find the names of all students who take at least two courses

Database Operations: SQL Find the names and GPAs of all students who take 311 SELECT DISTINCT Student_name, GPA FROM STUDENT Natural Join TAKES WHERE Course = ‘CSE311’ Find the names of all students who take at least two courses SELECT DISTINCT Student_name, GPA FROM STUDENT s, TAKES t1, TAKES t2 WHERE s.ID_number = t1.ID_number and s.ID_number = t2.ID_number and t1.course != t2.course

Relational Databases: Keys An attribute is a key if all its values in the database are always distinct Autumn 2012CSE Which attribute is the key? Why is Student_Name not a key? Student_NameID_NumberOfficeGPA Knuth Von Neuman Russell Einstein Newton Karp Bernoulli

Relational Databases: Relationships Autumn 2012CSE WORKS_ON is a relationship between students and project Student_NameID_NumberOffice Knuth Von Neuman Russell Einstein Newton Karp Bernoulli PRJ_IDProject_NameDue_date P331“Flying cyphers”11/2012 P004“Virtual induction”12/2012 P901“Binary bots”12/2012 STUDENT PROJECT ID_NumberPRJ_ID P P P901 Who works on what?

Types of Relationships in Relational Databases one-one: many-one many-many abcdabcd abcdabcd abcdabcd Autumn 2012CSE What type is WORKS_ON? ID_NumberPRJ_ID P P P901