1 / 35

RELASI

RELASI. Definisi dan Notasi: Relasi R dari A ke B merupakan sub-himpunan dari A  B R : A  B Representasi dari relasi R : A  B, bisa dilakukan dg 4 cara: 1) himpunan pasangan terurut, 2) pemetaan, 3) matriks, 4) Notasi Digunakan matriks dengan :

Download Presentation

RELASI

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. RELASI

  2. Definisi dan Notasi: • Relasi Rdari A ke Bmerupakan sub-himpunan dari A  B • R : A  B • Representasi dari relasi R : A  B, bisa dilakukan dg 4 cara: 1) himpunan pasangan terurut, 2) pemetaan, 3) matriks, 4) Notasi • Digunakan matriks dengan : • baris merepresentasikan elemen-elemen A • kolom merepresentasikan elemen-elemen B • entri (ai, bj) = 1 jika (ai, bj)  R, i,j menunjukkan indeks • entri (ai, bj) = 0 jika (ai, bj)  R

  3. Contoh: • A = { a, p, x }; B = { b, q, y, z }, AxB={(a,b), (a,y), (a,q), (a,z), (p,b), …} , R1={(a,z), (p,y), (p,b)} • R = { (a, b), (p, q), (x, y), (x, z) } • (a, b) R atau a R b • (a, q) R atau a R q Relasi R dlm bentuk matriks Relasi R dlm bentuk pemetaan b q y z b q y z a p x a p x 10 0 0 0 10 0 0 01 1

  4. Invers dari relasi R (R–1), R–1 : B  A R–1 = { (b,a) | (a, b)  R} = { (b, a), (q, p), (y, x), (z, x) } Komplemen dari relasi R, R : A  B R = { (a, b | (a, b)  R , tapi (a,b)  AXB} = { (a, q), (a, y), (a, z), (p, b), (p, y), (p, z), (x, b), (x, q) } Tentukan himp relasi yang unsur absisnya huruf vokal dan ordinatnya huruf konsonan dari A dan B di atas!

  5. R={(a,b), (a,q), (a,y), (a,z)}

  6. Relasi pada sebuah himpunan (relation on a set) • R : A  Aadalah sub-himpunan dari A  A • Contoh (Example 5): R : Bil Bulat  Bil Bulat • R1 = { (a, b) | a  b} • R2 = { (a, b) | a  b} • R3 = { (a, b) | a = b or a = – b } • R4 = { (a, b) | a = b} • R5 = { (a, b) | a = b + 1 } • R6 = { (a, b) | a + b  3}

  7. Relasi pada sebuah himpunan (relation on a set) • R : A  Aadalah sub-himpunan dari A  A • Representasi dari R : A  A • Menggunakan Matriks Relasi (banyaknya baris = banyaknya kolom) • Menggunakan Directed Graph (disingkat Digraph=Graph berarah) • Contoh : A = { 1, 2, 3 }; R = { (1, 1), (1, 2), (2, 3), (3, 1) } • 2 • 1 • 3 1 10 0 01 10 0

  8. Sifat-sifat relasi R : A  A • Refleksif : a [ (a, a)  R ] • Irefleksif : a [ (a, a)  R ] • Sifat-sifat relasi R : A  B • Simetrik : a,b [ (a, b)  R  (b, a)  R ] • Antisimetrik : a,b [ ((a, b)  R  (b, a)  R)  (a = b) ] • atau a ,b [ (a  b)  ((a, b)  R  (b, a)  R) ] • 3. Transitif: a,b,c [((a, b)  R  (b, c)  R)  (a, c)  R ] • 4. Asimetrik : a, b [ (a, b)  R  (b, a)  R ]

  9. Contoh (Example 5): Cek sifat-sifat relasi R : A  A , di mana A = { 1, 2, 3, 4 } R1 = { (a, b) | a  b} R4 = { (a, b) | a = b} R2 = { (a, b) | a  b} R5 = { (a, b) | a = b + 1 } R3 = { (a, b) | a = b or a = – b } R6 = { (a, b) | a + b  3} R1 = {(1,1), (1,2), (1,3), (1,4), (2,2), (2,3), (2,4), (3,3), (3,4), (4,4)} Refleksif : ya, karena(1,1), (2,2), (3,3), (4,4)  R1 Irefleksif : tidak, karena (1,1)  R1 Simetrik : tidak, karena (1, 3)  R1 (3, 1)  R1 Asimetrik : ya, karena (4a, 4b)  R1 (4b, 4a)  R1 Antisimetrik : ya, karena [(4a, 4b)  R1 (4b, 4a)  R1]  ( 4a = 4b) memenuhi untuk (1,1), (2,2), (3,3) juga

  10. Contoh (Example 5): Cek sifat-sifat relasi R : A  A , di mana A = { 1, 2, 3 } R2 = { (a, b) | a  b} R5 = { (a, b) | a = b + 1 } R6 = { (a, b) | a + b  3} Periksa sifat relasi utk relasi tsb Kerjakan per kelompok maks 3 org Sekarang!

  11. R1 : { 1, 2, 3, 4 }  { 1, 2, 3, 4 }, A di mana R1 = { (a, b) | a  b} R1 = {(1,1), (1,2), (1,3), (1,4), (2,2), (2,3), (2,4), (3,3), (3,4), (4,4)} Transitif : (a, b)  R1 dan (b, c)  R1  (a, c)  R1 (1,1)  R1 dan (1,1)  R1  (1,1)  R1 ; (1,1)  R1 dan (1,2)  R1  (1,2)  R1 (1,1)  R1 dan (1,3)  R1  (1,3)  R1 ; (1,1)  R1 dan (1,4)  R1  (1,4)  R1 (1,2)  R1 dan (2,2)  R1  (1,2)  R1 ; (1,2)  R1 dan (2,3)  R1  (1,3)  R1 (1,2)  R1 dan (2,4)  R1  (1,4)  R1 ; (1,3)  R1 dan (3,3)  R1  (1,3)  R1 (1,3)  R1 dan (3,4)  R1  (1,4)  R1 ; (1,4)  R1 dan (4,4)  R1  (1,4)  R1 (2,2)  R1 dan (2,2)  R1  (2,2)  R1 ; (2,2)  R1 dan (2,3)  R1  (2,3)  R1 (2,2)  R1 dan (2,4)  R1  (2,4)  R1; (2,3)  R1 dan (3,3)  R1  (2,3)  R1 (2,3)  R1 dan (3,4)  R1  (2,4)  R1; (2,4)  R1 dan (4,4)  R1  (2,4)  R1 (3,3)  R1 dan (3,3)  R1  (3,3)  R1 ; (3,3)  R1 dan (3,4)  R1  (3,4)  R1 (4,4)  R1 dan (4,4)  R1  (4,4)  R1

  12. Refleksif : a [ (a, a)  R ] • R : integer  integer • R1 = { (a, b) | a  b} ya • R2 = { (a, b) | a  b} tidak • R3 = { (a, b) | a = b or a = – b } ya • R4 = { (a, b) | a = b} ya • R5 = { (a, b) | a = b + 1 } tidak • R6 = { (a, b) | a + b  3 } ya

  13. 2.Simetrik: a b [ (a, b)  R  (b, a)  R ] • R : integer  integer • R1 = { (a, b) | a  b} tidak • R2 = { (a, b) | a  b} tidak • R3 = { (a, b) | a = b or a = – b } ya • R4 = { (a, b) | a = b} ya • R5 = { (a, b) | a = b + 1 } tidak • R6 = { (a, b) | a + b  3 } ya

  14. 3. Antisimetrik : a b [ ((a, b)  R  (b, a)  R)  (a = b) ] • atau a b [ (a  b)  ((a, b)  R  (b, a)  R) ] • R : integer  integer • R1 = { (a, b) | a  b} • R2 = { (a, b) | a  b} • R3 = { (a, b) | a = b or a = – b } • R4 = { (a, b) | a = b} • R5 = { (a, b) | a = b + 1 } • R6 = { (a, b) | a + b  3 }

  15. 4. Transitif : • abc [((a, b)  R  (b, c)  R)  (a, c)  R ] • R : integer  integer • R1 = { (a, b) | a  b} • R2 = { (a, b) | a  b} • R3 = { (a, b) | a = b or a = – b } • R4 = { (a, b) | a = b} • R5 = { (a, b) | a = b + 1 } • R6 = { (a, b) | a + b  3 }

  16. 5. Irefleksif : a [ (a, a)  R ] • R : integer  integer • R1 = { (a, b) | a  b} • R2 = { (a, b) | a  b} • R3 = { (a, b) | a = b or a = – b } • R4 = { (a, b) | a = b} • R5 = { (a, b) | a = b + 1 } • R6 = { (a, b) | a + b  3 }

  17. 6. Asimetrik : a b [ (a, b)  R  (b, a)  R ] • R : integer  integer • R1 = { (a, b) | a  b} • R2 = { (a, b) | a  b} • R3 = { (a, b) | a = b or a = – b } • R4 = { (a, b) | a = b} • R5 = { (a, b) | a = b + 1 } • R6 = { (a, b) | a + b  3 }

  18. SOAL: • Periksa ke-6 sifat relasi untuk • Relasi invers dari R1 s/d. R6 • Relasi komplementer dari R1 s/d. R6 • Catatan: R : A  B • Relasi invers dari R, notasi R-1: B  A • { (b, a) | (a, b)  R } • Relasi komplemen dari R, notasi R: A  B • { (a, b) | (a, b) R }

  19. Kombinasi dua relasi: • R1 : A  B • R2 : A  B • R1  R2 • R1  R2 • R1  R2 • R1 – R2 • R2 – R1 • Catatan: baca Examples 3, 4 (halaman 491, 492)

  20. Komposisi dua relasi: A B C a b c R : A  B S : B  C dan disebut relasi komposit/komposisi R S S  R Komposisi ditulis sebagai S  R

  21. Contoh: R : A  B di mana A = { 1, 2, 3 } dan B = { 1, 2, 3, 4 } S : B  C di mana C = { 0, 1, 2 } R = { (1,1), (1,4), (2,3), (3,1), (3,4) } S = { (1,0), (2,0), (3,1), (3,2), (4,1) } S  R = ………………. Soal: Gambarkan relasi komposit tersebut.

  22. Representasi relasi komposit: R : A  B di mana A = { 1, 2, 3 } dan B = { 1, 2, 3, 4 } S : B  C di mana C = { 0, 1, 2 } R = { (1,1), (1,4), (2,3), (3,1), (3,4) } S = { (1,0), (2,0), (3,1), (3,2), (4,1) } MR = MS = MS°R = MR MS (perkalian Boolean MR dan MS)

  23. MR = MS = MS°R = MR MS (perkalian Boolean MR dan MS) =1 1 0 0 1 1 1 1 0

  24. Komposisi lebih dari dua relasi R: A  A • R1 = R • R2 = R  R • R3 = R2 R • ………. • Rn+1 = Rn  R

  25. Contoh: R : {1, 2, 3, 4}  {1, 2, 3, 4} R = { (1,1), (2,1), (3,2), (4,3) } R2 = { (1,1), (2,1), (3,1), (4,2) } R3 = { (1,1), (2,1), (3,1), (4,1) } R4 = { (1,1), (2,1), (3,1), (4,1) } R5 = { (1,1), (2,1), (3,1), (4,1) } dst Soal: Verifikasi dengan gambar

  26. R : {1, 2, 3, 4}  {1, 2, 3, 4} R = { (1,1), (2,1), (3,2), (4,3) } R2 = { (1,1), (2,1), (3,1), (4,2) } R3 = { (1,1), (2,1), (3,1), (4,1) } MR = MR = MRMR 2

  27. RELASI n-ary Sub-bab 7.2

  28. Relasi R: • Binary : (a1, a2) disebut ordered-pair • Contoh : (Nama_mahasiswa, nilai_UTS) • Ternary : (a1, a2, a3) disebut ordered-triple • Contoh : (NRP_mhs, Nama_mhs, nilai_UTS) • Contoh lain: • R adalah relasi (penerbangan, no-penerbangan, asal, tujuan, waktu-berangkat) • Disebut quintuple (karena terdiri dari 5 komponen) • n-ary : (a1, a2, a3, … , an) disebut n-tuple

  29. Relasi R: • Binary : (a1, a2) disebut ordered-pair • Contoh : (Nama_mahasiswa, nilai_UTS) • Ternary : (a1, a2, a3) disebut ordered-triple • Contoh : (NRP_mhs, Nama_mhs, nilai_UTS) • Contoh lain: • R adalah relasi (penerbangan, no-penerbangan, asal, tujuan, waktu-berangkat) • Disebut quintuple (karena terdiri dari 5 komponen) • n-ary : (a1, a2, a3, … , an) disebut n-tuple

  30. Definisi: • Relasi n-ary adalah sub-himpunan dari A1  A2 A3 …  An • Himpunan-himpunan A1, A2, A3, …, An disebut domaindari relasi • n disebut derajatrelasi • Aplikasi: Basis Data Relasional

  31. Terminologi: Tabel : alternatif representasi basis data relasional Primary-key : a domain of an n-ary relation such that an n-tuple is uniquely determined by its value for this domain Composite-key : the Cartesian product of domains of an n-ary relation such that an n-tuple is uniquely determined by its values for these domains Projection : a function that produces relations of smaller degree from an n-ary relation by deleting fields Join : a function that combines n-ary relations that agree on certain fields SQL : Structured Query Language

  32. Primary-key :a domain of an n-ary relation such that an n-tuple is uniquely determined by its value for this domain • Contoh: lihat Tabel 1 • 4-tuple : (nama, nomor-identitas, jurusan, IPK) • (Ackermann, 231455, CS, 3.88) • (Adams, 8888323, Physics, 3.45) • (Chou, 102147, CS, 3.49) • (Goodfriend, 453876, Math, 3.45) • (Rao, 678543, Math, 3.90) • (Stevens, 786576, Psychology, 2.99) • Alternatif primary-key: nama, nomor-identitas

  33. Composite-key :the Cartesian product of domains of an n-ary relation such that an n-tuple is uniquely determined by its values for these domains • Contoh:4-tuple : (nama, nomor-identitas, jurusan, IPK) • (Ackermann, 231455, CS, 3.88) CS, 3.45 • (Adams, 8888323, Physics, 3.45) CS, 3.88 • (Chou, 102147, CS, 3.49) Math, 3.45 • (Goodfriend, 453876, Math, 3.45) Math, 3.90 • (Rao, 678543, Math, 3.90) Physics, 3.45 • (Stevens, 786576, Psychology, 2.99) Psychology, 2.99 • Alternatif composite-key: jurusan x IPK

  34. Projection : a function that produces relations of smaller degree from an n-ary relation by deleting fields Pi1,i2,i3, … ,imdeletes n–m of the components of the n-tuple, leaving the i1th, i2th, i3th, …, imth components Lihat Example 7

  35. Join : Jp Jp is a function that combines all m-tuples of the first relation with all n-tuples of the second relation, where the last p components of the m-tuples agree with the first p components of the n-tuples. Lihat Example 9 halaman 486

More Related