0% found this document useful (0 votes)
3 views

DBMS Assignment 2

Normalization is a database design process that organizes data to reduce redundancy and improve integrity through stages called normal forms (NFs). Each normal form has specific rules, with higher forms reducing redundancy but potentially increasing table count. Functional dependencies are crucial for normalization, guiding table structure and ensuring data consistency.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

DBMS Assignment 2

Normalization is a database design process that organizes data to reduce redundancy and improve integrity through stages called normal forms (NFs). Each normal form has specific rules, with higher forms reducing redundancy but potentially increasing table count. Functional dependencies are crucial for normalization, guiding table structure and ensuring data consistency.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 24

Question 1:

Explain Normalization in detail.


Normalization is a systematic process in database design that organizes data to minimize
redundancy and improve data integrity. It involves dividing large tables into smaller, related
tables and defining relationships between them, typically using foreign keys. The primary
goal of normalization is to ensure that the database is efficient, maintains data consistency,
and is free from unwanted data anomalies (insertion, deletion, and update anomalies).
Normalization is generally structured in stages called normal forms (NFs), each with
specific rules and conditions. Moving from a lower normal form to a higher one reduces
redundancy but can sometimes increase the number of tables, impacting query performance.
Here’s a detailed look at each type of normal form:
1. First Normal Form (1NF)
The first level of normalization, 1NF, focuses on making data atomic and eliminating
repeating groups or arrays.
Conditions for 1NF:
• All attributes must contain only atomic (indivisible) values.
• Each attribute must contain a single value per record (no multiple values in a single
field).
• Each field in a table should contain only one type of data.

2. Second Normal Form (2NF)


The second level of normalization eliminates partial dependencies and applies only to tables
with composite primary keys (a primary key made up of multiple attributes).
Conditions for 2NF:
• The table must be in 1NF.
• All non-key attributes must be fully functionally dependent on the entire primary key,
not just part of it.

3. Third Normal Form (3NF)


Third Normal Form removes transitive dependencies, where non-key attributes depend
indirectly on the primary key via another non-key attribute.
Conditions for 3NF:
• The table must be in 2NF.
• There should be no transitive dependency, i.e., no non-key attribute should depend on
another non-key attribute.
6. Fifth Normal Form (5NF)
The fifth normal form, also called Project-Join Normal Form (PJNF), eliminates join
dependencies by ensuring no unnecessary dependencies remain.
Conditions for 5NF:
• The table must be in 4NF.
• Every join dependency must be implied by candidate keys.
Example: If an Orders table has attributes OrderID, ProductID, and SupplierID, and each
supplier might provide only certain products for an order, this can introduce a complex join
dependency. To normalize to 5NF:
• Separate into three tables: OrderProducts, OrderSuppliers, and ProductSuppliers.
Importance of Normalization
1. Reduced Redundancy: Avoids duplication of data, reducing storage space and
enhancing data integrity.
2. Improved Data Integrity: Ensures that updates, deletions, and insertions do not lead
to anomalies.
3. Efficient Querying: Although normalization can create more tables, it enhances
logical organization, making data easier to maintain and update.
Normalization is crucial for designing databases that are both efficient and consistent,
ensuring that data structures can evolve without unnecessary data duplication or integrity
issues.

Question 2:
What is BCNF? Provide the condition that a relation
must satisfy to be in a BCNF?
Question 3:
Discuss the concept of JDs. How does it relate to
Fourth Normal Form and Fifth Normal Form?
How JDs Relate to Fifth Normal Form (5NF)
What is Fifth Normal Form (5NF)?
A table is in 5NF (or Projection-Join Normal Form, PJNF) if:
1. It is in 4NF.
2. It has no non-trivial join dependencies.
Key Concept of 5NF
• While 4NF deals with decompositions involving two sub-relations (MVDs), 5NF
ensures correctness for decompositions into three or more sub-relations (complex
JDs).
Relation Between JD and 5NF
• A table violates 5NF if it can be decomposed into three or more sub-relations without
loss of information, but the table is not already in that decomposed form.
• 5NF ensures that the decomposition guided by JDs is complete and no unnecessary
redundancy remains.
Observation
• A course belongs to a department.
• An instructor teaches multiple courses.
• The course-instructor relationship is independent of the department.
Problem:
This table has redundancy because:
1. Department names are repeated for each course.
2. Multiple rows combine course-instructor pairs unnecessarily.
Key Takeaway
• 5NF ensures no redundancy caused by complex join dependencies.
• Tables are decomposed into the smallest logical sub-tables that still allow the data to
be reconstructed.

