L1 Flashcards
(17 cards)
DB interface
Interface
- remove low level concerns from app developer
- provide additional functional not inherent in underlying resource
- implementations can be changed over time
- BUT not always consistent with maximising performance
- Hourglass (multiple electricity using devices, multiple generation methods, but a single AC mains socket interface for all of these).
DBMS
- The interface presented by a database is defined by the query language it uses, its data model, and the programming API>
- The query engine implements and knows about the low level representation of data, and thereby can optimise query evaluation.
- Services provided by DBMS - abstraction of persistent storage that provides for CRUD operations, ACID transactions.
CRUD operations
Create - insert new items into the DB
Read - query the database
Update - change objects in the DB
Delete - remove data
ACID transactions
Atomicity, consistency, isolation, durability
Atomicity
Atomicity - transaction is all or nothing, even under system crash. All actions of t occur or none of them.
Consistency
- complete transactions can only transform the state of the DB between consistent states.
- if a transaction is applied to a consistent state of the DB, it can only leave the DB in a consistent state.
Isolation
concurrent transactions must produce a final state corresponding to the result produced by some sequential execution of the transactions. IE the effects of concurrently running transactions are protected from the effects of other concurrently executed transactions.
Durability
- if a transaction commits / completes successfully then its effects persist.
Relational model
1 Data stored as tables 2 unique keys identify unique rows 3 attributes correspond to columns 4 some attributes may be keys into other tables -- abstract pointers to a row in another table. 5 SQL main query language 6 Purpose is reducing data redundancy
Graph oriented model
Data stored as nodes/edges
Query language involves path oriented constructs
Document oriented model
- read optimised
2. key -> value = JSON bytes, for example.
Redundant data
Data is REDUNDANT if it could be deleted and then re-computed from the rest of the remaining data.
Advantage of low DR
Low DR -> transaction has to lock fewer tables on average -> more transactions can proceed concurrently -> higher update throughput
QL and UT define
Query response vs update throughput
Query response: latency until results of query are available.
Update throughput = number of updates committed per unit time.
Disadvantage of high DR
High DR -> transaction needs to lock other data which is affected by the update, as redundant data items need to be recomputed.
Disadvantage of low DR
Low DR -> simple queries can be expensive and may need to recompute much data, we a read-optimised DBMS would have cached (which is by definition redundant - the data was originally computed by a query).
What to use for a read oriented DB
For applications which require read optimised DB - use document oriented model.
- Present key , get a blob of JSON bytes.
- The JSON bytes contain all the information in the DB about that person.