Discrete Maths Objective to introduce relations, show their connection to sets, and their use in databases 242-213, Semester 2, 2014-2015 5. Relations.

Slides:



Advertisements
Similar presentations
CSE 211- Discrete Structures
Advertisements

Fall 2002CMSC Discrete Structures1 You Never Escape Your… Relations.
The Engineering Design of Systems: Models and Methods
Basic Properties of Relations
5/16/20151 You Never Escape Your… Relations. 5/16/20152Relations If we want to describe a relationship between elements of two sets A and B, we can use.
Copyright © Cengage Learning. All rights reserved. CHAPTER 1 SPEAKING MATHEMATICALLY SPEAKING MATHEMATICALLY.
Ch. 8: Relations 8.1 Relations and their Properties.
CSE115/ENGR160 Discrete Mathematics 04/24/12 Ming-Hsuan Yang UC Merced 1.
Module #1 - Logic 1 Based on Rosen, Discrete Mathematics & Its Applications. Prepared by (c) , Michael P. Frank and Modified By Mingwu Chen Relations.
1 Section 7.1 Relations and their properties. 2 Binary relation A binary relation is a set of ordered pairs that expresses a relationship between elements.
Discrete Maths Objective to re-introduce basic set ideas, set operations, set identities , Semester 2, Set Basics 1.
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Sixth Edition, Mc Graw-Hill, 2007 Chapter 8: Relations Relations(8.1) n-any Relations &
Discrete Maths Objective to introduce predicate logic (also called the predicate calculus) , Semester 2, Predicate Logic 1.
Relational Model Session 6 Course Name: Database System Year : 2012.
(CSC 102) Lecture 15 Discrete Structures. Previous Lectures Summary  Procedural Versions  Properties of Sets  Empty Set Properties  Difference Properties.
8.2 n-ary Relations and Their Applications
Relation. Relations Recall the definition of the Cartesian (Cross) Product: The Cartesian Product of sets A and B, A x B, is the set A x B = { : x  A.
Discrete Maths Objective to introduce mathematical induction through examples , Semester 2, Mathematical Induction 1.
Discrete Maths Objectives to show the connection between relations and functions, and to introduce some functions with useful, special properties ,
CS Discrete Mathematical Structures Mehdi Ghayoumi MSB rm 132 Ofc hr: Thur, 9:30-11:30a Fall 2002KSU - Discrete Structures1.
April 10, 2002Applied Discrete Mathematics Week 10: Relations 1 Counting Relations Example: How many different reflexive relations can be defined on a.
DBSQL 3-1 Copyright © Genetic Computer School 2009 Chapter 3 Relational Database Model.
Ordered Sets. Relations. Equivalence Relations 1.
Chapter 2 Adapted from Silberschatz, et al. CHECK SLIDE 16.
1 Relations Rosen 6 th ed., § Relations Re lationships between elements of sets occur in many contextsRe lationships between elements of sets occur.
Lecture 14 Relations CSCI – 1900 Mathematics for Computer Science Fall 2014 Bill Pine.
Unit Unit 04 Relations IT DisiciplineITD1111 Discrete Mathematics & Statistics STDTLP1 Unit 4 Relations.
Relations and Their Properties
ICOM 6005 – Database Management Systems Design Dr. Manuel Rodríguez Martínez Electrical and Computer Engineering Department Lecture 2 – Relational Model.
Chapter 6 Relations Relationships are dealed with every day: businesses and their telephone numbers, employees and their salaries, …. Relationships can.
CSC-2259 Discrete Structures
HALVERSON – MIDWESTERN STATE UNIVERSITY CMPS 2433 Chapter 2 – Part 2 Functions & Relations.
Sets Define sets in 2 ways  Enumeration  Set comprehension (predicate on membership), e.g., {n | n  N   k  k  N  n = 10  k  0  n  50} the set.
Discrete Structures1 You Never Escape Your… Relations.
April 14, 2015Applied Discrete Mathematics Week 10: Equivalence Relations 1 Properties of Relations Definition: A relation R on a set A is called transitive.
Chapter 7: Relations Relations(7.1) Relations(7.1) n-any Relations & their Applications (7.2) n-any Relations & their Applications (7.2)
Relations and their Properties
Fall 2002CMSC Discrete Structures1 You Never Escape Your… Relations.
1 RELATIONS Learning outcomes Students are able to: a. determine the properties of relations – reflexive, symmetric, transitive, and antisymmetric b. determine.
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.
CS 103 Discrete Structures Lecture 19 Relations. Chapter 9.
Discrete Structures – CNS2300
Chapter Relations and Their Properties
1 RELATIONS Learning outcomes Students are able to: a. determine the properties of relations – reflexive, symmetric, transitive, and antisymmetric b. determine.
N-ary Relations & Their Applications. 2 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 x A 2 x … x A.
2012 년 봄학기 강원대학교 컴퓨터과학전공 문양세 이산수학 (Discrete Mathematics) n- 항 관계 (n-ary Relations)
MAT 2720 Discrete Mathematics Section 3.3 Relations
1 Discrete Structures – CNS2300 Text Discrete Mathematics and Its Applications (5 th Edition) Kenneth H. Rosen Chapter 7 Relations.
ORDERED SETS. RELATIONS COSC-1321 Discrete Structures 1.
Discrete Mathematics 3. MATRICES, RELATIONS, AND FUNCTIONS Lecture 6 Dr.-Ing. Erwin Sitompul
1 Discrete Structures – CNS2300 Text Discrete Mathematics and Its Applications Kenneth H. Rosen (5 th Edition) Chapter 1 The Foundations: Logic, Sets,
Theory of Computing Topics Formal languages automata computability and related matters Purposes To know the foundations and principles of computer science.
Theory of Computing Topics Formal languages automata computability and related matters Purposes To know the foundations and principles of computer science.
Chapter 3 The Relational Model. Objectives u Terminology of relational model. u How tables are used to represent data. u Connection between mathematical.
Unit 0 Representing Sets Of Real Numbers. Math 1301 College Algebra Unit 0 - Representing Sets of Real Numbers 2 Goals –Learn to represent sets of real.
1 The Relational Data Model David J. Stucki. Relational Model Concepts 2 Fundamental concept: the relation  The Relational Model represents an entire.
Section 9.1. Section Summary Relations and Functions Properties of Relations Reflexive Relations Symmetric and Antisymmetric Relations Transitive Relations.
Applied Discrete Mathematics Week 10: Relations
Cartesian product Given two sets A, B we define their Cartesian product is the set of all the pairs whose first element is in A and second in B. Note that.
CSE 504 Discrete Structures & Foundations of Computer Science
Taibah University College of Computer Science & Engineering Course Title: Discrete Mathematics Code: CS 103 Chapter 9 Relations Slides are adopted from.
CMSC Discrete Structures
Equivalence Relations
8.1 Relations and Their Properties
Applied Discrete Mathematics Week 6: Relations/Digraphs
Relations and their Properties
Discrete Math (2) Haiming Chen Associate Professor, PhD
Lecture Sets 2.2 Set Operations.
Agenda Lecture Content: Relations (Relasi)
Presentation transcript:

Discrete Maths Objective to introduce relations, show their connection to sets, and their use in databases , Semester 2, Relations 1

Overview 1. Defining a Relation 2. Relations using One Set 3. Properties of a Relation reflexive, symmetric, transitive 4. Composition of Relations 5. N-ary Relations 6. Databases and Relations 7. More Information 2

1. Defining a Relation A relation connects two (or more) sets. Two new ideas: the Cartesian Product (A  B) of sets ordered pairs 3

Cartesian Product Example A = {Smith, Johnson} B = {Calc, Math, History, Programming} 4 Smith Johnson Art Math History Programming A B  the Cartesian Product creates all the possible links from elements in set A to set B

A Set of Ordered Pairs We can write these links as a set of ordered pairs, one pair for each link: AxB = { (Smith, Art), (Smith,Math), (Smith,History),..., (Johnson,History), (Johnston,Programming) } The ordering of a pair matters: first an element from A, which is linked to an element from B. A pair is sometimes called a 2-tuple. 5

Relations A relation R is defined by a subset of the ordered pairs in AxB. For example one possible relation is: 6 Smith Johnson Art Math History Programming A B R

R can be written as a set of ordered pairs: R = { (Smith,Art), (Smith,Math),... (Johnson, History), (Johnston, Programming) } R  A x B We can also write each link as a relation (or predicate): (Smith R Art)is true or R(Smith, Art)istrue (Johnston R Art)is false or R(Johnston,Art)isfalse 7 yes, there is a link between relations and predicate logic yes, there is a link between relations and predicate logic

2. Relations Using One Set It's possible to use the same set in a relation e.g. R  A x A For example, integer relations are  Z x Z 8 0 Z R : 1 2 : 0 Z : 1 2 :

A relation involving numerical sets can often be summarized using set notation. For example: R = {(a,b) | a  Z, b  Z, b = a+1 } or without the set types: R = {(a,b) |b = a+1 } 9

A relation R involving a set S may have special properties: If (x R x) is true, then R is reflexive. If (x R y) is true when (y R x) is true, then R is symmetric. If (x R z) is true when (x R y) and (y R z) are true, then R is transitive Properties of a Relation

Reflexive Examples Are the following relations on {1, 2, 3, 4} reflexive? 11 R = {(1, 1), (1, 2), (2, 3), (3, 3), (4, 4)} No. R = {(1, 1), (2, 2), (2, 3), (3, 3), (4, 4)} Yes. R = {(1, 1), (2, 2), (3, 3)} No. 1 2 S S 3 4 R ??

Transitivity Examples Are the following relations on {1, 2, 3, 4} transitive? 12 R = {(1, 1), (1, 2), (2, 2), (2, 1), (3, 3)}Yes. R = {(1, 3), (3, 2), (2, 1)}No. R = {(2, 4), (4, 3), (2, 3), (4, 1)} No. 1 2 S S 3 4 R ??

4. Composition of Relations Let R be a relation from a set A to a set B and S a relation from B to a set C. The composite of R and S is written as S  R read this as "do R then do S" 13 a 2 A d 4 s t B 3 4 R : : 9 0 C h u : S this strange ordering is to do with the connection between relations and functions (see the next part) this strange ordering is to do with the connection between relations and functions (see the next part)

Example 1 Let R and S be relations on Z + = {1, 2, 3, …} R = {(a, b) | b = 2*a} S = {(a, b) | b = a-1} Z+Z+ 4 5 R 3 S 6 : 1 2 Z+Z : 1 2 Z+Z :

We can write S  R in terms of the ordered pairs of "start" and "finish" elements: S  R = {(1,1), (2,3), (3,5), (4,7),... } remember that  means "do R and then do S" We can also summarise the composite using set notation: S  R = {(a,b) | b = (2*a) – 1 } 15 this combines the maths of set R and S this combines the maths of set R and S

Example 2 Let R and S be relations on A = {1, 2, 3, 4} R = {(a, b) | b = 5 - a} S = {(a, b) | b > a} this means that an 'a' can be linked to all 'b's which are bigger 16 A A 3 4 R A S

As a set of ordered pairs: S  R = { (2,4), (3,3), (3,4), (4,2), (4,3), (4,4) } only "start" and "finish" pairs are included Using set notation: S ° R = {(a,b) | b > 5 – a} or S ° R = {(a,b) | a + b > 5} 17 this combines the maths of set R and S this combines the maths of set R and S

5. N-ary Relations The Cartesian Product can involve any number of sets. We write it as A1 x A2 x … x An. The sets A1, A2, …, An are called the domains of the relation, and n is called its degree. 18 a 2 A1 4 s A A3 h u for this example, degree == 3 for this example, degree == 3

An n-ary relation R uses a subset of the links in an n-ary Cartesian Product. e.g. 19 a 2 A1 4 s A A3 h u

6. Databases and Relations A database can be defined as an n-ary relation this is known as the relational data model A 'database' for students: R = { (Ackermann, 231, CoE, 3.88), (Adams, 888, Physics, 3.45), (Chou, 102, CoE, 3.79), (Goodfriend, 453, Math, 3.45), (Rao, 678, Math, 3.90), (Stevens, 786, Math, 2.99) } Each tuple is also called a record. 20 called a 4-tuple (because there are 4 values) called a 4-tuple (because there are 4 values)

Each tuple (record) is made up of values from sets (also called domains or fields). e.g. each R tuple contains values from the fields Name, ID, Dept, and GPA The database R is an n-ary relation: 21 Name ID 231 : Dept Chou :::: Ackerman Adams Physics Chem CoE Math GPA 888 : : : 3.45 : : : fields (domains) primary key = 1 tuple (or record)

Primary Key A field is called a primary key if the relation's tuples are uniquely defined by that key's values no two records can have the same primary key value e.g. ID is the primary key in the R relation. 22

7. More Information Discrete Mathematics and its Applications Kenneth H. Rosen McGraw Hill, 2007, 7th edition chapter 9, sections 9.1 –