SlideShare una empresa de Scribd logo
1 de 21
Descargar para leer sin conexión
Normalisasi
15 Desember 2011
Integrity Constraint
 Redundancy
    Sumber masalah mengapa perlu Schema Refinement
 Dipecahkan dengan Dekomposisi
    Dekomposisi tidak terbebas dari masalah
    Harus dilakukan dengan hati-hati
 Constraint Anomalies
    Redundant Storage
    Update Anomalies
    Insertion Anomalies
    Deletion Anomalies
              Normal Form                             2
Multi-valued Column
 Seorang pegawai memiliki 1 atau lebih bawahan
 Seorang customer boleh memesan barang 1 kali atau
  lebih




      Ssn             Name        AB1           AB2           AB3
      123-22-3666     Attisho
      231-31-5368     Smiley      123-22-3666
      131-24-3650     Smethurst   231-31-5368   434-26-3751
      434-26-3751     Guldu                     612-67-4134
      612-67-4134       Madayan
                    Normal Form   131-24-3650                       3
Multi-valued Column
 Seorang pegawai memiliki 1 atau lebih bawahan
 Seorang customer boleh memesan barang 1 kali atau
  lebih




      Ssn             Name        AnakBuah
      123-22-3666     Attisho
      231-31-5368     Smiley      123-22-3666
      131-24-3650     Smethurst   231-31-5368, 434-26-3751
      434-26-3751     Guldu       612-67-4134
      612-67-4134      Madayan
                    Normal Form   131-24-3650                4
Bentuk Normal Pertama
 1st Normal Form
    Hilangkan duplicative columns dari setiap tabel
    Dekomposisi setiap kelompok atribut yang
      berhubungan ke dalam masing-masing tabel dengan
      diidentifikasi melalui Primary Key


      Ssn             Name        AnakBuah
      123-22-3666     Attisho
      231-31-5368     Smiley      123-22-3666
      131-24-3650     Smethurst   231-31-5368, 434-26-3751
      434-26-3751     Guldu       612-67-4134
      612-67-4134      Madayan
                    Normal Form   131-24-3650                5
Bentuk Normal Kedua
 2nd Normal Form
    Memenuhi 1st NF
    Pindahkan subset dari data pada sebuah tabel ke tabel
     lain
    Buat relasi antara tabel yang baru dengan tabel parent
     melalui hubungan Foreign Key
 Mengurangi jumlah data yang redundant pada tabel
  dengan memindahkannya ke tabel lain



                Normal Form                                   6
Bentuk Normal Kedua
 Customer (custID, fname, lname, address, city,
  province, postalcode)
 Redundancy
    (101, 'M', 'Najih', 'Gg. Guan I/2', 'Tangerang', 'Banten',
     99102)
    (102, 'Agung', 'Sediyono', 'Gd E lt.8', 'Karawaci', 'Banten',
     99102)




                 Normal Form                                         7
Bentuk Normal Kedua
 Dekomposisi relasi Customer (custID, fname, lname,
  address, city, province, postalcode)
    Customer (custID, fname, lname, address)
    ZIPcode (postalcode, city, province)
 Buat relasi Foreign Key antara Customer dan ZIPCode
   Customer (custID, fname, lname, address,
    postalcode)
   ZIPcode (postalcode, city, province)



              Normal Form                               8
Bentuk Normal Ketiga
 3rd Normal Form
    Memenuhi 1st NF dan 2nd NF
    Hapus atribut yang tidak bergantung kepada Primary
     Key
 Pesanan (IDpesanan, custID, hargaSatuan, jumlah,
  total)
    IDPesanan  hargaSatuan
    IDPesanan, custID  jumlah
 Atribut total bisa dihapus
    total = hargaSatuan × jumlah
               Normal Form                                9
Bentuk Normal Ketiga
 Atribut total bisa dihapus
    total = hargaSatuan × jumlah
 Pesanan (IDpesanan, custID, hargaSatuan, jumlah)
  SELECT IDPesanan, Total
  FROM Pesanan
  diganti dengan
  SELECT IDPesanan, hargaSatuan * jumlah AS Total
  FROM Pesanan




              Normal Form                            10
Boyce-Codd Normal Form
 Candidate Key
    Himpunan atribut yang dapat digunakan untuk
     mengidentifikasi secara unik baris-baris di dalam tabel
     basis data
 Primary Key
    Candidate Key yang dipilih menjadi Kunci dari tabel
 Determinan
    Candidate Key yang tidak dipilih menjadi Kunci




                Normal Form                                    11
