Professional Documents
Culture Documents
Database Design (IS414) Views: By: Neamat El Tazi
Database Design (IS414) Views: By: Neamat El Tazi
Views
To make complex
To restrict queries easy
data access
To present
different views of
the same data
A view 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. In some cases, we can modify a view and present the
data as if the data were coming from a single table.
Syntax:
1. DISTINCT in SELECT
2. DERIVED COLUMNS nor EXPRESSIONS;
3. The FROM/UNION references more than one table;
4. The FROM references another VIEW that is not
updateable;
5. The CREATE VIEW contains GROUP BY or
HAVING.
UPDATE ParamountMovie
SET year = 1979
WHERE title = ‘Star Trek the Movie’;
However, DROP TABLE will delete the table and also make
the view ParamountMovie unusable.
Suppose
The view is used frequently
The underlying tables on which the view is based do not
change very often
Suppose
Emps and Depts are changed infrequently
Everytime EmpDeptsView is accessed, Emps and Depts have to
be joined
Original query:
SELECT buyer, seller
FROM Person, Purchase
WHERE Person.city = ‘Seattle’
AND Person.per-name = Purchase.buyer
AND Purchase.product=‘ipad’.
Materialized views
Used in data warehouses
Precomputed offline – faster at runtime
May have stale data