Non-Relational Database
Common mistakes
- Choosing NoSQL to skip the schema, then validating nothing and ending up with inconsistent data.
- Doing joins by hand in app code with many queries because the data was modeled like SQL tables.
Key points
- Documents are shaped around the app's read queries, not copied from a normalized SQL schema.
- Unbounded lists, like all comments on a post, are separate documents, not one growing array.
- Fields used in queries have indexes.
Interview questions
What are the main types of NoSQL databases?
Document stores, key-value stores, wide-column stores and graph databases. Each is optimized for a different access pattern.
Do NoSQL databases support transactions?
Many do, but often with limits, such as within one document or partition. Check the guarantees of the specific database.
Is NoSQL faster than SQL?
Not in general. It can be faster for the access pattern it was modeled for, and slower for queries it wasn't designed around.