Boyce-Codd Normal Form
 BCNF
    Memenuhi 1st NF, 2nd NF, dan 3rd NF
    Semua determinan adalah Candidate Key




              Normal Form                    12
How Far Should You Go?
 4th NF, 5th NF, 6th NF
 Kebanyakan kasus cukup hingga 3rd NF
 4th NF mendekomposisi tabel-tabel terlalu jauh
    Kinerja database turun
    Terlalu banyak join antar tabel




               Normal Form                         13
FD dan NF
 For a table to be in second normal form (2NF), there
  must be no case of a non-prime attribute in the table
  that is functionally dependendent upon a subset of
  a candidate key.
 For a table to be in third normal form (3NF), every
  non-prime attribute must have a non-transitive
  functional dependency on every candidate key.




               Normal Form                                14
FD dan NF
 For a table to be in Boyce-Codd Normal Form (BCNF),
  every functional dependency (other than trivial
  dependencies) must be on a superkey.
 For a table to be in fourth normal form (4NF), it must
  have no multivalued dependencies.




               Normal Form                                 15
Kasus Kardinalitas
 1-to-N
    Seorang Dosen membimbing beberapa mahasiswa PA
    Satu mahasiswa dibimbing oleh seorang Dosen PA
 mhs(nim, nama, e-mail, nik)
 dosen(nik, nama, e-mail)




              Normal Form                             16
Kasus Kardinalitas
 M-to-N
   Seorang Mahasiswa mengambil beberapa Mata Kuliah
   Satu Mata Kuliah diikuti oleh beberapa orang
    Mahasiswa
 mhs(nim, nama, e-mail, nik)
 mk (kodemk, nama, konsentrasi)
 krs (kodemk, nim, grade)




              Normal Form                              17
Kasus Kardinalitas
 CREATE TABLE mhs (
    nim CHAR(8) PRIMARY KEY,
    nama VARCHAR(20) NOT NULL,
    email VARCHAR(30),
 );
 CREATE TABLE mk (
    kodemk CHAR(6) PRIMARY KEY,
    nama VARCHAR(20) NOT NULL,
    konsentrasi VARCHAR(20) NOT NULL
 );



            Normal Form                18
Kasus Kardinalitas
 CREATE TABLE krs (
    kodemk CHAR(6) NOT NULL,
    nim CHAR(8) NOT NULL,
    FOREIGN KEY (kodemk) REFERENCES mk (kodemk),
    FOREIGN KEY (nim) REFERENCES mhs (nim)
 );




            Normal Form                            19
Pustaka
 Ramakhrisnan, Raghu & Johannes Gehrke, "Database
  Management Systems", 2nd ed., McGraw-Hill, 2000.
 Elmasri dan Navathe, "Foundation of Database System"
 http://databases.about.com/od/specificproducts/a/Databa
  se-Dependency.htm
 http://tjerdastangkas.blogspot.com/search/label/ikd312




               Normal Form                              20
Kamis, 15 Desember 2011

Más contenido relacionado

Destacado

Jornada de puertas abiertas 2016
Jornada de puertas abiertas 2016Jornada de puertas abiertas 2016
Jornada de puertas abiertas 2016XXX XXX
 
Most Wanted Xbox 360 Games 23 June 2009
Most Wanted Xbox 360 Games 23 June 2009Most Wanted Xbox 360 Games 23 June 2009
Most Wanted Xbox 360 Games 23 June 2009William
 
House For Rent in Montgomery Alabama 2009
House For Rent in Montgomery Alabama 2009House For Rent in Montgomery Alabama 2009
House For Rent in Montgomery Alabama 2009sad asad
 
Living in a Post-Morrison World: NAPPA Working Group
Living in a Post-Morrison World: NAPPA Working GroupLiving in a Post-Morrison World: NAPPA Working Group
Living in a Post-Morrison World: NAPPA Working GroupReed Kathrein
 
Haverhill, MA needs a fiber network
Haverhill, MA needs a fiber network Haverhill, MA needs a fiber network
Haverhill, MA needs a fiber network John Michitson
 
Ralph credentials Deck 2012
Ralph credentials Deck 2012Ralph credentials Deck 2012
Ralph credentials Deck 2012Jay Armitage
 
Microsoft
MicrosoftMicrosoft
MicrosoftVirus91
 
