The following content is my own note from the book, "Designing Data-Intensive Applications". The writing is intended for people who want to dash through the book quickly.
There're numerous types of data model in the industry and these three types are the most dominant at present: Relational, Document, and Graph-Like.
Relational Model, SQL
- When to use: there's strict relationship between entities.
-
Concept:
- All data can be expressed in terms of relation (table) and a collection of tuples (row).
- Normalization (use of ID instead of string texts for entities) helps avoid duplicating human-meaningful info in every record that uses it.
- Caveat: Schema changes (through "ALTER TABLE" command) have a bad reputation of being slow and requiring downtime. For example, MySQL copies the entire table on "ALTER TABLE", causing minutes or even hours of downtime when altering a large table.
Document Model, NoSQL
-
When to use:
- an application has mostly one-to-many relationships (tree-structure data) or no relationships between records.
- need for greater scalability (high write throughput and very large datasets).
- Concept: Flexible schema (dynamic and expressive data model).
-
Caveat:
- Clients have no guarantees as to what fields the documents may contain.
- If an application needs to access large parts of the document at the same time, the database typically needs to load the entire document even if you access only a small portion of it. For this reason, it's generally recommended that you keep documents fairly small and avoid writes that increase the size of a document.
Graph-Like Model
- When to use: an application commonly has many-to-many relationships. Graphs are good for evolvability (you add features to your application, a graph can easily be extended to accommodate changes in your application's data structures)
- Concept: A graph consists of two objects: vertices (entities) and edges (relationships).
- Example: social graph (vertices are people, and edges indicate which people know each other).
Top comments (0)