Learning objectives
What you will be able to explain
- Complex development and numerous function calls are both disadvantages of compilation-based query processing models.
- Which of the following processing models has the largest intermediate result sizes for pipelining operators?
- The five base operators of the relational algebra are selection, projection, intersect, union, and cartesian product.
- The set difference of two relations can be expressed using only set intersection operators.
- The grouping operator γ is used to filter tuples based on a condition.
- A join is the composition of a set intersection and a selection operator.
Section 01
Complex development and numerous function calls are both disadvantages of compilation-based query processing models. to The five base operators of the relational algebra are selection, projection, intersect, union, and cartesian product.
01
Complex development and numerous function calls are both disadvantages of compilation-based query processing models.
02
Which of the following processing models has the largest intermediate result sizes for pipelining operators?
Guided checkpoint
Wählen Sie eine Antwort:
03
The five base operators of the relational algebra are selection, projection, intersect, union, and cartesian product.
Section 02
The set difference of two relations can be expressed using only set intersection operators. to A join is the composition of a set intersection and a selection operator.
01
The set difference of two relations can be expressed using only set intersection operators.
02
The grouping operator γ is used to filter tuples based on a condition.
03
A join is the composition of a set intersection and a selection operator.
Section 03
Selection in relational algebra is used to retrieve only certain attributes from a relation. to Operator invocations by processing model
01
Selection in relational algebra is used to retrieve only certain attributes from a relation.
02
Grouping, sort and join are all pipelining operators.
03
Operator invocations by processing model
Guided checkpoint
Given the following SQL query and execution steps, calculate the number of invocations per operator for each processing model (Volcano, Materialization, Vectorization).
SQL
SELECT MIN(e.salary)
FROM employee e
WHERE e.age > 35;Execution steps
- Scan table employee e.
- Filter results on e.age > 35.
- Aggregate tuples on MIN(e.salary).
Important assumptions
- Table employee consists of 500000 rows.
- The predicate (e.age > 35) has a selectivity factor of 0.5 (50% pass this filter).
- The vectorization model uses a batch size of 2000 tuples (processes 2000 tuples at a time).
- For the materialization model, intermediate results are fully materialized.
Section 04
Is the following law valid? to Select the best join order (the one with the lowest cost).
01
Is the following law valid?
Guided checkpoint
Assume relations R and S are sets.
02
Cross product detection in join order selection
Guided checkpoint
Consider four relations R(b, c), S(c, d), T(a, d), and U(a, b). Each relation has 1000 tuples. The relations have the following attribute domain cardinalities:
| R(b, c) | S(c, d) | T(a, d) | U(a, b) |
|---|---|---|---|
| V(T, a) = 250 | V(U, a) = 100 | ||
| V(R, b) = 40 | V(U, b) = 20 | ||
| V(R, c) = 100 | V(S, c) = 200 | ||
| V(S, d) = 200 | V(T, d) = 1000 |
For each join order: Can it be ignored because it contains a cross product when determining the optimal join order?
03
Select the best join order (the one with the lowest cost).
Guided checkpoint
Consider four relations R(a, d), S(b, d), T(b, c), and U(a, c). Each relation has 1000 tuples. The relations have the following attribute domain cardinalities:
| R(a, d) | S(b, d) | T(b, c) | U(a, c) |
|---|---|---|---|
| V(R, a) = 50 | V(U, a) = 20 | ||
| V(S, b) = 400 | V(T, b) = 100 | ||
| V(T, c) = 1000 | V(U, c) = 200 | ||
| V(R, d) = 500 | V(S, d) = 40 |
Note: Cost refers to the sum of all intermediate result sizes (excluding input relations and the final result).
Wählen Sie eine Antwort:
Section 05
Join-order cost to Join cardinality
01
Join-order cost
Guided checkpoint
Consider four relations R(b, c), S(a, b), T(c, d), and U(a, d). Each relation has 1000 tuples. The relations have the following attribute domain cardinalities:
| R(b, c) | S(a, b) | T(c, d) | U(a, d) |
|---|---|---|---|
| V(S, a) = 40 | V(U, a) = 10 | ||
| V(R, b) = 1000 | V(S, b) = 200 | ||
| V(R, c) = 400 | V(T, c) = 40 | ||
| V(T, d) = 10 | V(U, d) = 250 |
What is the cost of the following join order ((T ⋈ U) ⋈ R) ⋈ S?
Note: Cost refers to the sum of all intermediate result sizes (excluding input relations and the final result).
02
Join with selection cardinality
Guided checkpoint
Given are the tables R(r1, s1) and S(s1, s2). R.s1 is a foreign key to S.s1. The tables have the following tuple and attribute domain cardinalities:
- T(R) = 5000
- T(S) = 450
- V(S, s2) = 10
Assume that 1 / (2 * V(R, f)) of the tuples satisfy the comparison when an attribute is equated to a constant (e.g., σ_{f=15}).
How many tuples are selected by the join R ⋈ σ_{s2=89}(S)?
03
Join cardinality
Guided checkpoint
Consider four relations R(c, d), S(a, b), T(a, d), and U(b, c). Each relation has 1000 tuples. The relations have the following attribute domain cardinalities:
| R(c, d) | S(a, b) | T(a, d) | U(b, c) |
|---|---|---|---|
| V(S, a) = 10 | V(T, a) = 50 | ||
| V(S, b) = 250 | V(U, b) = 50 | ||
| V(R, c) = 100 | V(U, c) = 200 | ||
| V(R, d) = 100 | V(T, d) = 10 |
What is the cardinality of the following join (U ⋈ T) ⋈ S?
Section 06
Estimated natural join cardinality to Selection cardinality with independent predicates (OR)
01
Estimated natural join cardinality
Guided checkpoint
Consider the natural join R(a, c) ⋈ S(a, b, e) ⋈ U(a, e), and the following important statistics:
| R(a, c) | S(a, b, e) | U(a, e) |
|---|---|---|
| T(R) = 72000 | T(S) = 14400 | T(U) = 10000 |
| V(R, a) = 400 | V(S, a) = 90 | V(U, a) = 40 |
| V(S, b) = 40 | ||
| V(R, c) = 450 | ||
| V(S, e) = 80 | V(U, e) = 500 |
What is the estimated cardinality of the natural join (the join on all common attributes)?
02
Selection cardinality with independent predicates (AND)
Guided checkpoint
Given is the table R(a, b) with the following tuple and attribute domain cardinalities:
- T(R) = 128000
- V(R, a) = 80
- V(R, b) = 100
Assume that:
- 1 / (3 * V(R, f)) of the tuples satisfy the comparison when an attribute is equated to a constant (e.g., σ_{f=15})
- Inequality (e.g., σ_{f<90}) tends to retrieve one-third of the tuples
- For not equals (e.g., σ_{f≠90}), a fraction of 5 / V(R, f) number of the tuples will fail to meet the condition
- Predicates are independent
Note, single assumptions may deviate from the ones discussed during the lecture.
How many tuples are selected by the selection ?
03
Selection cardinality with independent predicates (OR)
Guided checkpoint
Given is the table R(a, b) with the following tuple and attribute domain cardinalities:
- T(R) = 37800
- V(R, a) = 70
- V(R, b) = 30
Assume that:
- 1 / V(R, f) of the tuples satisfy the comparison when an attribute is equated to a constant (e.g., σ_{f=15})
- Inequality (e.g., σ_{f<90}) tends to retrieve half of the tuples
- For not equals (e.g., σ_{f≠90}), a fraction of 6 / V(R, f) number of the tuples will fail to meet the condition
- Predicates are independent
Note, single assumptions may deviate from the ones discussed during the lecture.
How many tuples are selected by the selection ?
Section 07
Which of the following is a valid Condition Rule in the grammar for simple subset of SQL? to A schedule with interleaved operations from different transactions can have multiple conflict-equivalent serial schedules.
01
Which of the following is a valid Condition Rule in the grammar for simple subset of SQL?
02
A transaction is a single unit of work which should be executed fully or not at all.
03
A schedule with interleaved operations from different transactions can have multiple conflict-equivalent serial schedules.
Section 08
Complete precedence graph by choosing correct entries from dropdowns. to The following schedule is conflict-serializable:
01
Complete precedence graph by choosing correct entries from dropdowns.
Guided checkpoint
Consider the following schedule: W2(A), R1(A), W3(C), R2(A), R3(B), W4(A), W4(B)
02
Do the following operations conflict or not?
Guided checkpoint
Let T1 and T2 be two transactions that are contained in an interleaved schedule.
Let A and B be two different database elements.
Select the appropriate option for each operation pair.
03
The following schedule is conflict-serializable:
Guided checkpoint
W2(C), W1(A), R3(B), W4(B), R2(C), W3(C), R3(A), W2(B)Section 09
Strict two-phase locking (2PL) leads to lower parallelization and lower throughput (compared to normal 2PL). to The following schedule is possible under strict two-phase locking (S2PL): R3(C), W3(B), R3(D), R3(D), R1(D), R2(C), R1(A), W1(C)
01
Strict two-phase locking (2PL) leads to lower parallelization and lower throughput (compared to normal 2PL).
02
Lock compatibility matrix with Increment (I) and Multiplication (M)
Guided checkpoint
Consider that in addition to the shared (S) and exclusive (X) locks, your database system has two more locks:
- Increment (I) - increments a database element by a constant.
- Multiplication (M) - multiplies a database element by a constant.
Fill in the appropriate value for the drop-downs in the compatibility matrix (N.A. stands for not applicable).
| Shared (S) | Exclusive (X) | Increment (I) | Multiplication (M) | |
|---|---|---|---|---|
| Shared (S) | Yes | No | N.A. | N.A. |
| Exclusive (X) | No | No | N.A. | N.A. |
| Increment (I) | N.A. | N.A. | N.A. | ? |
| Multiplication (M) | N.A. | N.A. | ? | N.A. |
03
The following schedule is possible under strict two-phase locking (S2PL): R3(C), W3(B), R3(D), R3(D), R1(D), R2(C), R1(A), W1(C)
Section 10
Timestamp-based scheduling table completion to Match the failure below to the type of failure
01
Timestamp-based scheduling table completion
Guided checkpoint
Consider that you have three transactions, T1, T2, and T3 that operate on three database elements A, B, and C. The timestamps of the transactions are as follows: T1 = 250, T2 = 225, T3 = 150, while the initial values of the read and write timestamps of the three database elements is 0.
Consider the following schedule: R1(B), R2(A), R3(C), W1(B), W1(A), W2(C), W3(A)
Fill out the missing values in the table below following the algorithm in the Complete Book (Section 18.8.4 The Rules for Timestamp-Based Scheduling).
Assumptions
- The last occurrence of a transaction in the schedule also includes the commit request to the scheduler.
- RT(X) refers to the read timestamp of a database element X.
- WT(X) refers to the write timestamp of a database element X.
- C(X) refers to the commit bit of a database element X.
02
Multi-version Concurrency Control (MVCC) keeps only a single version of all data items.
03
Match the failure below to the type of failure
Section 11
Force policy means that the database system imposes a condition that all updates by the transaction should be written to disk just before the transaction commits. to The analysis phase in recovery starts from the last checkpoint in the log.
01
Force policy means that the database system imposes a condition that all updates by the transaction should be written to disk just before the transaction commits.
02
Write-Ahead Logging (WAL) ensures atomicity but not integrity.
03
The analysis phase in recovery starts from the last checkpoint in the log.
Section 12
ARIES analysis pass: fill transaction table and dirty page table entries to ARIES undo pass actions for UPDATE log records
01
ARIES analysis pass: fill transaction table and dirty page table entries
Guided checkpoint
Consider the following log records. The table contains the log sequence number (LSN), the transaction ID (TID), the previous log sequence number of the transaction (prevLSN), and the action of the log entry. The format of the UPDATE action is: (Page ID, Element ID, Old value, New value).
| LSN | TID | prevLSN | ACTION |
|---|---|---|---|
| 1 | 1 | BEGIN_TRANSACTION | |
| 2 | 2 | BEGIN_TRANSACTION | |
| 3 | 3 | BEGIN_TRANSACTION | |
| 4 | 1 | 1 | UPDATE (1, 1, "a", "A") |
| 5 | 2 | 2 | UPDATE (2, 2, "b", "B") |
| 6 | 1 | 4 | UPDATE (2, 3, "c", "C") |
| 7 | BEGIN_CHECKPOINT | ||
| 8 | 1 | 6 | UPDATE (3, 4, "d", "D") |
| 9 | 3 | 3 | UPDATE (2, 5, "e", "E") |
| 10 | 1 | 8 | COMMIT |
| 11 | 1 | 10 | END_TRANSACTION |
| 12 | END_CHECKPOINT | ||
| 13 | 2 | 5 | UPDATE (3, 6, "f", "F") |
| 14 | 2 | 13 | UPDATE (1, 7, "g", "G") |
The recovery process starts at LSN 7 with the following transaction table and dirty page table.
Transaction table (initial)
| TID | lastLSN |
|---|---|
| 1 | 6 |
| 2 | 5 |
| 3 | 3 |
Dirty page table (initial)
| PID | recLSN |
|---|---|
| 1 | 4 |
| 2 | 5 |
In the transaction and dirty page tables below, enter the LSN for each transaction/page after the analysis pass. Select "No Entry" if a transaction/page is not in the transaction/dirty page table.
02
Loser transactions refer to uncommitted transactions.
03
ARIES undo pass actions for UPDATE log records
Guided checkpoint
Consider the following log records. The table contains the log sequence number (LSN), the transaction ID (TID), the previous log sequence number of the transaction (prevLSN), and the action of the log entry. The format of the UPDATE action is: (Page ID, Element ID, Old value, New value).
The recovery process starts at LSN 7 with the following transaction table and dirty pages table.
Transaction table
| TID | lastLSN |
|---|---|
| 1 | 6 |
| 2 | 5 |
| 3 | 3 |
Dirty page table
| PID | recLSN |
|---|---|
| 1 | 4 |
| 2 | 5 |
Select the action taken during the undo passes for the UPDATE actions in the drop-down menus in the log table below.
Section 13
The redo pass in recovery goes forward in the log from the last checkpoint (or the first relevant log sequence number identified during the analysis pass). to What is the purpose of checkpoints for logging?
01
The redo pass in recovery goes forward in the log from the last checkpoint (or the first relevant log sequence number identified during the analysis pass).
02
ARIES redo pass actions for UPDATE log records
Guided checkpoint
Consider the following log records. The table contains the log sequence number (LSN), the transaction ID (TID), the previous log sequence number of the transaction (prevLSN), and the action of the log entry. The format of the UPDATE action is: (Page ID, Element ID, Old value, New value).
The recovery process starts at LSN 7 with the following transaction table and dirty pages table.
Transaction table
| TID | lastLSN |
|---|---|
| 1 | 4 |
| 2 | 6 |
| 3 | 3 |
Dirty page table
| PID | recLSN |
|---|---|
| 1 | 6 |
Select the action taken during the redo passes for the UPDATE actions in the log table below. Assume that pageLSN is always less than LSN.
03
What is the purpose of checkpoints for logging?
Guided checkpoint
Wählen Sie eine Antwort:
Section 14
Amdahl's Law is more optimistic than Gustafson's Law when predicting speedup in parallel computing. to Which parallel architecture does a multiprocessor laptop use?
01
Amdahl's Law is more optimistic than Gustafson's Law when predicting speedup in parallel computing.
02
According to Amdahl's Law, in a best-case scenario, the theoretical speedup of a program is equal to the number of processors available.
03
Which parallel architecture does a multiprocessor laptop use?
Guided checkpoint
Wählen Sie eine Antwort:
Section 15
Besides round robin, hash-based partitioning also guarantees an equal amount of tuples per partition. to Vertical partitioning is most useful when the full table is frequently used in queries.
01
Besides round robin, hash-based partitioning also guarantees an equal amount of tuples per partition.
02
If a table is range-partitioned based on a subset of its attributes, range queries involving those attributes can be optimized by processing only the relevant partitions.
03
Vertical partitioning is most useful when the full table is frequently used in queries.
Section 16
Which of the following correctly describes a scenario where both replication and fragmentation are used? to Inter-query parallelism is more suited for analytical workloads (OLAP) than transactional workloads (OLTP).
01
Which of the following correctly describes a scenario where both replication and fragmentation are used?
Guided checkpoint
Wählen Sie eine Antwort:
02
Inter-operator parallelism allows multiple operators to run concurrently.
03
Inter-query parallelism is more suited for analytical workloads (OLAP) than transactional workloads (OLTP).
Section 17
The transaction coordinator manages the start, execution, and termination of transactions originating from a particular site.
01
The transaction coordinator manages the start, execution, and termination of transactions originating from a particular site.
Knowledge check
Turn understanding into recall.
The quiz now follows the same concepts in scored form. You can return to this lesson from the quiz whenever a gap appears.