What is a View? How it is Related to Data Independence in DBMS?
Last Updated :
11 Jun, 2024
In DBMS, View is a virtual table that is created using specific rows of one more table. View does not create a new table with these entries, it only presents the selected rows together. Views are used to hide sensitive information from users. Views are used to display the information that is needed by the user, all other information that is sensitive or useless is hidden and not displayed in the view.
How to create the view?
A view can be created using the following Syntax
CREATE VIEW view_name AS SELECT column1, column2, ...FROM table_name WHERE condition.
Syntax for accessing the view is
SELECT * FROM view_name;
Example
Let's create a Table of students with three attributes i.e. Roll_No, Marks, and Phone_Number. The query for this will be:
CREATE TABLE Students (
Roll_No INT PRIMARY KEY,
Marks INT,
Phone_Number VARCHAR(15)
);Let's insert a few records into the table. The query for this will be
INSERT INTO Students (Roll_No, Marks, Phone_Number)
VALUES
(1, 85, '1234567890'),
(2, 90, '0987654321'),
(3, 78, '1122334455'),
(4, 92, '5566778899'),
(5, 87, '6677889900');
We will display the table with the following query
SELECT * from Students;
- The table will look like below
Table Students
- Now we want to display the result but we do not want to expose the Phone_Number. So here we will create a view displaying Roll_No and Marks only.
- The query for this will be as below:
CREATE VIEW Results AS
SELECT Roll_No, Marks
FROM Students;
- To display the view, the query will be
SELECT * FROM Results;
- The view will look like below:
View ResultsData Independence in DBMS
Data independence is used for the separation of the data from various application that needs the same data. In other words, it helps to change the database schema at one level of the system without affecting the database schema at other levels of the system. It is used to provide a clear separation of data between multiple applications.
Data independence is of mainly 2 types
1. Logical Data Independence
- As the name suggests, the logical schema of the data is modified and it does not affect the physical structure of the data. The view of the data will be retained as it is but the logical level of retrieving the data will be modified.
- It refers to adding new fields, changing the data types redefining the relations between the entities, and many more. For example, adding a new column to the table or combining/merging the 2 tables.
2. Physical Data Independence
- It mainly refers to the changing the physical level of data but the logical level schema is retained as it is.
- There is change only in how data will be displayed but the logic of retrieving or accessing the data will be retained as it is.
- Changing file indexes, changing the structures of files, or using different storage devices can be included in physical data independence.
How View is related to data independence in DBMS
Views help in obtaining data freedom from a Database Management System (DBMS) when acting as an abstraction layer between the physical storage of data by the users or applications that touch this data. This is how views enhance both physical and logical data independence:
1. Logical Data Independence
Abstraction of Complex Queries:
- Views are an interface that makes it easier for users to understand complicated queries. We can adjust view definitions without changing the applications utilizing them once the fundamental schema is altered (such as modification to table structures or addition/deletion of some columns).
- For instance, new columns can be introduced to the tables or the current ones rearranged, but this will only require updating the view definitions, leaving the applications intact as originally developed without any modifications.
Uniform Interface:
- Views give you a way to retrieve data that won't be affected by changes in the underlying schema of a database; therefore we can say that this makes them constant.
- Illustration: In case your application reads data via a view and then your database administrator chooses to create two new tables from that one (all in the name of making the system better), the view may be modified to include such action. The user has no idea that the view is accessed by the application despite the structural change
2. Physical Data Independence
Hiding Physical Storage Details:
- The data's physical storage details can be hidden from views, and physical storage details of the data can be abstracted by views. Change in the way actual data retrieval and storage mechanisms (e.g., indexing, file storage format) are done does not necessarily mean that users and applications will stop accessing the data through views.
- Example: If the indexing strategy for performance is modified by the database administrator, changes may occur in the underlying tables but not the view, thus maintaining an interface for applications.
Helping Changes in Physical Storage:
- A physical transformation like moving information among storage drives or varying the physical organization of data (eg partitioning tables) does not have any effect on views. Views keep a level of generalization that protects users from such changes.
- Example: Switching from heap storage to clustered storage format for tables doesn’t influence a view thus the applications using it remain as they were.
Conclusion
To summarize, views are powerful tools in DBMS that provide a method for displaying specific records in one or more tables without needing a separate table. Security problems are avoided with them. Data integrity is thereby maintained by them since there is a simplified interface from which information can be easily accessed that people need. Another way that they ensure data consistency is by decoupling between the type of data stored in the database and how it is stored
Similar Reads
What is Data Independence in DBMS?
Data independence is a property of a database management system by which we can change the database schema at one level of the database system without changing the database schema at the next higher level. In this article, we will learn in full detail about data independence and will also see its ty
5 min read
What is Record-at-a-Time in DBMS?
A database management system (DBMS) is a software system that is used to manage databases. In a database management system, there are various approaches to accessing the data from the databases. Record-at-a-time is one of the approaches in database management systems. Record-at-a-time is a processin
5 min read
What is Data Inconsistency in DBMS?
The database is the collection of structured records that are used in various scenarios to gain useful insights, perform CRUD operations, and many other things. The data stored in the Database is in the form of rows and columns, we mostly call them as records. There are various tables that store and
4 min read
Physical and Logical Data Independence
1. Physical Data Independence : Physical Data Independence is defined as the ability to make changes in the structure of the lowest level of the Database Management System (DBMS) without affecting the higher-level schemas. Hence, modification in the Physical level should not result in any changes in
2 min read
What are the design schemas of data modelling?
The global enterprise data management market is predicted to grow at a compound annual growth rate of 12.1% until 2030. This growth underscores the importance of effective data management strategies in organizations. A critical component of this strategy is the database management system (DBMS), whi
4 min read
Differences between Views and Materialized Views in SQL
When working with databases, views and materialized views are important tools for managing data effectively. Both have their unique characteristics, advantages and use cases. Understanding the differences can help us choose the best option for our requirements. In this article, we will cover detaile
4 min read
What is Relationship in DBMS?
A database is a structured data set that is usually electronically written in a computer system and stored as data. With their primary purpose being to maintain, keep, and extract data correctly, databases are important. In many practical situations, data is never an isolated file, and its correlati
5 min read
What is Relationship Set in DBMS?
Relationship set in a Database Management System (DBMS) is essential as it provides the ability to store, recover, and oversee endless sums of information effectively in cutting-edge data administration, hence making a difference in organizations. In a Relational database, relationship sets are buil
4 min read
Difference Between Row oriented and Column oriented data stores in DBMS
Databases are essential for managing and retrieving data in a variety of applications, and the performance of these systems is greatly influenced by the way they store and arrange data. The two main strategies used in relational database management systems (RDBMS) are data stores that are row-orient
6 min read
Difference between Physical and Logical Data Independence
Data Independence therefore refers to the nature whereby one can change the structure of the database without having to change its implementation or data. There are two types of data independence: The first type is the Physical one as well as the second type is the Logical one. As will be seen, both
6 min read