L6 Updates Flashcards

1
Q

When defining a foreign key constraint in SQL, we can specify three possible actions the database system can take (the default and two others) when a value referenced by the foreign key value is to be deleted or updated. Explain what the three possible actions do.

A
  1. Disallow such updates (default)
  2. ON DELETE CASCADE / ON UPDATE CASCADE
    • for actions on the referenced relation to cascade to referencing relation
  3. ON DELETE SET NULL / ON UPDATE SET NULL
    • the referencing relation’s values will be set to null
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Give two reasons why SQL views are considered useful.

A
  • Views provide an abstracting layer preventing direct access to the tables
  • encourage In One Place Only (IOPO) policy
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the acid test?

A

Transactions are designed to meet the “ACID” test:

  • “A” stands for “atomicity”
    • transactions should execute completely or appear not to have run at all
  • “C” stands for “consistency”
    • the constraints specified in the database must be preserved
  • “I” stands for “isolation”
    • each transaction should appear to execute as if there are no others
  • “D” stands for “durability”
    • once a transaction completes, it effect should never be lost
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Views are sometimes described as virtual. Describe what is meant by this.

A
  • views are not precomputed and their results stored.
  • I Instead they can be queried and the system “combines” the query and view definition.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is Dirty data?

A

Dirty data means data written by a transaction that
has not yet committed.

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

What is a dirty read operation and what is the risk with them?

A
  • A dirty read is a read of dirty data written by anothertransaction.
  • The risk is that the transaction that wrote the datamay abort.
  • This results in non-serializable behaviour.
  • This may or may not be a problem for the reading transaction.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Which Transaction Isolation Levels exist in SQL?

A
  • READ UNCOMMITTED: allowed to read dirty data.
  • READ COMMITTED: not allowed to read dirty data (but can still issue the same query a number of times and get different answers).
  • REPEATABLE READ: ensures that tuples read by a query don’t “disappear” if the query is repeated, but can still retrieve phantom tuples if insertions have been made.
  • SERIALIZABLE: the default (and strongest).
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Which of the SQL transaction isolation levels will disallow dirty read operations?

A

SERIALIZABLE

REPEATABLE READ

READ COMMITTED

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

Under which conditions is a view said to be updatable in SQL?

A
  • The from clause has only one database relation.
  • The select clause contains only attribute names of the relation (no expressions, aggregates, or distinct).
  • Any attribute not listed in the select clause can be set to null.
  • There is no group by or having clause.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What does updatable mean in the context of a sql view?

A

inserts, updates or deletes can be applied

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

Give the names for the two operations which end a transaction and explain how the database is affected by each.

A
  • COMMIT causes the transaction to end successfully.
    • All changes to the database are made permanent.
  • ROLLBACK cause the transaction to abort. All
    • changes to the database are undone.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is a transaction commit?

A
  • COMMIT causes the transaction to end successfully.
  • All changes to the database are made permanent.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is a transaction abort?

A
  • ROLLBACK cause the transaction to abort.
  • All changes to the database are undone.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Is a dirty read operation one that should always be avoided?

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