- Introduced by
- NoSQL community pioneers (various founders)
- Year
- 2009
- Type
- Data modeling approach
- Family
- Non-Relational Data Modeling
What does it do?
NoSQL schema design is the practice of structuring data for non-relational database systems around the queries an application will run and the scale it must reach.
Where relational design normalizes data to remove redundancy, NoSQL design often accepts duplication and nested, embedded structures so that common reads can be served without joins across distributed nodes. The choices are therefore driven by access patterns, which need to be known before the schema is fixed.
The intuition behind the method
Relational schemas split data into normalized tables and reassemble it at query time with joins. Document, key-value and wide-column stores generally cannot join efficiently across partitions spread over many servers, so the schema is shaped to place data that is read together in the same record or partition. The cost is that a fact stored in several places must be updated in several places, and the database may not guarantee that all copies change together. Cattell's review of SQL and NoSQL stores describes this trade-off: many of these systems give up database-wide transaction consistency in exchange for higher availability and scalability.
History
The NoSQL label covers non-relational systems that developed in response to the scalability demands of web-scale applications. Cattell's 2011 review contrasts these systems by data model, consistency mechanism, storage, durability, availability and query support, and notes that they were originally motivated by Web 2.0 applications serving very large numbers of users. Products such as MongoDB, Cassandra, Couchbase, DynamoDB and Firestore are named here as examples only. Each has its own modeling conventions, and this page does not compare them.
When to use it
Choose NoSQL schema design when the main queries are known and reasonably stable, when data volume or write rate makes a single relational server or join-heavy queries a constraint, and when the data has a naturally nested or varying structure. It also fits systems that can accept eventual consistency for some reads and writes. Do not choose it when queries are unpredictable or ad hoc, when many multi-record operations must be strictly consistent, or when the data is highly interconnected and relationship traversal is the main workload. In those cases a normalized relational design or a graph model is usually easier to justify.
Limitations and considerations
- Duplicated values must be updated wherever they appear; a change that misses one copy leaves the database holding conflicting versions of the same fact.
- Cattell notes that many of these systems sacrifice database-wide transaction consistency for availability and scalability, so invariants that span several records often have to be enforced in application code.
- The schema encodes the anticipated queries; a new query pattern can require restructuring the data and rewriting existing records.
Source conditions do not replace independent scientific review or validation by an analysis engine.
Strengths
- Reads that need a whole entity are served from one record or partition, avoiding the cross-table joins a normalized design would require.
- Partitioning by key spreads both data and writes across many servers, which is the scaling goal Cattell identifies for these systems.
- Records can hold fields that vary between items, so new attributes can be added without a schema migration on the database side, although the application must still handle older record shapes.
Applications
- E-commerce product catalogs with variable attributes across categories stored as flexible documents
- Social media systems with denormalized user profiles and activity feeds for rapid access
- IoT platforms storing sensor readings as time-series records organized for time-range queries; a NoSQL schema fits only if the store's read and write needs are met by it, and dedicated time-series stores are an alternative to weigh
- Content management systems storing articles with embedded comments and metadata for single-query access
How it works
How it works
List the operations the application performs, with their frequency, the read/write mix, and the latency requirements for each. Without this list, the later steps have no basis for deciding what to embed.
Identify which entities are read or written together, and how they relate (one-to-few, one-to-many, or many-to-many). Groups that are accessed together are the candidates for co-location within one record or partition.
For each relationship, decide whether the related data is embedded inside the parent document or stored as a reference to it. Embedding favors reads that need the whole group; referencing suits data that changes independently or is shared by many parents, at the cost of consistency work in the application.
Create the collections or tables with the chosen structures, select partition or shard keys, and add indexes for the main query paths. To check a partition key against the write pattern, list the keys that receive the highest write volume and count how many distinct values carry most of that traffic. Prefer a key whose values spread writes evenly across nodes, since a key with concentrated values sends most traffic to one node.
Run the defined queries and writes against realistic data volumes, and measure latency and document size. Judge the schema against criteria set by the application's requirements: a target latency for each main query, a document size below the store's maximum, and a maximum acceptable staleness for any duplicated data. Confirm that every update touching duplicated data is covered. Where the database cannot keep copies consistent, record the consistency window the application accepts. A schema that misses these criteria needs redesign.
Common pitfalls
- Using references for most relationships, which recreates the join-heavy design that embedding was meant to avoid.
- Embedding lists that grow without bound inside a single record, so documents become slow to read, write and transmit.
- Choosing a partition key with concentrated values, so most requests land on one node and the benefit of distribution is lost.
- Treating a schema-less store as having no design: the application still depends on a record structure and should validate it.
Frequently asked questions
Should I embed data or reference it?
Embed when the data is read together with its parent and the embedded part stays bounded in size. Immutable data can be embedded without consistency risk, but it is still duplicated wherever it is embedded, and embedding does not justify unbounded lists (see the pitfall on unbounded growth). Reference when data changes frequently, is shared across many documents, or must stay consistent.
How do I handle updates when data is denormalized?
Identify where duplicates exist and ensure updates are propagated to all locations. Use atomic operations for single documents; for multi-document updates, accept eventual consistency or implement application-level transactions.
What indexing strategies work best for NoSQL?
Index fields used in query filters and sorts. Compound indexes help queries filtering on multiple fields. Avoid indexing large arrays unless queries specifically need array filtering.
How does NoSQL schema design differ from relational?
Relational prioritizes normalization (minimize redundancy); NoSQL prioritizes query performance (denormalize for speed). Relational uses joins; NoSQL embeds or duplicates. The trade-off is simplicity and speed versus consistency and flexibility.
Sources
Cattell, R. (2011). Scalable SQL and NoSQL data stores. ACM SIGMOD Record, 39(4), 12-27.
Open DOI referenceChodorow, K. (2013). MongoDB: The Definitive Guide (2nd ed.). Sebastopol, CA: O'Reilly.
Open publication referenceSadalage, P. J., & Fowler, M. (2012). NoSQL Distilled: A Brief Guide to the Emerging World of Polyglot Persistence. Addison-Wesley.
Open publication reference