What is a view in SQL?
A) A physical table
B) A saved query
C) A database
D) An index
B) A saved query
Does a view store data itself?
A) Yes
B) No
C) Sometimes
D) Only in SQLite
B) No
A view acts like:
A) A file
B) A virtual table
C) A server
D) A key
B) A virtual table
Why are views useful?
A) To delete data
B) To simplify queries
C) To slow down queries
D) To create indexes
B) To simplify queries
When you query a view, what happens?
A) Nothing
B) Data is deleted
C) The query runs again
D) A new table is created
C) The query runs again
What is stored inside a view?
A) Data rows
B) Query definition
C) Indexes
D) Keys
Query definition
Which SQL command is most commonly used with views?
A) DELETE
B) SELECT
C) DROP
D) ALTER
SELECT
What problem do views solve?
A) Data duplication
B) Rewriting queries many times
C) Slow internet
D) Memory issues
Rewriting queries many times
Where are views stored in SQLite?
A) user_table
B) sqlite_master
C) system_data
D) view_store
B) sqlite_master
What type is used for views in sqlite_master?
A) 'table'
B) 'index'
C) 'view'
D) 'data'
C) 'view'
Which is NOT a benefit of views?
A) Simplification
B) Reusability
C) Data storage
D) Security
Security
Views help users avoid:
A) Writing code
B) Understanding complex tables
C) Using SQL
D) Running queries
Understanding complex tables
Views can help with:
A) Security
B) Deleting databases
C) Hardware upgrades
D) Networking
Security
What happens if you change a view definition?
A) All related queries update automatically
B) Data is deleted
C) Database crashes
D) Nothing changes
All related queries update automatically
Views are useful for:
A) Complex joins
B) Simple queries only
C) Storing files
D) Encryption
Complex joins
Which operation may NOT work on some views?
A) SELECT
B) INSERT
C) UPDATE
D) All of the above
All of the above
In SQLite, which operations are NOT supported on views?
A) SELECT
B) INSERT/UPDATE/DELETE
C) CREATE
D) DROP
INSERT/UPDATE/DELETE
What is a non-updateable view?
A) A view that stores data
B) A view that cannot be modified with INSERT/UPDATE/DELETE
C) A broken view
D) A temporary table
A view that cannot be modified with INSERT/UPDATE/DELETE
Why should you avoid creating views of views?
A) It increases performance
B) It simplifies queries
C) It becomes too complex
D) It deletes data
It becomes too complex
What is a performance issue with views?
A) They store too much data
B) They re-run queries each time
C) They delete tables
D) They block users
They re-run queries each time
Explain how a view helps reduce query duplication, and give a simple example.
Answer: A view stores a common query (e.g., joining students and courses), so instead of rewriting it multiple times, you reuse the view, reducing repetition.
What is the main difference between a table and a view in terms of data storage and execution?
Answer: A table stores actual data, while a view stores only a query and retrieves data dynamically when accessed.
Why are views useful when working with complex SQL queries involving joins?
Answer: They hide complexity by encapsulating joins, making queries easier to read and reuse.
How can a view be used to restrict access to sensitive data? Provide a simple example.
Answer: A view can show only selected columns (e.g., student name and course) while hiding sensitive ones like GPA or grades.
What happens if the underlying tables of a view are modified (e.g., columns added or removed)?
Answer: The view may still work if changes don’t affect its query, but it can break if required columns are removed or renamed.