0% found this document useful (0 votes)
17 views11 pages

DBMS Unit 3 Notes

Uploaded by

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

DBMS Unit 3 Notes

Uploaded by

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

DBMS UNIT 3

Q1. What is partial dependency and how is it different from transitive


dependency?
Partial Dependency

Partial dependency occurs when a non-prime attribute (an attribute that is


not part of any candidate key) is dependent on only a part of a candidate
key, rather than the whole key. This typically happens in tables that have a
composite primary key, which means the primary key consists of more than
one attribute. Partial dependency is a violation of the Second Normal Form
(2NF).

Example: Consider a table with a composite key consisting of StudentID and


CourseID:

StudentID CourseID CourseNam Instruct


e or
In this table, CourseName and
Instructor might depend only on
CourseID, not on the entire
composite key (StudentID,
CourseID). This partial dependency
implies that CourseName and
Instructor should be moved to a
different table where CourseID is the
primary key to achieve 2NF.
Transitive Dependency

Transitive dependency occurs when a non-prime attribute is dependent on


another non-prime attribute rather than on the candidate key. This is a
violation of the Third Normal Form (3NF). Essentially, a transitive
dependency means that a non-prime attribute depends indirectly on the
primary key through another non-prime attribute.

Example: Consider a table:

StudentID DepartmentI DepartmentNa


D me
Here, if DepartmentName is dependent
on DepartmentID (which is itself a non-
prime attribute) and DepartmentID is
dependent on StudentID, then
DepartmentName is transitively
dependent on StudentID. To resolve
this and achieve 3NF, DepartmentName
and DepartmentID should be moved to
a separate table where DepartmentID
is the primary key.
Key Differences

 Nature of Dependency: Partial dependency involves a dependency of a


non-prime attribute on a part of a composite key, while transitive
dependency involves a non-prime attribute depending on another non-
prime attribute.
 Normalization Form: Partial dependency violates 2NF, whereas
transitive dependency violates 3NF.
 Resolution: To resolve partial dependencies, you decompose tables to
ensure that non-prime attributes depend on the whole candidate key.
To resolve transitive dependencies, you decompose tables so that non-
prime attributes depend directly on candidate keys.

Understanding and resolving these dependencies are essential steps in


database normalization, which helps maintain data integrity and eliminate
redundancy.
Q2. What is view? Explain its Types with advantages and
disadvantages.
Introduction:
In database management systems (DBMS), a **view** is a virtual table that
provides a way to present data in a specific format or structure. It is derived
from one or more underlying tables (base tables) through a query, often
using the SQL `SELECT` statement. Unlike a real table, a view does not
store data physically but presents data dynamically whenever it is
accessed.

Types of Views
1. Simple View:
Description: Derived from a single table without any functions or
groupings.
- Advantages:
- Easier to create and maintain.
- Allows straightforward querying and updating.
- Disadvantages:
- Limited in functionality as it cannot handle complex queries involving
multiple tables.

2. Complex View:
-Description: Derived from multiple tables and can include functions,
joins, and groupings.
- Advantages:
- Provides a consolidated and comprehensive view of data from multiple
sources.
- Supports complex query operations.
- Disadvantages:
- More complicated to create and maintain.
- May have restrictions on updating data, depending on the complexity.

3. Materialized View:
-Description: Unlike standard views, it stores data physically. It is
periodically refreshed to update the stored data.
-Advantages:
- Faster query performance since data is stored and readily available.
- Useful for summarizing and aggregating large datasets.
-Disadvantages:
- Requires storage space for the physical data.
- Needs periodic refreshing, which can add overhead.

Advantages of Views
-Data Security: Views can restrict access to specific data by exposing only
the necessary columns and rows, thus enhancing security.
-Simplified Querying: Views simplify complex queries by encapsulating
them into a single view, making it easier for users to interact with the data.
-Data Independence: Changes to the schema of underlying tables do not
affect views, provided the changes do not alter the columns referenced in
the views.
-Consistency: Views ensure a consistent and standardized representation
of data across different applications and users.

Disadvantages of Views
-Performance Overhead: Since views are computed dynamically, they
can add overhead to query performance, especially for complex views.
-Update Limitations: Updating data through views can be restricted,
particularly in complex views involving joins or aggregations.
-Maintenance: Managing and maintaining views, especially complex and
materialized views, can be challenging and require additional administrative
effort.
-Storage: Materialized views require additional storage and resources to
manage and refresh the stored data.

In summary, views in DBMS provide a flexible and powerful way to present


and manage data. However, their use should be balanced with
considerations of performance, maintainability, and the specific needs of
the application.

Q3. Third Normal Form (3NF) and its significance.


Introduction:
Third Normal Form (3NF) is a vital concept in database design that helps
us keep our data organized and free from unnecessary repetition. To put it
simply, a table is in 3NF if it's already in Second Normal Form (2NF) and
doesn’t have any transitive dependencies. In everyday terms, this means
that every non-trivial dependency in the table should either involve a super
key or a prime attribute (part of a candidate key).
Key Points:
1.Definition of Third Normal Form (3NF):
- A relation is in 3NF if it is already in 2NF.
- It must not contain any transitive partial dependencies, meaning no non-
prime attributes are functionally dependent on other non-prime attributes.

2. Conditions for Achieving 3NF:


