Saturday, July 22, 2017

Data modeling - Normalization


This time we will see how basic database model  looks like and  how robust is 3-Normalized form over unNormalized ones.
Anything less than 3NF can cost in the form of data anomalies that 3NF is supposed to protect.


To keep things simple and concise, we will understand this by creating un-normalized entities and normalized form of "Hotstar", a digital and mobile entertainment platform.

Hotstar is an online media streaming platform where users can watch movies, tv series etc. after paying a subscription fee in monthly, biyearly or yearly.
After subscription, user can watch any sort of media available over there at hotstar.

here we have tried to present a basic data model of hotstar to understand the difference between unNormalized form and Normalized form.

                                            Hotstar - Online streaming platform

 Let's first identify primary key, we have email ID has unique identifer but does it work , if
same user uses free plan with that ID ,later say after a while switch to premium plan or multiple plans,
so our Primary id will be "Email ID + subscription date-time", because content depends on subscription
plan.


After identifying primary key, let's bring it into 1NF form.1NF - Requirement :   NO repeating group, split them into groups.













































1NF to 2- NF 

2 - NF requirement : 

No partial key dependency, all non key attributes should depend on primary key as a whole

                                                      .

























                                            












3 NF violation and solutions


3NF requirement :

No non-key interdependencies.
If some non-keys depend on other non-key, bring them out in other table.


    2 Normalized form                                                        3 Normalized form                                                  









Finally, our final representation of data model from unNormalized form to Normalized form!!




                   


In above model, if you see unNormalized form, there lies some hidden issues,
1. Redundancy
2. Suppose if customers do not watch any TV series, then we won't have TV series data since there won't be any entry for that which is a confounding issue.
3. More and more database grows, more complexity will be there because of the lack of well defined  model and so on.

Here comes, 3-NF to rescue us from this problem.
1. well defined
2. Clear and concise relationship between entity.
3. No data lost.

A good database model always caters for the perfectly defined entities and within entities, a clear dependency of non-key attributes over key attribute.


Happy learning!!!!!











No comments:

Post a Comment

5 States data in geoChart