Innovation mentoring grant proposal 100113 rev 1
Innovation mentoring grant proposal 100113 rev 1Innovation mentoring grant proposal 100113 rev 1
Innovation mentoring grant proposal 100113 rev 1John Michitson
 
Electing A President Individual Quiz
Electing A President Individual QuizElecting A President Individual Quiz
Electing A President Individual Quizguest71290aa
 
Sarah Robins Powell resume/work sample
Sarah Robins Powell resume/work sampleSarah Robins Powell resume/work sample
Sarah Robins Powell resume/work samplesayster
 
Visualizing Differential Equations
Visualizing Differential EquationsVisualizing Differential Equations
Visualizing Differential Equationspd3h
 
Как найти, заполучить и удержать CTO
Как найти, заполучить и удержать CTOКак найти, заполучить и удержать CTO
Как найти, заполучить и удержать CTOGregory Sitnin
 
Microsoft history
Microsoft historyMicrosoft history
Microsoft historyVirus91
 
DDS Efficiency and Extensibility
DDS Efficiency and ExtensibilityDDS Efficiency and Extensibility
DDS Efficiency and ExtensibilityAngelo Corsaro
 
Archydro
ArchydroArchydro
Archydroabkhiz
 
before traveling
before travelingbefore traveling
before travelingJune Song
 

Destacado (20)

ISO C++ DDS PSM
ISO C++ DDS PSMISO C++ DDS PSM
ISO C++ DDS PSM
 
ikp321-04
ikp321-04ikp321-04
ikp321-04
 
Jornada de puertas abiertas 2016
Jornada de puertas abiertas 2016Jornada de puertas abiertas 2016
Jornada de puertas abiertas 2016
 
Pei 2010 2014
Pei 2010 2014Pei 2010 2014
Pei 2010 2014
 
ikh331-05-transaction
ikh331-05-transactionikh331-05-transaction
ikh331-05-transaction
 
Most Wanted Xbox 360 Games 23 June 2009
Most Wanted Xbox 360 Games 23 June 2009Most Wanted Xbox 360 Games 23 June 2009
Most Wanted Xbox 360 Games 23 June 2009
 
House For Rent in Montgomery Alabama 2009
House For Rent in Montgomery Alabama 2009House For Rent in Montgomery Alabama 2009
House For Rent in Montgomery Alabama 2009
 
Living in a Post-Morrison World: NAPPA Working Group
Living in a Post-Morrison World: NAPPA Working GroupLiving in a Post-Morrison World: NAPPA Working Group
Living in a Post-Morrison World: NAPPA Working Group
 
Haverhill, MA needs a fiber network
Haverhill, MA needs a fiber network Haverhill, MA needs a fiber network
Haverhill, MA needs a fiber network
 
Ralph credentials Deck 2012
Ralph credentials Deck 2012Ralph credentials Deck 2012
Ralph credentials Deck 2012
 
Microsoft
MicrosoftMicrosoft
Microsoft
 
Innovation mentoring grant proposal 100113 rev 1
Innovation mentoring grant proposal 100113 rev 1Innovation mentoring grant proposal 100113 rev 1
Innovation mentoring grant proposal 100113 rev 1
 
Electing A President Individual Quiz
Electing A President Individual QuizElecting A President Individual Quiz
Electing A President Individual Quiz
 
Sarah Robins Powell resume/work sample
Sarah Robins Powell resume/work sampleSarah Robins Powell resume/work sample
Sarah Robins Powell resume/work sample
 
Visualizing Differential Equations
Visualizing Differential EquationsVisualizing Differential Equations
Visualizing Differential Equations
 
Как найти, заполучить и удержать CTO
Как найти, заполучить и удержать CTOКак найти, заполучить и удержать CTO
Как найти, заполучить и удержать CTO
 
Microsoft history
Microsoft historyMicrosoft history
Microsoft history
 
DDS Efficiency and Extensibility
DDS Efficiency and ExtensibilityDDS Efficiency and Extensibility
DDS Efficiency and Extensibility
 
Archydro
ArchydroArchydro
Archydro
 
before traveling
before travelingbefore traveling
before traveling
 

Más de Anung Ariwibowo (20)

isd314-06-association-mining
isd314-06-association-miningisd314-06-association-mining
isd314-06-association-mining
 
ikp213-unifikasi
ikp213-unifikasiikp213-unifikasi
ikp213-unifikasi
 
