Database Basics
Which correctly describes a database view in a relational database?
- AA virtual table defined by a SELECT statement; it normally holds no data of its own and builds its result from the underlying tables each time it is referenced
- BA table that stores a copy of the underlying table's data; changing the underlying table does not change the view's contents
- CA tree-structured piece of data created to find values in a particular column of a table quickly
Show answer and explanation
Answer: A. A virtual table defined by a SELECT statement; it normally holds no data of its own and builds its result from the underlying tables each time it is referenced
A database view is a virtual table defined by giving a name to a SELECT statement, as in CREATE VIEW sales_staff AS SELECT emp_no, name FROM employee WHERE dept = 'Sales'. An ordinary view holds no data of its own; its result is built from the underlying (base) tables each time the view is referenced, so updates to the base tables are reflected in the view as they are. Views are used to make frequently used complex queries simple to write, and to limit what users can access by granting them privileges only on a view that shows the permitted columns and rows. There are also materialized views, which compute and store the result in advance; they make reads faster but must be refreshed to follow the base tables. A tree structure for finding values quickly describes an index.
- A. Correct. A view is a virtual table defined by a SELECT statement, and changes to the base tables are reflected as they are.
- B. An ordinary view does not copy data, so changes to the base tables are reflected. Even materialized views, which store results, are refreshed to follow the base tables.
- C. This describes an index.