daniel adinugrohodatabase programming 1 database programming lecture on 04 – 05 – 2005
TRANSCRIPT
![Page 1: Daniel AdinugrohoDatabase Programming 1 DATABASE PROGRAMMING Lecture on 04 – 05 – 2005](https://reader036.vdocument.in/reader036/viewer/2022083010/5697bff21a28abf838cbbfe0/html5/thumbnails/1.jpg)
Daniel Adinugroho Database Programming1
DATABASE PROGRAMMING
Lecture on 04 – 05 – 2005
![Page 2: Daniel AdinugrohoDatabase Programming 1 DATABASE PROGRAMMING Lecture on 04 – 05 – 2005](https://reader036.vdocument.in/reader036/viewer/2022083010/5697bff21a28abf838cbbfe0/html5/thumbnails/2.jpg)
Daniel Adinugroho Database Programming2
PREVIOUS LECTURE
1. Introduction to Database Design
- 6 Steps Database Design
2. Normalization.
- 1NF, 2NF and 3NF and example of normalization.
- BCNF, 4NF and 5NF
![Page 3: Daniel AdinugrohoDatabase Programming 1 DATABASE PROGRAMMING Lecture on 04 – 05 – 2005](https://reader036.vdocument.in/reader036/viewer/2022083010/5697bff21a28abf838cbbfe0/html5/thumbnails/3.jpg)
Daniel Adinugroho Database Programming3
NEWS
1. All lecture materials are available on
http://192.168.1.1/teachers/adinugro/dp
2. Next Lecture will be QUIZ (06/05/2005)
- About Normalization
- OPEN BOOK
- DO NOT CHEAT!!!!!!!!!! or You will get 0.
- Exercise for exam, as the question is a typical exam questions,
- OK?
![Page 4: Daniel AdinugrohoDatabase Programming 1 DATABASE PROGRAMMING Lecture on 04 – 05 – 2005](https://reader036.vdocument.in/reader036/viewer/2022083010/5697bff21a28abf838cbbfe0/html5/thumbnails/4.jpg)
Daniel Adinugroho Database Programming4
REVIEW OF NORMAL FORMS1NF -> eliminate repeating attributes
1. Identify repeating attributes.
2. All the key attributes are defined.
3. All attributes are dependent on the primary key.
2NF
1. It's in first normal form (1NF)
2. It includes no partial dependencies (where an attribute is
dependent on only a part of a primary key).
3NF
1. It's in second normal form (2NF)2. It contains no transitive dependencies (where a non-key attribute is dependent on
another non-key attribute
![Page 5: Daniel AdinugrohoDatabase Programming 1 DATABASE PROGRAMMING Lecture on 04 – 05 – 2005](https://reader036.vdocument.in/reader036/viewer/2022083010/5697bff21a28abf838cbbfe0/html5/thumbnails/5.jpg)
Daniel Adinugroho Database Programming5
Project
numberProject name
Employee
numberEmployee name
Rate
category
Hourly
rate
1023 Madagascar travel site 11 Vincent Radebe A $60
12 Pauline James B $50
16 Charles Ramoraz C $40
1056 Online estate agency 11 Vincent Radebe A $60
17 Monique Williams B $50
![Page 6: Daniel AdinugrohoDatabase Programming 1 DATABASE PROGRAMMING Lecture on 04 – 05 – 2005](https://reader036.vdocument.in/reader036/viewer/2022083010/5697bff21a28abf838cbbfe0/html5/thumbnails/6.jpg)
Daniel Adinugroho Database Programming6
1st NORMAL FORM
Project
numberProject name
Employee
numberEmployee name
Rate
category
Hourly
rate
1023 Madagascar travel site 11 Vincent Radebe A $60
1023 Madagascar travel site 12 Pauline James B $50
1023 Madagascar travel site 16 Charles Ramoraz C $40
1056 Online estate agency 11 Vincent Radebe A $60
1056 Online estate agency 17 Monique Williams B $50
![Page 7: Daniel AdinugrohoDatabase Programming 1 DATABASE PROGRAMMING Lecture on 04 – 05 – 2005](https://reader036.vdocument.in/reader036/viewer/2022083010/5697bff21a28abf838cbbfe0/html5/thumbnails/7.jpg)
Daniel Adinugroho Database Programming7
2nd NORMAL FORM
Employee Table
Employee number Employee name Rate category Hourly rate
11 Vincent Radebe A $60
12 Pauline James B $50
16 Charles Ramoraz C $40
11 Vincent Radebe A $60
17 Monique Williams B $50
![Page 8: Daniel AdinugrohoDatabase Programming 1 DATABASE PROGRAMMING Lecture on 04 – 05 – 2005](https://reader036.vdocument.in/reader036/viewer/2022083010/5697bff21a28abf838cbbfe0/html5/thumbnails/8.jpg)
Daniel Adinugroho Database Programming8
2nd NORMAL FORM
Project Table Employee
Project Table
Project
numberProject name
1023 Madagascar travel site
1056 Online estate agency
Project
number
Employee
number
1023 11
1023 12
1023 16
1056 11
1056 17
![Page 9: Daniel AdinugrohoDatabase Programming 1 DATABASE PROGRAMMING Lecture on 04 – 05 – 2005](https://reader036.vdocument.in/reader036/viewer/2022083010/5697bff21a28abf838cbbfe0/html5/thumbnails/9.jpg)
Daniel Adinugroho Database Programming9
3rd NORMAL FORM
Employee Table Rate Table
Employee
numberEmployee name
Rate
category
11 Vincent Radebe A
12 Pauline James B
16 Charles Ramoraz C
11 Vincent Radebe A
17 Monique Williams B
Rate
category
Hourly
rate
A $60
B $50
C $40
![Page 10: Daniel AdinugrohoDatabase Programming 1 DATABASE PROGRAMMING Lecture on 04 – 05 – 2005](https://reader036.vdocument.in/reader036/viewer/2022083010/5697bff21a28abf838cbbfe0/html5/thumbnails/10.jpg)
Daniel Adinugroho Database Programming10
3rd NORMAL FORM
Project Table Employee
Project Table
Project
numberProject name
1023 Madagascar travel site
1056 Online estate agency
Project
number
Employee
number
1023 11
1023 12
1023 16
1056 11
1056 17
![Page 11: Daniel AdinugrohoDatabase Programming 1 DATABASE PROGRAMMING Lecture on 04 – 05 – 2005](https://reader036.vdocument.in/reader036/viewer/2022083010/5697bff21a28abf838cbbfe0/html5/thumbnails/11.jpg)
Daniel Adinugroho Database Programming11
DENORMALIZATION
Normalization is:
● Storing one fact in one place
● Storing related facts about single entity together
● every column of each entity refers non-transitively to only the unique identifier
for that entity.
Denormalization: is the reversal process of Normalization, which is a process to
store a fact in numerous places.
![Page 12: Daniel AdinugrohoDatabase Programming 1 DATABASE PROGRAMMING Lecture on 04 – 05 – 2005](https://reader036.vdocument.in/reader036/viewer/2022083010/5697bff21a28abf838cbbfe0/html5/thumbnails/12.jpg)
Daniel Adinugroho Database Programming12
DENORMALIZATION(2)
Sometimes we need to do denormalization to accomplish quick retrieval capability
for data stored in relational database.
Of course we should (whenever possible) normalize our design to provide optimum
environment . However, in real world, denormalization is necessary.
Some issues need to be considered before denormalization:
● can the system achieve acceptable performance without denormalizating?
● will the performance of the system after denormalizating still unacceptable?
● will the system be less reliable due to denormalization?
If there is one 'yes' answer, we should avoid denormalization!
![Page 13: Daniel AdinugrohoDatabase Programming 1 DATABASE PROGRAMMING Lecture on 04 – 05 – 2005](https://reader036.vdocument.in/reader036/viewer/2022083010/5697bff21a28abf838cbbfe0/html5/thumbnails/13.jpg)
Daniel Adinugroho Database Programming13
DENORMALIZATION (EXAMPLE)In order to justify denormalization we need to have a business reason for the alteration form 3rd NF. This example design is for a mail order company that has 120,000,000 customers to whom they must send catalogs. The top design is in 3rd normal form because the attributes for State, City, and Country are codependent on the PostalCode field. To fix that we created the PostalCode entity and related it back to the Customer records on the PostalCode foreign key in the Customer table.
However, during system testing it was discovered that the time required to produce 120,000,000 mailing labels through a two-table join was much longer than if the labels could be produced from a single table. The table was then denormalized by reintroducing the City, State, and Country attributes to the Customer table.
After doing this it would be heavily documented including the normal form that is violated, the reason for the violation, and the consequences of the violation. Any violation of a fully normalized design carries with it potential problems in the area of updates.
![Page 14: Daniel AdinugrohoDatabase Programming 1 DATABASE PROGRAMMING Lecture on 04 – 05 – 2005](https://reader036.vdocument.in/reader036/viewer/2022083010/5697bff21a28abf838cbbfe0/html5/thumbnails/14.jpg)
Daniel Adinugroho Database Programming14
REFERENCES
● Craig, S. Mullin, Denormalization,
http://www.objectarchitects.de/ObjectArchitects/orpatterns/Performance/
Denormalization/CraigMullinsGuidelines/i001fe02.htm ● Ian Gilfillan, Database Normalization,
http://www.databasejournal.com/sqletc/article.php/1428511● Mike Hillyer, An Introduction to Database Normalization,
http://dev.mysql.com/tech-resources/articles/intro-to-normalization.html● David Faour, Database Normalization,
http://www.serverwatch.com/tutorials/article.php/1549781