ikp213-06-horn-clause
ikp213-06-horn-clauseikp213-06-horn-clause
ikp213-06-horn-clause
 
ikp213-01-pendahuluan
ikp213-01-pendahuluanikp213-01-pendahuluan
ikp213-01-pendahuluan
 
ikd312-05-sqlite
ikd312-05-sqliteikd312-05-sqlite
ikd312-05-sqlite
 
ikd312-05-kalkulus-relasional
ikd312-05-kalkulus-relasionalikd312-05-kalkulus-relasional
ikd312-05-kalkulus-relasional
 
ikd312-04-aljabar-relasional
ikd312-04-aljabar-relasionalikd312-04-aljabar-relasional
ikd312-04-aljabar-relasional
 
ikd312-03-design
ikd312-03-designikd312-03-design
ikd312-03-design
 
ikd312-02-three-schema
ikd312-02-three-schemaikd312-02-three-schema
ikd312-02-three-schema
 
ikp213-02-pendahuluan
ikp213-02-pendahuluanikp213-02-pendahuluan
ikp213-02-pendahuluan
 
ikh311-08
ikh311-08ikh311-08
ikh311-08
 
ikh311-07
ikh311-07ikh311-07
ikh311-07
 
ikh311-06
ikh311-06ikh311-06
ikh311-06
 
ikh311-05
ikh311-05ikh311-05
ikh311-05
 
ikp321-svn
ikp321-svnikp321-svn
ikp321-svn
 
ikh311-04
ikh311-04ikh311-04
ikh311-04
 
ikp321-05
ikp321-05ikp321-05
ikp321-05
 
imsakiyah-jakarta-1433-09
imsakiyah-jakarta-1433-09imsakiyah-jakarta-1433-09
imsakiyah-jakarta-1433-09
 
ikh311-03
ikh311-03ikh311-03
ikh311-03
 
ikp321-03
ikp321-03ikp321-03
ikp321-03
 

