Download presentation
Presentation is loading. Please wait.
1
Relations
3
Ipoh Kota Bharu Alor Star Seremban Pasir Mas Perak Kelantan Kedah Neg. Sembilan citiesstates isin
4
Relations Defining isin relation isin == {(Ipoh,Perak), (Kota Bharu, Kelantan), (Alor Star, Kedah), (Seremban, Neg Sembilan), (Pasir Mas, Kelantan)} From the above we that (Ipoh,Perak) isin but (Ipoh, Kelantan) isin we can deduce that, the type of isin is ℙ( cities states)
5
Notation for Relation
6
Examples
8
Declaring Relations Examples isin : cities states Another example let [Author] and [Title] are given sets, then we will have wrote : ℙ (Author Title) wrote : Author Title
9
Representing pairs that make up a relation (x,y), we can use maplet notation x ↦ y Using maplet notation for isin relation {Ipoh ↦ Perak, Kota Bharu ↦ Kelantan, …} Ipoh ↦ Perak isin {Ipoh ↦ Perak, Kota Bharu ↦ Kelantan} isin
10
Domains and Ranges Domain of a relation is the set of first elements of the pairs (source) in the relation suppose R : X Y then dom R = { x : X | y : Y x ↦ y R} Range of a relation is the set of second elements of the pairs (target) in the relation ran R = {y : Y | x : X x ↦ y R}
11
Example
12
Exercise Assume that the definition of two relations involving the sets People, and Instruments as follows: plays == {Ash ↦ piano, William ↦ guitar, David ↦ violin, Huw ↦ trumpet, Alice ↦ flute, Alice ↦ piano, Kate ↦ piano} what are the domain and range of plays?
13
Restriction Domain restriction getting attention to those pairs in relation whose first members are members of some other set of interest Example: to confine the relation wrote to those pair whose first members are in the set female --- female ⊳ wrote An abbreviation of either of the following { a: female; t : Title | a wrote t a ↦ t } (female Title) wrote
14
Restriction Range restriction getting attention to those pairs in relation whose second members are members of some other set of interest Example: restrict on second members as set of novel which is a set of titles --- wrote ▷ novel An abbreviation of either of the following { a: Author; t : Novel | a wrote t a ↦ t } (Author Novel) wrote
15
Subtraction Domain subtraction Getting attention to those pair in a relation whose first members are not members of some other set of interest Example: denote set of ordered pairs in wrote whose first members are not in female
16
Subtraction Range subtraction Getting attention to those pair in a relation whose second members are not members of some other set of interest Example: denote set of ordered pairs in wrote whose second members are not in novel
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.