Skip to the content ForoHackers
Log inJoin

Databases: start here

Databases
#2901 · · Quote · Report

A database is a system that stores data durably and lets programs query and change it safely, even when many users work at once and machines fail. It matters because almost every application is, at heart, a way of keeping state: the hard parts are correctness, speed and not losing anything.

Key concepts

  • Data model: tables of rows, documents, key-value pairs or graphs; the model shapes what is easy to ask.
  • Transactions: a group of changes that succeeds or fails as one unit, with ACID guarantees.
  • Indexes: extra structures, usually B-trees, that turn a full scan into a quick lookup at the cost of slower writes.
  • Query planning: the engine chooses how to run a query; reading its plan explains why it is slow.
  • Durability and replication: a write-ahead log survives a crash, and copies on other machines survive a lost one.

Vocabulary

  • Schema: the declared structure of the data, its names, types and constraints.
  • Normalisation: organising tables so each fact is stored once.
  • Isolation level: how far concurrent transactions are kept from seeing each other's changes.
  • Primary key: the value that uniquely identifies a row.

What to study, in order

  1. Install a relational database and model a small domain, such as a library, in tables.
  2. Learn SQL well: selects, joins, grouping, inserts, updates and constraints.
  3. Create an index, read the query plan before and after, and measure the difference.
  4. Write two concurrent transactions that conflict and see what each isolation level allows.
  5. Read how a write-ahead log and a B-tree work, then restore a database from a backup.
  6. Compare the same problem in a document store and say what you gained and lost.

Related tags

#sql #nosql #data-structures #distributed-systems

You are not logged in, so this goes up anonymously: no account, no name and no address is stored with it, and it may carry no link and no image. Log in or join to post under your name. Our web server's logs keep the address and time of every request for up to 14 days; to keep yours out of them, use Tor. To reach the staff in confidence, use the drop. Sign as a returning source (a key kept only in this browser)

Sending takes a few seconds here: your browser first works out a proof of work against spam.

Reply