24

Normalisation and anomalies

Embed Size (px)

Citation preview

Page 1: Normalisation and anomalies
Page 2: Normalisation and anomalies

Disclaimer: This presentation is prepared by trainees of baabtra as a part of mentoring program. This is not official document of baabtra –Mentoring PartnerBaabtra-Mentoring Partner is the mentoring division of baabte System Technologies Pvt . Ltd

Page 3: Normalisation and anomalies

Title of the presentation

Shajeer [email protected]/shajeertwitter.com/shajeer_pkin.linkedin.com/in/

[email protected]

Page 4: Normalisation and anomalies

Normalization and Anomalies

Page 5: Normalisation and anomalies

ANOMALIES

• Tables that have redundant data have problems known as anomalies. So data redundancy is a cause of an anomaly.

• Redundancy is the duplication of the data.

Page 6: Normalisation and anomalies

There are 3 types of anomalies

1: Insert Anomaly: When you insert a record without having it stored on the related record

2: Delete Anomaly: When you delete some information and lose valuable related information at the same time.

3: Update Anomaly: Any change made to your data will require you to scan all records to make the changes multiple time.

Page 7: Normalisation and anomalies

Insert anomaly

• An Insert Anomaly occurs when certain attributes cannot be inserted into the database without the presence of other attribute

Page 8: Normalisation and anomalies

E.g.,Course _no Tutor Room Room_size En_limit353 Smith A532 45 40351 Smith C320 100 60355 Clark H940 400 300456 Turner H940 400 45

e.g. we have built a new room (e.g. B123) but it has not yet been timetabled for any courses or members of staff.

Page 9: Normalisation and anomalies

Delete Anomaly

• A Delete Anomaly exists when certain attributes are lost because of the deletion of other attributes.

Page 10: Normalisation and anomalies

E.g.;Course _no Tutor Room Room_size En_limit353 Smith A532 45 40351 Smith C320 100 60355 Clark H940 400 300456 Turner H940 400 45

e.g. if we remove the entity, course_no:351 from the above table, the details of room C320 get deleted. Which implies the corresponding course will also get deleted.

Page 11: Normalisation and anomalies

Update Anomaly

• An Update Anomaly exists when one or more instances of duplicated data is updated, but not all.

Page 12: Normalisation and anomalies

E.g.;Course _no Tutor Room Room_size En_limit353 Smith A532 45 40351 Smith C320 100 60355 Clark H940 400 300456 Turner H940 400 45

e.g. Room H940 has been improved, it is now of RSize = 500. For updating a single entity, we have to update all other columns where room=H940.

Page 13: Normalisation and anomalies

Normalization will help us to remove the Anomaly and create good database

Page 14: Normalisation and anomalies

Normalization• Normalization is the process of putting things right, making them normal. In

a relational database the term has a specific mathematical meaning having to do with separating elements of data - names, addresses - into affinity groups, and defining the normal or right relationships between them.

• This is database design technique which organizes tables in a manner that reduces redundancy and dependency of data(That means avoid anomaly)

• Normalization is ‘standardized’ rule for making database

Page 15: Normalisation and anomalies

1st Normal Form ,Requirements

• The requirements to satisfy the 1st NF:– Each table has a primary key: minimal set of

attributes which can uniquely identify a record– The values in each column of a table are atomic

(No multi-value attributes allowed).– There are no repeating groups: two columns do

not store similar information in the same table.

Page 16: Normalisation and anomalies

1st Normal For ExampleUn-normalized Students table:

Student#

AdvID

AdvName

AdvRoom

Class1

Class2

123 123A James 555 102-8 104-9124 123B Smith 467 209-0 102-8Normalized Students table:Student#

AdvID

AdvName

AdvRoom

Class#

123 123A James 555 102-8123 123A James 555 104-9124 123B Smith 467 209-0124 123B Smith 467 102-8

Page 17: Normalisation and anomalies

2nd Normal Form ,Requirements

• The requirements to satisfy the 2nd NF:– All requirements for 1st NF must be met.– Redundant data across multiple rows of a table

must be moved to a separate table.• The resulting tables must be related to each

other by use of foreign key.

Page 18: Normalisation and anomalies

2nd Normal For ExampleStudents table:Student# AdvID AdvName AdvRoom123 123A James 555124 123B Smith 467

Registration table:Student#

Class#

123 102-8123 104-9124 209-0124 102-8

Page 19: Normalisation and anomalies

3rd Normal Form ,Requirements

• The requirements to satisfy the 3rd NF:– All requirements for 2nd NF must be met.– Eliminate fields that do not depend on the primary

key;• That is, any field that is dependent not only

on the primary key but also on another field must be moved to another table.

Page 20: Normalisation and anomalies

3rd Normal Form ExampleStudents table

Advisor table:

AdvID AdvName

AdvRoom

123A James 555123B Smith 467

Student#

AdvID

123 123A124 123B

Student# Class#123 102-8123 104-9124 209-0124 102-8

Registration table:

Page 21: Normalisation and anomalies

Conclusion

• We have seen how Database Normalization can decrease redundancy, increase efficiency and reduce anomalies by implementing three of seven different levels of normalization called Normal Forms. The first three NF’s are usually sufficient for most small to medium size applications.

Page 22: Normalisation and anomalies

Thanks

Page 23: Normalisation and anomalies

Contact Us

Emarald Mall (Big Bazar Building)Mavoor Road, Kozhikode,Kerala, India.Ph: + 91 – 495 40 25 550

NC Complex, Near Bus StandMukkam, Kozhikode,Kerala, India.Ph: + 91 – 495 40 25 550

Start up VillageEranakulam,Kerala, India.

Email: [email protected]

Page 24: Normalisation and anomalies

If this presentation helped you, please visit our page facebook.com/baabtra and like it.

Thanks in advance.

www.baabtra.com | www.massbaab.com |www.baabte.com