View on GitHub

reading-notes

Hello, My name Emran Aloul, I'm a mechanical engineer, I like to technical work and to have the ability to build or create something, This page includes the reading summarization we have in the daily reading assignments for 102, and certain folder for the reading notes for 201

DATABASE NORMALIZATION

What is Normalization?

Database Normal Forms

Here is a list of Normal Forms

Note: The Theory of Data Normalization in SQL is still being developed further. For example, there are discussions even on 6th Normal Form. However, in most practical applications, normalization achieves its best in 3rd Normal Form. The evolution of Normalization theories is illustrated below-

image

Database Normalization With Examples

Database Normalization Example can be easily understood with the help of a case study. Assume, a video library maintains a database of movies rented out. Without any normalization, all information is stored in one table as shown below.

img

Here you see Movies Rented column has multiple values. Now let’s move into 1st Normal Forms:

1NF (First Normal Form) Rules

1NF Example

img

What is a KEY?

A KEY is a value used to identify a record in a table uniquely. A KEY could be a single column or combination of multiple columns

What is a Primary Key?

A primary is a single column value used to identify a database record uniquely.

It has following attributes

What is Composite Key?

A composite key is a primary key composed of multiple columns used to identify a record uniquely

In our database, we have two people with the same name Robert Phil, but they live in different places.

img

Hence, we require both Full Name and Address to identify a record uniquely. That is a composite key.

2NF (Second Normal Form) Rules

It is clear that we can’t move forward to make our simple database in 2nd Normalization form unless we partition the table above.

img

img

We have divided our 1NF table into two tables viz. Table 1 and Table2. Table 1 contains member information. Table 2 contains information on movies rented.

Database - Foreign Key

In Table 2, Membership_ID is the Foreign Key

img

Foreign Key references the primary key of another Table! It helps connect your Tables

img

Why do you need a foreign key?

Suppose, a novice inserts a record in Table B such as

img

3NF (Third Normal Form) Rules

img

img

img

We have again divided our tables and created a new table which stores Salutations.

There are no transitive functional dependencies, and hence our table is in 3NF

In Table 3 Salutation ID is primary key, and in Table 1 Salutation ID is foreign to primary key in Table 3