DB Design using Normalization

Designing a database using normalization involves applying a series of steps to organize the data into well-structured tables with minimal redundancy and improved data integrity. There are several normal forms (1NF, 2NF, 3NF, BCNF, etc.), each building upon the previous one.

Let’s walk through the process of database design using normalization up to the Third Normal Form (3NF):

Step 1: Identify Entities and Attributes:

Identify the entities (real-world objects or concepts) and their attributes (properties or characteristics).

For example, consider a database for a library with entities like Book, Author, and Publisher. The attributes for each entity would include information such as BookID, Title, AuthorID, Name, PublisherID, and Name.

Step 2: Create the Initial Unnormalized Table:

Combine all the identified attributes into one table without concern for normalization.

The initial unnormalized table might look like this:

Books (BookID, Title, AuthorID, AuthorName, PublisherID, PublisherName, Genre, Price)

Step 3: First Normal Form (1NF):

Eliminate repeating groups and ensure atomicity of values in each field.

Separate the attributes into distinct tables, and use primary keys to uniquely identify each record.

For example:

Books (BookID, Title, AuthorID, PublisherID, Genre, Price)

Authors (AuthorID, AuthorName)

Publishers (PublisherID, PublisherName)

Step 4: Second Normal Form (2NF):

Ensure that each non-key attribute is fully dependent on the entire primary key.

If necessary, create new tables to eliminate partial dependencies.

For example:

Books (BookID, Title, AuthorID, PublisherID, Genre, Price)

Authors (AuthorID, AuthorName)

Publishers (PublisherID, PublisherName)

Assume there is a functional dependency {BookID, AuthorID} -> {AuthorName}. This indicates a partial dependency because the AuthorName depends on only part of the primary key. To resolve this, create a new table:

Book_Authors (BookID, AuthorID)

Step 5: Third Normal Form (3NF):

Ensure that each non-key attribute is not transitively dependent on the primary key.

If necessary, create new tables to eliminate transitive dependencies.

For example:

Books (BookID, Title, PublisherID, Genre, Price)

Authors (AuthorID, AuthorName)

Publishers (PublisherID, PublisherName)

Book_Authors (BookID, AuthorID)

Assume there is a functional dependency {PublisherID} -> {PublisherName}. This indicates a transitive dependency because PublisherName depends on PublisherID, which is not part of the primary key. To resolve this, create a new table:

Book_Publishers (BookID, PublisherID)

Step 6: Review and Refine:

Review the database schema to ensure that all functional dependencies are appropriately resolved, and there is no unnecessary data duplication.

Refine the database design as needed based on the specific requirements and constraints of the system.

By following these normalization steps, we have organized the data into separate tables, reducing redundancy and ensuring data integrity. The resulting database schema is now in the Third Normal Form (3NF), providing a solid foundation for data management and manipulation.

Leave a Reply

error: Content is protected !!
%d