NoSQL is a loose name for databases that depart from the relational table model: key-value stores, document stores, wide-column stores and graph databases. Each trades some of the relational toolbox, such as joins or strict schemas, for an advantage in scale, flexibility or a particular access pattern.
Key concepts
- Data models: key-value for fast lookups, documents for nested records, wide-column for huge sparse tables, graphs for relationships.
- Design from queries: you often shape the data around the questions you will ask, duplicating it if needed.
- Partitioning: splitting data across machines by a key, so a poor key creates hot spots.
- Replication and consistency: copies on several nodes raise availability but may briefly disagree.
- Schema flexibility: records need not share a shape, so the application must handle old and new versions.
Vocabulary
- CAP theorem: during a network partition a system must choose between consistency and availability.
- Eventual consistency: replicas converge to the same value if updates stop.
- Denormalisation: storing the same fact in several places to avoid joins.
- TTL: time to live, the age after which a record expires on its own.
What to study, in order
- Relational basics first, so you know what you are giving up.
- Use a key-value store as a cache and observe expiry and eviction.
- Model a small application, such as a blog, in a document store and list the queries it supports well.
- Try a graph database on a social network and write a friends-of-friends query.
- Read about partitioning and replication, and simulate a node failure.
- Take a relational schema and redesign it for a wide-column store, noting every compromise.