What is a Database View, A view can join information from several tables together, or we can say that Views are useful for Hiding unwanted information for example adding the ename field to the Order information. Database View is a subset of the database sorted and displayed in a particular way. A database view displays one or more database records on the same page. A view can display some or all of the database fields.
Views have filters to determine which records they show. Views can be sorted to control the record order and grouped to display records in related sets. Views have other options such as totals and subtotals. A query returns information from a table or set of tables that matches particular criteria.
Most users interact with the database using the database views. A key to creating a useful database is a well-chosen set of views. Luckily, while views are powerful, they are also easy to create. Create custom views of a database to organize, filter and sort records.
Database views allow you to easily reduce the complexity of the end user experience and limit their ability to access data contained in database tables by limiting the data presented to the end user. Essentially, a view uses the results of a database query to dynamically populate the contents of an artificial database table.
You can use views to:
1. Focus on the data that interests them and on the tasks for which they are responsible. Data that is not of interest to a user can be left out of the view.
2. Define frequently used joins, projections, and selections as views so that users do not have to specify all the conditions and qualifications each time an operation is performed on that data.
3. Display different data for different users, even when they are using the same data at the same time. This advantage is particularly important when users of many different interests and skill levels share the same database.
Advantages:
1. Provide additional level of table security by restricting access to a predetermined set of rows or columns of a table.
2. Hide Data complexity: For example, a single view might be defined with a join, which is a collection of related columns or rows in multiple tables. However, the view hides the fact that this information actually originates from several tables.
3. Simplify Statements for User: Views allow users to select information from multiple tables without actually knowing how to perform join.
4. Present Data in different perspective: Columns of views can be renamed without effecting the tables on which the views are based.
5. Isolate applications from changes in definitions of base tables. If a view is referencing three columns of a four columns table, if a fifth column is added or fourth column is changed, the view and associated applications are un-affected.
6. Express query that cannot be expressed without using a view. For example, a view can be defined that joins a group by view with a table or a view can be defined that joins a UNION view with a table.
7. Saving of complex queries.
Disadvantages:
1. Rows available through a view are not sorted and are not ordered either.
2. Cannot use DML operations on a View.
3. When table is dropped view becomes inactive, it depends on the table objects.
4. It affects performance, querying from view takes more time than directly querying from the table.