View

Definition - What does View mean?

A view is a subset of a database that is generated from a query and stored as a permanent object. Although the definition of a view is permanent, the data contained therein is dynamic depending on the point in time at which the view is accessed.

Views represent a subset of the data contained in a table. They can join and simplify multiple tables into one virtual table. They take up very little storage space because the database contains only the view definition, not the data. Furthermore, they can provide results for different calculations (like sum and average) along with the stored data, and can limit the degree to which tables are exposed to the outer world.

Techopedia explains View

A view is simply a structured query language (SQL) query stored as an object. For instance, the CUSTOMER_MASTER and ACCOUNTS_MASTER tables in the relational database of a commercial bank are frequently queried for customers and their account numbers. The following SQL query returns first name, surname, account number(s) and account types of customers:

SELECT c.first_name, c.surname, a.account_number, a.account_type
FROM customer_master c, accounts_master a
WHERE c.customer_id=a.customer_id
ORDER BY c.surname, a.account_number

Every time this query is run, it has to be parsed and loaded into the SQL optimizer, consuming valuable time and resources. If the query is saved as a view, then these overhead activities will only be performed once at the time the view is created. A sample SQL script to create a view is given below:

CREATE VIEW customer_accounts AS
(
SELECT c.first_name, c.surname, a.account_number, a.account_type
FROM customer_master c, accounts_master a
WHERE c.customer_id=a.customer_id
ORDER BY c.surname, a.account_number
)

Views can be used in queries just as in normal tables by selecting specific columns, restricting the results using a WHERE clause, and so on. Some relational database engines even allow the data to be updated directly through the view.

This definition was written in the context of Databases.
Posted by:
How Can Analytics Improve Business Free Webinar

Connect with us

Techopedia on Linkedin
Techopedia on Linkedin
Tweat cdn.techopedia.com
Techopedia on Twitter


'@Techopedia'
Sign up for Techopedia's Free Newsletter!
Techwise Webinar Series
How Can Analytics Improve Business?
Register for this episode of TechWise to learn from two of the most experienced analysts in the business: Dr. Robin Bloor, Chief Analyst of The Bloor Group, and Dr. Kirk Borne, Data Scientist, George Mason University.

Email Newsletter

Join 138,000+ IT pros on our weekly newsletter