Summary
• Join Dependency (JD) ensures that a table can be split into smaller tables without
losing data.
• 4NF deals with simpler JDs (multivalued dependencies involving two sub-relations).
• 5NF extends this concept to more complex cases involving three or more sub-
relations.
Understanding JDs helps in designing databases that are efficient, free of redundancy, and
maintain data integrity!
Question 4:
Explain Functional Dependencies.
Functional Dependency
Importance of Functional Dependencies
Functional dependencies help in database normalization, which involves decomposing tables
to reduce redundancy and improve data integrity. They are crucial for defining normal
forms, such as:
1. First Normal Form (1NF): Ensures that the values in each column are atomic.
2. Second Normal Form (2NF): Eliminates partial dependencies.
3. Third Normal Form (3NF): Removes transitive dependencies.
4. Boyce-Codd Normal Form (BCNF): Every determinant must be a candidate key,
ensuring further normalization.
Functional Dependency Analysis in Database Design
During design, functional dependencies guide how tables should be structured. By identifying
dependencies:
1. We can reduce data anomalies (insertion, deletion, and update anomalies).
2. We can enhance data consistency by ensuring that data related by dependency is
properly grouped or normalized.
3. They serve as constraints, ensuring that data remains valid according to business
rules.
Functional dependencies are fundamental in maintaining database integrity and efficiency
in querying and updating data in a relational database.

Question 5:
Differentiate between Union and Intersection with
suitable example.
Question 6:
Difference between Queries and Sub-Queries.
Difference Between Queries and Sub-Queries in Databases
In database management systems, queries and sub-queries are both used to retrieve data, but
they work in different ways and have different purposes. Let’s break them down in simple
terms, then go into the details.
1. Queries (Main Queries)
A query is a request to retrieve data from a database. It is usually a standalone statement that
can fetch, update, or manipulate the data.
Key Points:
• Definition: A query is an SQL statement used to interact with the database to retrieve
or manipulate data.
• Execution: It runs independently and returns results directly.
• Types: Queries can be simple (retrieving data from a single table) or complex
(involving multiple tables and conditions).
2. Sub-Queries
A sub-query is a query that is nested inside another query. It is used to retrieve intermediate
results that can be used by the outer query. Sub-queries are placed within parentheses and
often help in filtering or processing data that cannot be handled by a single query.
Key Points:
• Definition: A sub-query is a query written inside another SQL query, often inside the
WHERE, FROM, or SELECT clause of the main query.
• Execution: The database executes the sub-query first to get its result, which is then
used by the main query.
• Purpose: Sub-queries are useful when the result of one query is needed as input for
another query. They allow more complex filtering or transformations that are difficult
to express in a single query.
• Types: Sub-queries can be:
o Single-row sub-queries: Return a single value.
o Multiple-row sub-queries: Return multiple values (like a list).
o Correlated sub-queries: Use values from the outer query.
o Non-correlated sub-queries: Independent from the outer query.
Advantages and Disadvantages

Advantages of Queries:

• Simplicity: Queries are easy to write and execute when dealing with straightforward data
retrieval.

• Performance: For simple operations, a query can be faster as it doesn’t rely on nested
calculations.

Advantages of Sub-queries:

• Complex Filtering: Sub-queries allow you to perform complex filtering and calculations that
would be difficult to express in a single query.

• Modularity: They break down complex problems into smaller, manageable parts.

Disadvantages of Sub-queries:

• Performance: Sub-queries, especially non-correlated ones, can lead to poor performance


since the inner query is executed for each row of the outer query.

• Complexity: Sub-queries can make SQL queries harder to read and maintain, especially if
they are nested deeply.

Summary

• Query: A standalone SQL command used to interact with a database. It retrieves or


manipulates data directly.

• Sub-query: A query inside another query, often used to perform intermediate calculations or
retrieve data that the outer query needs.

Use Queries when:

• You need a simple, straightforward data retrieval.

Use Sub-queries when:

• You need to use the result of one query in another query, for filtering, calculating aggregates,
or more complex conditions.

You might also like