A3.4.4 · Alternative databases and data warehouses
Distributed databases
By the end you can
Describe databases spread over many sites: fragmentation, replication, partitioning and the trade-offs.
A hotel chain has hotels all over the world. One central database means a receptionist in Tokyo waits on a server in London, and one broken link takes everyone down. A splits the data across several sites on a network, yet still works as one database to the people and programs that use it.
Spreading the data: fragmentation, replication, partitioning#
- Fragmentation: the database is cut into pieces and each piece is stored at one site (for example each hotel's own bookings). Together the pieces make the whole.
- Replication: copies of the data are kept at more than one site (or the whole database at every site). Data stays available if a site fails, and reads are fast and local, but every change has to reach every copy.
- Partitioning is how the pieces are chosen. Range partitioning uses ranges of a key (bookings by date). Hash partitioning applies a hash function to the key for an even, unpredictable spread. List partitioning names which values go where (country to site). Round-robin deals rows out in turn when there is no natural key.
Replication can be arranged in different ways: a master database takes all the changes and passes them on to the others, or several masters all accept changes and share them, or every site is a peer of the others.
A hash function of the key picks the node: nearly even, and the same key always goes to the same node.
Click a node to fail or repair it.
Busiest node vs average
1.1×
Rows still readable
100%
Copies stored
60
Fail a node to see what is lost.
Features to get right#
- Concurrency control. Many users at many sites change data at once, so the system must keep to the ACID properties (A3.3.6). Pessimistic control locks data before use, assuming clashes will happen. Optimistic control does not lock but checks for a clash at the moment of saving, assuming they are rare.
- Data consistency. All copies must agree on the latest values. Strong consistency makes every update visible everywhere at once; weaker models allow copies to be briefly out of step in return for speed.
- Transparency. Users should not need to know where data is (distribution transparency), that copies exist (replication transparency) or that a site failed (failure transparency): another takes over unnoticed.
- Fault tolerance. Replication means the system carries on when parts fail.
- Security. More sites and more network traffic mean more to protect: encrypt stored and moving data, use roles and permissions, and use strong authentication such as multi-factor.
Distributed databases can be homogeneous (every site uses the same database system and schema, which is easier to manage) or heterogeneous (different systems or schemas, needing translation between them).
Advantages and disadvantages#
Advantages: faster processing, because the work and data are spread and kept near the users; easier expansion, by adding sites; greater reliability, through replication; and local control of local data.
Disadvantages: complexity, particularly consistency and transactions that cross sites; dependence on a fast, stable network; extra storage and update effort for replication; and a larger attack surface.
Each branch stores only its own customers, and the pieces together make the whole database.
Every site keeps a copy of the product catalogue so it stays available if one fails.
Customer IDs are fed to a function that picks one of 8 servers, spreading load evenly.
Orders from January to March on server 1, April to June on server 2.
A record is locked as soon as one user opens it, and others have to wait.
No locks; a clash is detected when two users try to save, and one has to retry.
0 of 6 matched
Check yourself
Distributed databases
Quick questions, made fresh every time and marked here. Do a few until they feel easy.
Exam practice
Paper 1-style questions
5 questions · 19 marks
Write your answer as you would in the exam, then show the mark points and tick each one your answer made. These are our own questions in the style of the exam, not past-paper questions.
1.Describe what a distributed database is.
[3]Describe: A detailed account: say what happens, step by step if it is a process.
2.Distinguish between fragmentation and replication.
[3]Distinguish: Make the differences between two things clear.
3.Outline two methods of partitioning data in a distributed database.
[4]Outline: A brief account: the main points, without much detail.
4.Explain the difference between pessimistic and optimistic concurrency control.
[3]Explain: Give reasons: say what happens AND why, or how one thing causes another.
5.Discuss the advantages and disadvantages of using a distributed database for an international hotel chain.
[6]Discuss: Look at the question from more than one side, weigh the points against each other, and come to a conclusion.
In a nutshell
- A distributed database stores its data at several sites on a network but works as one database for its users.
- Fragmentation splits the data into parts at different sites. Replication keeps copies at several sites, improving availability and speed at the cost of keeping copies consistent.
- Partitioning methods: range, hash, list and round-robin. Concurrency control is pessimistic (lock first) or optimistic (check at save time).
- Features to manage: consistency, concurrency, security, fault tolerance, and transparency (users do not see where data is or that copies exist).
- Advantages: speed, reliability, scalability, local control. Disadvantages: complexity, network dependence, consistency, a larger attack surface.
