IDPEL
|
NMPEL
|
AP
|
123
|
Sely
|
Semplak
|
124
|
Meli
|
Joglo
|
125
|
Dewi
|
Bintaro
|
127
|
Linda
|
Lenteng Agung
|
126
|
Luqman
|
Lenteng Agung
|
Tabel Harga
IDPEL
|
NMPEL
|
Sosial
|
85
|
Bisnis
|
110
|
Rumah
|
100
|
Tabel Daya_Terpasang
IDPEL
|
NMPEL
|
AP
|
123
|
Rumah
|
1300
|
123
|
Sosial
|
900
|
124
|
Rumah
|
1300
|
125
|
Sosial
|
2500
|
126
|
Rumah
|
1300
|
127
|
Sosial
|
900
|
1. Analisis
Jika graph tidak
terkoneksi, maka query salah
Contoh:
select nmpel, tarif
from pelanggan, harga
where ap = “lenteng
agung”
and tarif = 110
2. Sederhanakan
1. p ∧ p ⇔ p
2. p V
p ⇔ p
3. p ∧ true ⇔ p
4. p V
false ⇔ p
5. p ∧ false ⇔ false
6. p V true ⇔ true
7. p ∧ ¬p ⇔ false
8. p V ¬p ⇔ true
9. p1 ∧ (p1 V p2) ⇔ p1
10. p1
V (p1 ∧ p2) ⇔ p1
Contoh:
select ap from
pelanggan
where nmpel = “sely”
or (not(ap=”semplak”)
and(ap=”semplak” or
ap =”bntaro”)
and not (ap=”bintaro”)
permisalan:
p1: nmpel=”sely”
p2: ap=”semplak”
p3: ap=”bintaro”
jadi:
p1 V (¬p2 ∧ (p2
V p3) ∧ ¬p3)
= p1 V ((¬p2 ∧ p2)
V (p3 ∧ ¬p3))
= p1 V (false V false)
= (p1 V false) V false
= p1 V false
= p1
select ap from
pelanggan where nmpel = “sely”
3. Tata Ulang (gunakan
query tree)
Contoh:
Cari nama pelanggan
yang tidak dilayani oleh ap lenteng agung yang mempunyai daya > 1300 dan
merupakan golongan rumah dengan tarif 85
select p.nmpel from
pelanggan p, daya_terpasang d, harga h
where p.idpel =
d.idpel and d.gol = h.gol
and p.ap <> ‘lenteng agung’ and d.daya
> 1300 and and h.gol = “rumah” and h.tarif = 85
atau
select nmpel from (select
* from pelanggan natural join daya_terpasang natural join harga
where ap <> ‘lenteng agung’ and daya >
1300 and gol = ‘rumah’ and tarif = 85)
Tidak ada komentar:
Posting Komentar