0% found this document useful (0 votes)
20 views24 pages

Lecture 7 Relation-2

The document defines binary relations, providing examples and applications, particularly in relational databases. It explains concepts such as inverse relations, relations on a set, and properties of relations including reflexivity, symmetry, antisymmetry, and transitivity. Additionally, it illustrates how to represent relations graphically and in tables.

Uploaded by

karim22214121074
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views24 pages

Lecture 7 Relation-2

The document defines binary relations, providing examples and applications, particularly in relational databases. It explains concepts such as inverse relations, relations on a set, and properties of relations including reflexivity, symmetry, antisymmetry, and transitivity. Additionally, it illustrates how to represent relations graphically and in tables.

Uploaded by

karim22214121074
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 24

1

2
3
4
5
6
7
8
Relation
Definition
a binary relation from A to B is a set R of ordered pairs where the first
element of each ordered pair comes from A and the second element
comes from B.
We use the notation a R b to denote that (a, b) ∈ R and a R b to denote
that (a, b) R. Moreover, when (a, b)belongs to R, a is said to be related
to b by R.
Let A and B be sets. A binary relation from A to B is a subset of A×B.

Application : Relational database model is based on the concept of relation.


Relation : Example
• Let A be the students in the Dept. of CSE
• A = {Rony, Putul, Shammi, Dipti}
• Let B be the courses the department offers
• B = {CSE 201, CSE 202, CSE 203}

• We specify relation R  A  B as the set that lists all students a 


A enrolled in class b  B

• R = {(Rony, CSE 201), (Putul, CSE 202), (Shammi, CSE 203),


(Rony, CSE 202), (Dipti, CSE 203)}
Relation : More
More relation Example
examples
• Another relation example:
• Let A be the Districts in the Bangladesh
• Let B be the Division in the Bangladesh
• We define R to mean a is a district in division b
• Thus, the following are in our relation:
• (Nator, Rahjshahi)
• (Jayputhat, Rajshahi)
• (Tongi, Dhaka)
• (Bagerhat, Khulna)
• etc…
• Most relations we will see deal with ordered pairs of integers
Representing relations
We can represent We can represent
relations graphically relations in a table

Nadira
CSE 201 CSE 202 CSE 203
CSE 201
Sojib Nadira 1 0 0
CSE 202 0 1 1
Sojib
Sakir
Sakira 0 0 0
CSE 203
Asma Asma 0 1 1

Not valid functions!


Inverse Relation
Definition
Let R be any relation from a set A to a set B. The inverse of R, denoted
by R-1, is the relation from B to A, which consists of those ordered pairs
which, when reversed, belong to R; that is,
R-1 = {(b, a)|(a, b)∈R}

• For example, let A={1,2,3} and B={x, y, z}. Then the inverse of R={(1, y), (1, z), (3,y)}
• Then the inverse relation is R-1 = {(y,1), (z,1), (y,3)
Relations on a set
Definition

• A relation on the set A is a relation from A to A


• In other words, the domain and co-domain are the same set
Relations on a Set : Example
• Let A be the set { 1, 2, 3, 4 }
• Which ordered pairs are in the relation
R = { (a,b) | a divides b }
• R = {(1,1), (1,2), (1,3), (1,4), (2,2), (2,4), (3,3), (4,4)}

1 1 R 1 2 3 4
1 X X X X
2 2
2 X X
3 3 3 X
4 X
4 4
Directed Graphs of Relations on Sets
• Consider the relation R on the set A={1,2,3,4} :

R={(1,2), (2,2), (2,4), (3,2), (3,4), (4,1), (4,3)}

• There is an important way of picturing a relation R on a finite set.


• First we write down the elements of the set
• Draw an arrow from each element x to each element y when ever x is related to y.
• This diagram is called the directed graph of the relation.
More
Relations onexamples
a Set : Example
• Consider some relations on the set Z
• Are the following ordered pairs in the relation?
(1,1) (1,2) (2,1) (1,-1) (2,2)

• R1 = { (a,b) | a≤b } X X X
X X
• R2 = { (a,b) | a>b }
X X X
• R3 = { (a,b) | a=|b| }
X X
• R4 = { (a,b) | a=b }
X
• R5 = { (a,b) | a=b+1 }
X X X X
• R6 = { (a,b) | a+b≤3 }
Relation properties
Properties of Relations
• Properties of relations we will study:

• Reflexive

• Symmetric

• Antisymmetric

• Transitive
Reflexivity
• Reflexivity
• Definition: A relation is reflexive if
• (a, a)  R for all a  A
Symmetric and Antisymmetric
Relations
Definition
Symmetric and Antisymmetric
Relations
• A relation is symmetric if
• for all a, b  A, (a,b)  R (b,a)  R

• A relation is antisymmetric if
• for all a, b  A, (a,b)  R  (b,a)  R
• If aRb and bRa then a=b
Transitivity
Definition


Transitivity
Transitivity
• A relation is transitive if
• for all a, b, c  A, ((a,b)R  (b,c)R)  (a,c)R

• If a < b and b < c, then a < c


• Thus, < is transitive

• If a = b and b = c, then a = c
• Thus, = is transitive
Summary of properties of relations

reflexive a (a, a)  R

irreflexive a (a, a)  R

symmetric  a, b  A, (a,b)  R  (b,a)  R

asymmetric  a, b  A, (a,b)  R  (b,a)  R

 a, b  A, ((a,b)  R  (b,a)  R)  a=b


antisymmetric (*)
for all a, b  A, ((a,b)  R  a  b)  (b,a)  R)

transitive  a, b, c  A, ((a,b)  R  (b,c)  R)  (a,c)  R

(*)
Alternative definition…

You might also like