Week 3 - Spreadsheets and Storage Flashcards
What type of programming are spreadsheets a form of?
Functional programming
Give 2 use cases of spreadsheets.
Reading a cell
Updating a cell
How else can a spreadsheet be seen?
As a store of documents
What does the repository design pattern encapsulate?
A set of objects persisted in a data store and the operations performed over them. It provides a clean separation between the domain and mapping layers.
How can an enterprise computer system store data?
Using a centralised or decentralised/distributed database
What is an enterprise using a monolith likely to store its data in?
A centralised database
What are some pros of using centralised database organisation?
It is easy to ensure that the accuracy, completeness, and consistency of data is maintained
What are the two things a transaction can do?
Commit (completes successfully), and the database is moved to a new consistent state.
Aborts (completes unsuccessfully), and the database is restored to its previous consistent state.
Transactions have the ACID properties. What does ACID stand for?
Atomicity, Consistency, Isolation, Durability
What does atomicity mean in terms of centralised database transactions?
All or nothing - transactions either happen or they don’t
What does consistency mean in terms of centralised database transactions?
Before a transaction the database is in a consistent state, and after the transaction the database is in a consistent state
What does isolation mean in terms of centralised database transactions?
Serialisability - transactions cannot view other in-progress transactions
What does durability mean in terms of centralised database transactions?
If a transaction takes place, its effects will be seen
What is an enterprise using microservices likely to store its data in?
A distributed/decentralised database
What are some cons of distributed databases?
It is difficult to ensure the accuracy, completeness and consistency of data is maintained
How can a distributed database be managed?
With two-phase commit or sagas
Describe a two-phase commit.
A coordinator transaction asks a number of participant transactions to vote on whether they are prepared to commit a change.
Each participant holds locks on its data involved in the transaction until the coordinator decides to commit or abort.
If all participants vote to commit, then the coordinator instructs all participants to commit. Otherwise, if any participant votes to abort or times out, the coordinator instructs all participants to abort.
What is a problem with a two-phase commit?
The locks on the transaction data means other transactions can’t take place at the same time.
Describe a saga.
A coordinator transaction asks each participant to commit or abort in sequence.
Each participant holds a lock on its data involved in the transaction only until it decides to commit or abort.
What happens in a saga if a participant aborts?
The sequence ends immediately and compensating transactions are made to undo the work of those participants that have already committed - a saga sacrifices atomicity and relies on eventual consistency.
Among the desirable properties of a distributed system are CAP - what does this stand for?
Consistency, Availability, Partition-tolerance
What does consistency mean in the CAP Theorem?
The same response is received from any node/microservice
What does availability mean in the CAP Theorem?
A response is received from every node/microservice
What does partition-tolerance mean in the CAP Theorem?
The system works even if nodes/microservices become disconnected