0% found this document useful (0 votes)
12 views24 pages

Database 4

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views24 pages

Database 4

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 24

Relational Database Modeling and

Normalization
Agenda
1 Title Slide
2 Introduction to Relational Database Modeling
3 Components of a Relational Model
4 Entity-Relationship (ER) Diagram
5 Database Normalization
6 The Normalization Process
7 Example: Normalizing a Construction Project Database
8 Importance of Normalization in the Construction Industry
9 Trade-offs of Normalization
10 Summary
11 Questions and Discussion
12 Conclusion
Relational Database Modeling and Normalization

Photo by Marvin Meyer on Unsplash


Introduction to Relational Database Modeling
• Definition of Relational Database Modeling: This modeling approach
organizes data into two-dimensional tables (relations), each representing
a unique entity and all its relevant information, providing a structured
way to manage databases.

• Structure and Interconnections: Relational databases use primary and


foreign keys to establish connections between tables, facilitating data
retrieval and integrity across various datasets—critical for complex
operations.

• Key Concepts: Understanding entities as real-world objects, attributes


as their descriptive characteristics, and relations as the organizational
format of data is fundamental for effective modeling.

Photo by Hanna Morris on Unsplash


Components of a Relational Model

Tables (Relations) Primary Key


The primary structure in a relational database, where data is systematically An essential element that uniquely identifies each record in a table, ensuring
organized in rows and columns, assisting in structured data management. that no duplicate entries exist and enabling precise data retrieval.

Foreign Key Types of Relationships


A crucial component that links one table to another, establishing relationships Understanding the nature of relationships (1:1, 1:M, M:N) between different
and enabling the joining of data across different tables within the database. entities is vital for effective data structuring and retrieval in complex databases.
Entity-Relationship (ER) Diagram
Definition of an ER Diagram Components of ER Diagrams Example ER Diagram
A visual representation that illustrates entities in a Key elements to be represented in ER diagrams A practical depiction of a construction project
database, their attributes, and the relationships include entities (rectangles), attributes (ovals), and database, showcasing how different entities, such
among them, aiding in understanding and relationships (diamonds), which collectively as Projects, Contractors, and Materials, interact
designing a relational structure. convey the database schema. within the system.
Database Normalization

Definition and Purpose Process of Normalization Benefits of Normalization


Normalization refers to the systematic approach of A multi-step process that includes assessing data The primary advantages include reducing data
organizing data in a database to minimize structures, identifying redundancies, and duplication, ensuring consistency and integrity, and
redundancy and enhance data integrity, creating a implementing changes to organize data efficiently optimizing database performance for swift data
more efficient data structure. within tables. access and querying.
The Normalization Process
1st Normal Form (1NF) 2nd Normal Form (2NF) 3rd Normal Form (3NF)
Ensures that all columns contain atomic data, and Focuses on removing partial dependencies, Eliminates transitive dependencies, ensuring that
eliminates repeating groups, laying the groundwork ensuring that all non-key attributes depend on the non-key attributes are only dependent on the
for further normalization. entire primary key, which is critical for multi- primary key, thus enhancing data structure
column primary keys. reliability.
Example: Normalizing a Construction Project Database

Unnormalized Table 1NF Example


An initial table housing complex project, contractor, and material data all in one Demonstrating adherence to 1NF by ensuring atomicity and breaking down
location, leading to data redundancy and inefficiencies. repeating groups for clearer data presentation.

2NF Example 3NF Example


Identification of partial dependencies leading to the creation of new tables— Establishment of distinct tables ensuring that all non-key attributes are
such as Projects, Contractors, and Materials—facilitating direct data optimally organized, enhancing both clarity and data management.
relationships.
Problem: Normalizing a Construction Project Database
You are given an unnormalized table that tracks details of ongoing construction projects. The table stores project
details, contractors assigned, materials used, and tasks completed. The structure of the table is as follows:
Task: Normalize this table up to 3rd Normal Form (3NF).

Project Contractor Contractor Material Material Material


Project ID Task Name Task Deadline
Name Name Phone Used Supplier Cost
ABC
Mall 123-456- CementCo Foundation
101 Construction Concrete $5,000 May 15, 2024
Expansion 7890 Ltd. Work
Co.
Mall BuildFast 987-654- Steel IronWorks Structural
101 $12,000 August 1, 2024
Expansion Solutions 3210 Beams Inc. Framing
Build
Residential Elite Builders 555-987- Cement
102 Supplies $7,500 Groundwork June 1, 2024
Complex Inc. 6543 Blocks
Ltd.
Residential Elite Builders 555-987- Roofing Roof Tech Electrical November 15,
102 $4,500
Complex Inc. 6543 Sheets Inc. Installation 2024

10
Step 1: First Normal Form (1NF)
In 1NF, we eliminate repeating groups and ensure that each field contains atomic (indivisible) values.
•The table is already in 1NF because there are no repeating groups, and each field contains atomic values.

11
Step 2: Second Normal Form (2NF)
In 2NF, we remove partial dependencies. A partial dependency occurs when a non-primary key attribute
depends on only part of the composite primary key.
The primary key in this table would be the combination of Project ID and Task Name, but we have non-key
attributes that depend on only Project ID (e.g., Contractor Name and Contractor Phone). We need to separate
these into their own tables.
New Tables for 2NF:

