This content originally appeared on DEV Community and was authored by hebaShakeel
Normalization: It is a way to reduce/minimize data redundancy (repetition of data). It can be achieved by splitting the table into many tables.
First Normal Form (1NF):
-> It is the property of converting ER Diagram into the Relational Database.
-> The Relational Database is implicitly in 1NF.
-> All attributes should be atomic [ only one value in a tuple is allowed].
Example
Here, SMobile has multiple values which are not allowed. They have to be taken individually.
Approach-1
This approach creates a lot of redundancy in the table. Therefore it is not a suitable approach.
Approach-2
This approach also has redundancy but less when compared to the previous Approach. This is because the tables have now been split into two.
Prime Attributes(Key):
Those attributes which participate in the Candidate key.
Example 1
R(ABCD), CKs: {A, BD}
Therefore PA = {A,B,D}
Example 2
R(ABCDEFG), CKs: {AB, BC, CD, F}
Therefore PA = {A,B,C,D,F}
Non-Prime Attributes(Non-Key):
Those attributes which do not participate in Candidate Key.
Example 1
R(ABCD), CKs: {A, BD}
Therefore NPA = {C}
Example 2
R(ABCDEFG), CKs: {AB, BC, CD, F}
Therefore NPA = {E,G}
Partial Dependency:
If subset of any Candidate Key derives a non-key attribute.
Example
R(ABCD) FDs : {AB->CD, B->D}
CK => {AB}
B->D, B is a subset of AB and it derives non-key, therefore it is a partial dependency.
Second Normal Form (2NF):
=> If a relation 'R' is in 1NF (and)
=> If every non-prime attribute is fully dependent on any complete CK (or) No Partial Dependency exists.
Allowed in 2NF:
=> Non-Prime determines Non-Prime
=> Non-Prime determines Prime
=> Prime determines Prime
Not-Allowed in 2NF:
=> Prime determines Non-Prime
This content originally appeared on DEV Community and was authored by hebaShakeel
hebaShakeel | Sciencx (2021-06-14T18:17:24+00:00) 1NF and 2NF. Retrieved from https://www.scien.cx/2021/06/14/1nf-and-2nf/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.