What is the significance of using the views? Write a command to create the view.


Q.) What is the significance of using the views? Write a command to create the view.

Subject: Data Base Management System

Introduction

In Database Management System (DBMS), a view is a virtual table based on the result-set of an SQL statement. It contains rows and columns, just like a real table. The fields in a view are fields from one or more real tables in the database. A view can be thought of as a stored query or a virtual table where the data does not physically exist. It is used to implement the security mechanism in the DBMS.

Significance of Using Views

Simplification of Complex Queries

Views can simplify the structure of complex queries. When you have a complex query that is used repeatedly, it is easier and more efficient to create a view of that query. Once the view is created, it can be referenced like a table in SQL queries, making the query syntax simpler and easier to understand.

For example, consider a complex query that joins three tables to provide a report on employee performance. Instead of writing the join query every time the report is needed, a view can be created for the join query. Then, the view can be referenced in future queries, simplifying the SQL syntax.

Data Security

Views provide an additional level of table security. They can be used to restrict the level of access that users have to the underlying database tables. A view can be created that selects certain columns from the table, and users can be granted access to the view instead of the full table. This ensures that users only have access to the specific data they need.

For example, a view can be created that only shows the employee name and performance rating from the employee table. If a user is granted access to this view, they will not be able to see other information in the employee table, such as salary or home address.

Data Abstraction

Views provide a level of abstraction from the underlying tables. They can hide the complexity of data in a database, including complex join operations or calculations, from users. Users can query the view without knowing the details of how the data is stored or managed.

For example, a view can be created that provides the total sales for each product category. The view might join several tables and perform calculations to provide this data. However, a user querying the view does not need to know these details.

Consistency of Data

Views ensure the consistency of data. When a view is created, it can be used in multiple queries. If the underlying data changes, the view will automatically reflect these changes. This ensures that all queries using the view will return consistent results.

For example, if a view is created that shows the total sales for each product category, and later the sales data is updated, the view will automatically reflect these changes. Any queries that use the view will return the updated total sales.

Command to Create a View

The syntax to create a view in SQL is as follows:

CREATE VIEW view_name AS
SELECT column1, column2, ...
FROM table_name
WHERE condition;

In this syntax:

  • CREATE VIEW is the SQL command to create a view.
  • view_name is the name of the view.
  • SELECT column1, column2, ... is the SELECT statement that defines the view.
  • FROM table_name specifies the table that the view is based on.
  • WHERE condition is an optional condition that can be applied to the view.

Here is an example of a command to create a view:

CREATE VIEW EmployeePerformance AS
SELECT EmployeeName, PerformanceRating
FROM Employee;

This command creates a view named EmployeePerformance that shows the employee name and performance rating from the employee table.

Conclusion

In conclusion, views in DBMS are significant for simplifying complex queries, enhancing data security, providing data abstraction, and ensuring consistency of data. Understanding how to create and use views is important for efficient and secure database management.

Diagram: Not necessary for this answer.

Summary

Views in DBMS are significant for simplifying complex queries, enhancing data security, providing data abstraction, and ensuring consistency of data. They can simplify the structure of complex queries, restrict access to specific data, hide the complexity of data, and automatically reflect changes in the underlying data. To create a view, use the CREATE VIEW command followed by the view name, SELECT statement, and optional condition.

Analogy

Views in DBMS can be compared to virtual tables that provide a simplified and secure way to access and manipulate data, similar to how a virtual reality headset provides a simulated environment for users to interact with.

Quizzes
Flashcards
Viva Question and Answers

Quizzes

What is the purpose of using views in DBMS?
  • To simplify complex queries
  • To enhance data security
  • To provide data abstraction
  • To ensure consistency of data
  • All of the above