Topic 7 · Notes

Databases and distributed systems

These notes are part of a subscription

11 sections covering the whole specification for this topic, with worked examples.

Preview

Flat files and relational databases

A flat file database keeps all the data in one table. The same details get stored again and again:

OrderIDCustomerNameCustomerAddressProduct
1Ann Jones3 High StKeyboard
2Ann Jones3 High StMouse
3Ann Jones3 Hihg StMonitor
  • Data redundancy: Ann's address is stored three times, wasting space.
  • Data inconsistency: one copy has been mistyped, so which is right? Changing her address means changing every copy.

A relational database splits the data into linked tables (relations). Each fact is stored once, and tables are linked by keys.

Customer(CustomerID*, Name, Address)
Order(OrderID*, CustomerID, Product)
TermMeans
Table (relation)Data about one kind of thing (entity)
Record (row, tuple)One instance, e.g. one customer
Field (column, attribute)One item of data about each record

Benefits: less redundancy, so less wasted space and fewer inconsistencies; data is updated in one place; data integrity can be enforced; flexible queries can combine tables; different users can be given different views; it scales to large amounts of data.

Drawbacks: more complex to design and set up, needs a DBMS and skilled staff, and queries joining many tables can be slower than reading one flat file.

Also in these notes

  • Keys and indexesAS
  • Entity relationship modellingAS
  • User viewsAS
  • Consistency, redundancy and data independenceA2
  • NormalisationA2
  • SQL: querying dataA2
  • SQL: changing data and structureA2
  • The DBMS and the data dictionaryA2
  • Big data, data warehousing and data miningA2
  • Distributed data and processingA2