1 / 23

Relations

Relations. Relations. Relations. cities. states. isin. Ipoh Kota Bharu Alor Star Seremban Pasir Mas. Perak Kelantan Kedah Neg. Sembilan. Relations. Defining isin relation isin == {(Ipoh,Perak), (Kota Bharu, Kelantan), (Alor Star, Kedah),

zody
Download Presentation

Relations

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Relations

  2. Relations

  3. Relations cities states isin Ipoh Kota Bharu Alor Star Seremban Pasir Mas Perak Kelantan Kedah Neg. Sembilan

  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

  7. 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 female wrote

  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 wrote novel

  17. Inverse

  18. Inverse

  19. Relational Image • Given any set of domain-type elements of a relation, we can get the subset of range elements to which they are related

  20. Relational Composition

  21. Given two relations such that the range type of the first is the same as the domain type of the second • Able to put ‘end-to-end’ to form a single relation containing all pairs joined by some common elements • Example: wrote : Author  Title issued-by : Title  Publisher composition published-by : wrote ; issued-by

More Related