ikd312-09-normalisasi

  • 2. Integrity Constraint  Redundancy  Sumber masalah mengapa perlu Schema Refinement  Dipecahkan dengan Dekomposisi  Dekomposisi tidak terbebas dari masalah  Harus dilakukan dengan hati-hati  Constraint Anomalies  Redundant Storage  Update Anomalies  Insertion Anomalies  Deletion Anomalies Normal Form 2
  • 3. Multi-valued Column  Seorang pegawai memiliki 1 atau lebih bawahan  Seorang customer boleh memesan barang 1 kali atau lebih Ssn Name AB1 AB2 AB3 123-22-3666 Attisho 231-31-5368 Smiley 123-22-3666 131-24-3650 Smethurst 231-31-5368 434-26-3751 434-26-3751 Guldu 612-67-4134 612-67-4134 Madayan Normal Form 131-24-3650 3
  • 4. Multi-valued Column  Seorang pegawai memiliki 1 atau lebih bawahan  Seorang customer boleh memesan barang 1 kali atau lebih Ssn Name AnakBuah 123-22-3666 Attisho 231-31-5368 Smiley 123-22-3666 131-24-3650 Smethurst 231-31-5368, 434-26-3751 434-26-3751 Guldu 612-67-4134 612-67-4134 Madayan Normal Form 131-24-3650 4
  • 5. Bentuk Normal Pertama  1st Normal Form  Hilangkan duplicative columns dari setiap tabel  Dekomposisi setiap kelompok atribut yang berhubungan ke dalam masing-masing tabel dengan diidentifikasi melalui Primary Key Ssn Name AnakBuah 123-22-3666 Attisho 231-31-5368 Smiley 123-22-3666 131-24-3650 Smethurst 231-31-5368, 434-26-3751 434-26-3751 Guldu 612-67-4134 612-67-4134 Madayan Normal Form 131-24-3650 5
  • 6. Bentuk Normal Kedua  2nd Normal Form  Memenuhi 1st NF  Pindahkan subset dari data pada sebuah tabel ke tabel lain  Buat relasi antara tabel yang baru dengan tabel parent melalui hubungan Foreign Key  Mengurangi jumlah data yang redundant pada tabel dengan memindahkannya ke tabel lain Normal Form 6
  • 7. Bentuk Normal Kedua  Customer (custID, fname, lname, address, city, province, postalcode)  Redundancy  (101, 'M', 'Najih', 'Gg. Guan I/2', 'Tangerang', 'Banten', 99102)  (102, 'Agung', 'Sediyono', 'Gd E lt.8', 'Karawaci', 'Banten', 99102) Normal Form 7
  • 8. Bentuk Normal Kedua  Dekomposisi relasi Customer (custID, fname, lname, address, city, province, postalcode)  Customer (custID, fname, lname, address)  ZIPcode (postalcode, city, province)  Buat relasi Foreign Key antara Customer dan ZIPCode  Customer (custID, fname, lname, address, postalcode)  ZIPcode (postalcode, city, province) Normal Form 8
  • 9. Bentuk Normal Ketiga  3rd Normal Form  Memenuhi 1st NF dan 2nd NF  Hapus atribut yang tidak bergantung kepada Primary Key  Pesanan (IDpesanan, custID, hargaSatuan, jumlah, total)  IDPesanan  hargaSatuan  IDPesanan, custID  jumlah  Atribut total bisa dihapus  total = hargaSatuan × jumlah Normal Form 9
  • 10. Bentuk Normal Ketiga  Atribut total bisa dihapus  total = hargaSatuan × jumlah  Pesanan (IDpesanan, custID, hargaSatuan, jumlah) SELECT IDPesanan, Total FROM Pesanan diganti dengan SELECT IDPesanan, hargaSatuan * jumlah AS Total FROM Pesanan Normal Form 10
  • 11. Boyce-Codd Normal Form  Candidate Key  Himpunan atribut yang dapat digunakan untuk mengidentifikasi secara unik baris-baris di dalam tabel basis data  Primary Key  Candidate Key yang dipilih menjadi Kunci dari tabel  Determinan  Candidate Key yang tidak dipilih menjadi Kunci Normal Form 11
  • 12. Boyce-Codd Normal Form  BCNF  Memenuhi 1st NF, 2nd NF, dan 3rd NF  Semua determinan adalah Candidate Key Normal Form 12
  • 13. How Far Should You Go?  4th NF, 5th NF, 6th NF  Kebanyakan kasus cukup hingga 3rd NF  4th NF mendekomposisi tabel-tabel terlalu jauh  Kinerja database turun  Terlalu banyak join antar tabel Normal Form 13
  • 14. FD dan NF  For a table to be in second normal form (2NF), there must be no case of a non-prime attribute in the table that is functionally dependendent upon a subset of a candidate key.  For a table to be in third normal form (3NF), every non-prime attribute must have a non-transitive functional dependency on every candidate key. Normal Form 14
  • 15. FD dan NF  For a table to be in Boyce-Codd Normal Form (BCNF), every functional dependency (other than trivial dependencies) must be on a superkey.  For a table to be in fourth normal form (4NF), it must have no multivalued dependencies. Normal Form 15
  • 16. Kasus Kardinalitas  1-to-N  Seorang Dosen membimbing beberapa mahasiswa PA  Satu mahasiswa dibimbing oleh seorang Dosen PA  mhs(nim, nama, e-mail, nik)  dosen(nik, nama, e-mail) Normal Form 16
  • 17. Kasus Kardinalitas  M-to-N  Seorang Mahasiswa mengambil beberapa Mata Kuliah  Satu Mata Kuliah diikuti oleh beberapa orang Mahasiswa  mhs(nim, nama, e-mail, nik)  mk (kodemk, nama, konsentrasi)  krs (kodemk, nim, grade) Normal Form 17
  • 18. Kasus Kardinalitas CREATE TABLE mhs ( nim CHAR(8) PRIMARY KEY, nama VARCHAR(20) NOT NULL, email VARCHAR(30), ); CREATE TABLE mk ( kodemk CHAR(6) PRIMARY KEY, nama VARCHAR(20) NOT NULL, konsentrasi VARCHAR(20) NOT NULL ); Normal Form 18
  • 19. Kasus Kardinalitas CREATE TABLE krs ( kodemk CHAR(6) NOT NULL, nim CHAR(8) NOT NULL, FOREIGN KEY (kodemk) REFERENCES mk (kodemk), FOREIGN KEY (nim) REFERENCES mhs (nim) ); Normal Form 19
  • 20. Pustaka  Ramakhrisnan, Raghu & Johannes Gehrke, "Database Management Systems", 2nd ed., McGraw-Hill, 2000.  Elmasri dan Navathe, "Foundation of Database System"  http://databases.about.com/od/specificproducts/a/Databa se-Dependency.htm  http://tjerdastangkas.blogspot.com/search/label/ikd312 Normal Form 20