Live Lecture Materials Week 13 Flashcards
(47 cards)
A view is a
query stored within a database
Views are best for
complex queries that need to be run often
Correct syntax for creating a view
CREATE [OR REPLACE] VIEW name AS
–SELECT STATEMENT–
Create a view for the hospital table called doctor, that selects name_of_hospital and doctor
CREATE VIEW doctor AS
SELECT name_of_hospital, doctor
FROM hospital
Alter the doctor view so that it shows the pay, name_of_hospital, and the doctor from the hospital table
ALTER VIEW doctor AS
SELECT pay, name_of_hospital, doctor
FROM hospital
All views need the _____ keyword added to the statement, even if it is not used
alias
Dynamic view is also called a
virtual table or logical view. It’s also known as a derived table.
T/F - Dynamic views occupy hard disk space
False
T/F - A dynamic view provides the most recent data
True
T/F - Materialized views occupy hard disk space
True
Materialized views must be ________ to stay up to date
refreshed
T/F - Data in materialized views is always consistent with live data
False
Command to refresh a materialized view
REFRESH
Updating a view is only possible if the ____________ are honored
constraints
Most employee’s do not have access to ______, only _____
tables, only views
The reason why indexes are effective is that most queries only require a
small amount of information from a database
Purpose of indexes
Speed up queries so we don’t have to search the entire database
Index analogy for a textbook
Instead of searching the entire textbook for a certain page, we have an index that allows us to look up the topic/pg number
Index definition
A data structure that is used to speed up data retrieval. Typically contains a list of keys used to identify table columns.
_______ ____ are automatically indexed
Primary keys
An index is a table or data structure used to determine the ________ __ ________ that satisfy some condition
location of records
T/F - A combination of fields can be indexed
True
Secondary keys
Indexed field or fields that are not primary keys
Indexed file organization uses something known as a ____ _______
Tree search