- For every non-trivial functional dependency \(X \rightarrow Y\):
- \(X\) must be a super key, or
- \(Y\) must be a prime attribute, i.e., part of a candidate key.

3. Significance of 3NF:
- Reduction of Data Duplication: 3NF minimizes redundant data
storage, optimizing storage space and improving data consistency.
- Enhancement of Data Integrity: By eliminating transitive
dependencies, 3NF ensures that data remains accurate and reliable.
- Prevention of Anomalies: 3NF reduces the likelihood of anomalies
such as insertion, update, and deletion anomalies, which can compromise
data integrity.
- Simplified Data Management: A database in 3NF is easier to manage
and maintain, streamlining data operations and enhancing overall
efficiency.
- Balanced Complexity: 3NF strikes a balance between reducing
redundancy and maintaining a manageable database structure, making it
suitable for diverse applications.

4. Practical Example:
- Consider a database containing employee details and department
information.
- In an unnormalized form, redundant department names may be stored
with each employee entry.
- By applying 3NF, department information can be separated into its own
table, eliminating redundancy and ensuring data integrity.

Conclusion:
In conclusion, Third Normal Form (3NF) plays a pivotal role in database
normalization, offering a structured approach to designing databases that
are efficient, scalable, and resilient to data inconsistencies. By adhering to
the principles of 3NF, database designers can create systems that optimize
data storage, enhance data integrity, and streamline data management
processes, ultimately contributing to the overall effectiveness and reliability
of the database infrastructure.
Q4. Explain Second Normal Form (2NF) with an example.
Introduction:
Second Normal Form (2NF) is a crucial concept in database normalization,
aiming to eliminate redundancy and ensure data integrity by organizing
data into logically related tables. In 2NF, a table must first satisfy the
conditions of the First Normal Form (1NF), which includes having a primary
key and atomic values in each cell.
To understand 2NF better, let's consider an example with a hypothetical
school database storing information about teachers and the subjects they
teach. Suppose we have a table named TEACHER with the following
columns: TEACHER_ID, SUBJECT, and TEACHER_AGE.
TEACHER_ID SUBJECT TEACHER_AGE
25 Chemistry 30
25 Biology 30
47 English 35
83 Math 38
83 Computer 38
In this table, TEACHER_ID serves as the primary key, uniquely identifying
each teacher. However, TEACHER_AGE is dependent on TEACHER_ID,
which violates 2NF since TEACHER_AGE is not fully dependent on the
entire primary key; instead, it is functionally dependent only on a part of it.
To bring this table into 2NF, we decompose it into two tables:
TEACHER_DETAIL and TEACHER_SUBJECT.

TEACHER_DETAIL table:
TEACHER_ID TEACHER_AGE
25 30
47 35
83 38

TEACHER_SUBJECT table:
TEACHER_ID SUBJECT
25 chemistry
25 Biology
47 English
83 Maths
83 Computer

Now, TEACHER_AGE is fully dependent on the primary key


(TEACHER_ID) in the TEACHER_DETAIL table, satisfying 2NF.
Meanwhile, TEACHER_SUBJECT table contains only attributes directly
related to subjects taught, without any redundancy.
In summary, Second Normal Form (2NF) ensures that all non-key attributes
in a table are fully functional dependent on the primary key, thereby
minimizing redundancy and potential anomalies in the database schema.

Q5. What is Boyce-Codd Normal Form (BCNF) and when is it


achieved?
Introduction:
Boyce-Codd Normal Form (BCNF) is a crucial concept in database
normalization, offering a higher level of data organization and integrity than
the Third Normal Form (3NF). It addresses specific anomalies that might
arise in databases by imposing stricter conditions on functional
dependencies within tables. Understanding BCNF and its achievement is
fundamental for designing efficient and robust database schemas.
Key Points:

1. Stricter than 3NF: BCNF serves as an advanced version of 3NF,


demanding more stringent adherence to normalization principles. While
3NF focuses on eliminating transitive dependencies, BCNF goes further by
requiring that every functional dependency within a table must have the
left-hand side (LHS) as a superkey.

2. Requirements for BCNF: Before a table can be considered to be in


BCNF, it must first fulfill the criteria of 3NF. This entails ensuring that there
are no transitive dependencies between non-prime attributes. Additionally,
for BCNF, every functional dependency \(X \rightarrow Y\) in the table must
have \(X\) as a superkey.

3. Superkey Dependency: The essence of BCNF lies in the concept of


superkey dependency. A superkey is a set of attributes within a table that
uniquely identifies each row. In BCNF, every determinant (LHS of a
functional dependency) must be a superkey. This ensures that the table is
structured in such a way that it minimizes redundancy and preserves data
integrity.

4. Achieving BCNF: BCNF is achieved when a table meets both the


requirements of 3NF and the additional condition of superkey dependency
for every functional dependency. This implies that the table has been
meticulously organized to eliminate certain types of anomalies, such as
insertion, deletion, and modification anomalies, thus enhancing the
efficiency and maintainability of the database.
Conclusion:
In summary, BCNF represents a pinnacle in the normalization process,
offering a robust framework for designing database schemas that prioritize
data integrity and efficiency. By adhering to the principles of BCNF and
ensuring that every functional dependency is based on a superkey,
database designers can create structures that minimize redundancy and
maintain consistency, ultimately facilitating effective data management.

You might also like