Live Lecture Materials Week 13 Flashcards

(47 cards)

1
Q

A view is a

A

query stored within a database

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Views are best for

A

complex queries that need to be run often

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Correct syntax for creating a view

A

CREATE [OR REPLACE] VIEW name AS
–SELECT STATEMENT–

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Create a view for the hospital table called doctor, that selects name_of_hospital and doctor

A

CREATE VIEW doctor AS
SELECT name_of_hospital, doctor
FROM hospital

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Alter the doctor view so that it shows the pay, name_of_hospital, and the doctor from the hospital table

A

ALTER VIEW doctor AS
SELECT pay, name_of_hospital, doctor
FROM hospital

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

All views need the _____ keyword added to the statement, even if it is not used

A

alias

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Dynamic view is also called a

A

virtual table or logical view. It’s also known as a derived table.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

T/F - Dynamic views occupy hard disk space

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

T/F - A dynamic view provides the most recent data

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

T/F - Materialized views occupy hard disk space

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Materialized views must be ________ to stay up to date

A

refreshed

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

T/F - Data in materialized views is always consistent with live data

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Command to refresh a materialized view

A

REFRESH

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Updating a view is only possible if the ____________ are honored

A

constraints

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Most employee’s do not have access to ______, only _____

A

tables, only views

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

The reason why indexes are effective is that most queries only require a

A

small amount of information from a database

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

Purpose of indexes

A

Speed up queries so we don’t have to search the entire database

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

Index analogy for a textbook

A

Instead of searching the entire textbook for a certain page, we have an index that allows us to look up the topic/pg number

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

Index definition

A

A data structure that is used to speed up data retrieval. Typically contains a list of keys used to identify table columns.

20
Q

_______ ____ are automatically indexed

21
Q

An index is a table or data structure used to determine the ________ __ ________ that satisfy some condition

A

location of records

22
Q

T/F - A combination of fields can be indexed

23
Q

Secondary keys

A

Indexed field or fields that are not primary keys

24
Q

Indexed file organization uses something known as a ____ _______

25
In a tree search, the average time to find the desired record depends on the _____ and ______ of the tree
depth and length
26
A unique (primary) index
Usually for primary keys, but can also apply to other unique fields
27
A nonunique (secondary) index
An index of a non-unique table column. Often used to group data items (eg. Product Category)
28
Syntax to create nameIndex for the source_airport_id column in the routes table
CREATE INDEX nameIndex ON routes( source_airport_id );
29
A transaction is a
unit of work that changes the state of a database
30
Transactions are a __________ group of statements
sequential
31
Transactions can either be _________ or ______ ____ by the user
committed or rolled back
32
3 Examples of transactions
INSERT, UPDATE, DELETE
33
A transaction that ends after encountering a commit or roll back
It ended explicitly
34
A transaction after encountering a DDL statement
It ended implicitly
35
ACID - A
Atomic - Every statement within the unit of work must be performed successfully. If one operation fails, the group of statements fail.
36
ACID - C
Consistent - Maintains data integrity. If a database violates data integrity it will be rolled back. Protects the data.
37
ACID - I
Isolation - Every operation is independent within a unit of work Also means that statements are transparent to each other.
38
ACID - D
Durability - When transactions are committed, they will survive permanently For example, if a flight booking reports that a seat has successfully been booked, then the seat will remain booked even if the system crashes
39
2 synonyms for START TRANSACTION that also work
BEGIN and BEGIN WORK
40
The ______ statement allows for durable modifications to the database
COMMIT
41
___ ____-______ is used to enable or disable the auto-commit mode for a current transaction. Auto-commit commits a transaction when it is executed.
SET auto-commit
42
T/F - by default, auto-commit is ON
True
43
a savepoint ensures that all statements
performed after the savepoint can be rolled back
44
During a transaction, if multiple savepoints are set with the same name, which one is used for the rollback?
The newest one
45
Statement to rollback to the savepoint
ROLLBACK TO SAVEPOINT
46
Statement that removes the given savepoint from the current transaction, without making any changes the query
RELEASE SAVEPOINT
47
If you have a savepoint called name_of_savepoint, what is the syntax to rollback to it? to release it?
ROLLBACK TO SAVEPOINT name_of_savepoint RELEASE SAVEPOINT name_of_savepoint