Unit 2 · Lesson 212 minAcademic review pending

A view is a saved question, not a saved answer

A view lets many users see a tailored slice of the same underlying tables without copying data, and a design is never truly final — tables need to grow and change safely after they already hold real rows.

Choose explanation

After this lesson

You should be able to

  • Explain what a view is and why it does not store its own copy of data.
  • Describe what changes a table's structure can safely absorb after it already holds data.
01

A view: the exact view-level abstraction from Unit 1, made real

A view is a virtual relation defined by a stored query over one or more real relations — it looks and behaves like a table when queried, but holds no data of its own. Every time a view is used, the DBMS re-runs its underlying query against the current, live data. This is precisely the view level from Unit 1's three-level abstraction, now expressed as an actual database object: a fee-office view might show only paid_amount and roll_number from a wider Student table that also has personal details the fee office does not need to see.

Because a view has no stored data of its own, updates through certain simple views can pass through to the underlying table, but complex views (joining several tables, using aggregates) are often read-only. This limitation exists because there is no single unambiguous way to reverse-translate a change back into multiple underlying tables.

02

Tables change after they already have data

A design is rarely perfect on the first attempt, and requirements change over time. ALTER commands let a table's structure evolve after it already holds rows — adding a new column (existing rows typically get a null or default value for it), dropping a column that is no longer needed, or changing a column's data type when the data allows it.

DROP TABLE and DROP VIEW remove the object entirely and are effectively irreversible without a backup — unlike deleting rows with a query, which can sometimes be undone within a transaction, dropping the structure itself removes both the data and the schema definition together.

Try it yourself

The library's Member table needs a new email column, and the library wants a view that shows only members with overdue books, hiding everyone else. Describe both changes using this lesson's vocabulary.

Need a hint?

Adding a column to an existing table is an ALTER TABLE. Showing only a filtered slice of members without copying data is exactly what a view is for.

Check the worked solution

ALTER TABLE Member ADD email VARCHAR(50) adds the column; existing members get a null email until updated. A view, OverdueMembers, defined as a query selecting members with an overdue borrow record, shows only that filtered slice — no data is duplicated, and the view stays current automatically as borrow records change.

Quick check

Why can a simple view often be updated through, while a complex view joining several tables usually cannot?

Select an answer to check your thinking.

Why this lesson exists

Syllabus mapping

Introduction to Views, Altering Tables and Views, Destroying/altering Tables and Views

Maps to course outcomes CO1, CO2.