1.Projects Table :
Project ID Project Name
101 Mall Expansion
102 Residential Complex

2. Contractors Table:
Contractor Name Contractor Phone
ABC Construction Co. 123-456-7890
BuildFast Solutions 987-654-3210
Elite Builders Inc. 555-987-6543

12
Step 2: Second Normal Form (2NF)
In 2NF, we remove partial dependencies. A partial dependency occurs when a non-primary key attribute
depends on only part of the composite primary key.
The primary key in this table would be the combination of Project ID and Task Name, but we have non-key
attributes that depend on only Project ID (e.g., Contractor Name and Contractor Phone). We need to separate
these into their own tables.

3. Materials Table:

Material Used Material Supplier Material Cost


Concrete CementCo Ltd. $5,000
Steel Beams IronWorks Inc. $12,000
Cement Blocks Build Supplies Ltd. $7,500
Roofing Sheets Roof Tech Inc. $4,500

13
Step 2: Second Normal Form (2NF)
In 2NF, we remove partial dependencies. A partial dependency occurs when a non-primary key attribute
depends on only part of the composite primary key.
The primary key in this table would be the combination of Project ID and Task Name, but we have non-key
attributes that depend on only Project ID (e.g., Contractor Name and Contractor Phone). We need to separate
these into their own tables.

4. Tasks Table:

Project ID Task Name Task Deadline


101 Foundation Work May 15, 2024
101 Structural Framing August 1, 2024
102 Groundwork June 1, 2024
102 Electrical Installation November 15, 2024

14
Step 3: Third Normal Form (3NF)
In 3NF, we eliminate transitive dependencies. A transitive dependency exists when a non-key attribute depends
on another non-key attribute.
•The Contractor Phone depends on the Contractor Name, not the Project ID, so it is already separated into its
own table in 2NF.
•The Material Supplier and Material Cost depend on Material Used, not on the Project ID or Task Name.
Since the non-key attributes are properly placed in their own tables, the database is now in 3NF.

15
Final Tables:
Projects Table:

Project ID Project Name


101 Mall Expansion
102 Residential Complex

1 0 /8 /2 4 S A M P L E F O O T E R T E X T 16
Final Tables:
Contractors Table:
Contractor Name Contractor Phone
ABC Construction Co. 123-456-7890
BuildFast Solutions 987-654-3210
Elite Builders Inc. 555-987-6543

Materials Table:

Material Used Material Supplier Material Cost


Concrete CementCo Ltd. $5,000
Steel Beams IronWorks Inc. $12,000
Cement Blocks Build Supplies Ltd. $7,500
Roofing Sheets Roof Tech Inc. $4,500

1 0 /8 /2 4 S A M P L E F O O T E R T E X T 17
Final Tables:
Tasks Table:
Project ID Task Name Task Deadline
101 Foundation Work May 15, 2024
101 Structural Framing August 1, 2024
102 Groundwork June 1, 2024
102 Electrical Installation November 15, 2024

Project-Contractor Relationship Table:


Project ID Contractor Name
101 ABC Construction Co.
101 BuildFast Solutions
102 Elite Builders Inc.

1 0 /8 /2 4 S A M P L E F O O T E R T E X T 18
Final Tables:
Project-Material Relationship Table:
Project ID Material Used
101 Concrete
101 Steel Beams
102 Cement Blocks
102 Roofing Sheets
Importance of Normalization in the Construction
Industry
• Consistency and Accuracy: In construction, maintaining accurate
project data is critical, as it influences decision-making across various
stakeholders; normalization aids in ensuring this consistency.

• Scalability: As project scopes grow, the ability to efficiently manage an


expanding database becomes crucial; a normalized structure supports
scalable data growth without redundancy.

• Efficiency in Querying: With properly normalized data, queries can be


executed promptly and accurately, enhancing the speed of information
retrieval and report generation.

Photo by Luke Chesser on Unsplash


Trade-offs of Normalization
• Advantages: Normalization is conducive to eliminating redundancy,
thereby improving data integrity and simplifying updates—all crucial for
maintaining data quality.

• Challenges: However, over-normalization may lead to complex query


structures with excessive joins, potentially diminishing performance and
complicating database design.

Photo by Ray Reyes on Unsplash


Summary
• Key Concepts of Relational Database Modeling: Thorough
understanding of how to organize and link data effectively is paramount
to successful database design.

• Normalization Benefits: It ensures data integrity, reduces redundancy,


and enhances overall database performance, leading to improved
scalability and reliability.

• Efficient Databases: Applying principles of relational modeling and


normalization contributes to crafting databases that perform well with
changing data volumes, particularly in data-rich industries.

Photo by Lukas Blazek on Unsplash


Questions and Discussion
• Engagement with Real-World Applications: Encouraging participants to
share their experiences or challenges faced when implementing
normalization principles in practical scenarios.

• Challenges in Normalization: Opening up discussions on potential


hurdles and misconceptions that can arise during the normalization
process, especially in complex datasets.

Photo by Amélie Mourichon on Unsplash


Conclusion

You might also like