DBMS Unit 3 Notes
DBMS Unit 3 Notes
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.
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