Timedora

Choosing a Nonrelational Database Model

A practical comparison of nonrelational database models, their access patterns, and the tradeoffs that guide selection.

Start with the and Workload

Start with the and Workload

A organizes data using a model other than traditional relational tables linked by keys. is a common name for these systems, but it does not mean “no queries” or “no structure.”

The important difference is how each family organizes data and supports the application's common access patterns. For example, a is designed around lookup by a known key, while a makes relationships between entities central. Choosing a database therefore starts with the questions and updates the application needs to handle—not with the assumption that one family is best for every job.

Direct Lookups and Flexible Documents

Direct Lookups and Flexible Documents

A stores each record as a pair: a unique key identifies its value. In the source example, the key session:42 is used to store and retrieve the value user=17. This is a direct lookup: the application already knows the key. Such a model suits data retrieved by a known identifier, including sessions, caches, and counters. If the key is unknown, however, finding records by their contents may require extra indexes or a scan; applications also need a consistent way to name keys.

A instead stores records as documents with fields that may contain nested documents or arrays. A collection can hold documents with different fields, which can accommodate records that vary or change. A typical query filters by field values: the source example selects inventory documents whose status is A and whose quantity is below 30.

Related information can be embedded in one or stored separately and linked using references. Embedding can make retrieval convenient in one operation and can support an atomic update to that , but it may duplicate data or make documents too large. References can suit large, independently accessed, or frequently changing related data, but may require additional reads or joins. Flexible documents still need deliberate modeling and indexes for important queries.

Partitions and Relationships

Partitions and Relationships

A organizes data into rows and columns, but is designed for partitioned, distributed storage rather than arbitrary relational joins. In Cassandra, the determines where rows are stored, and optional clustering columns order rows within a partition. Because of this, tables are designed around expected queries; different access patterns may call for separate tables.

The source's sensor-readings example uses sensor ID and day as the , then orders readings by timestamp. This layout supports a specific query: retrieving readings for a known sensor on a known day. The design makes that query direct, but the partition choices matter. An oversized or heavily used partition can become a storage or traffic hotspot. Cassandra does not provide distributed joins or cross-partition transactions, and its consistency level can be selected for operations, trading off how many replicas must respond against latency and availability. Reads or writes outside the designed patterns may be difficult or inefficient, and serving different queries can require duplicated data in separate tables.

A is organized around nodes (entities) and relationships (edges). Rather than representing every connection indirectly through foreign keys, the graph makes connections explicit. A query can describe a relationship pattern, such as finding people who know a particular person. This makes graphs useful when an application needs to follow many relationships, as in social networks, recommendations, or fraud connections. For simple lookups or aggregations over independent records, graph modeling may add unnecessary complexity; the database and query language also need to fit the graph model.

Choose for the Access Patterns

Choose for the Access Patterns

Choose among database families by starting with the workload. List the queries and updates the application must perform, then ask which model supports them directly. A lookup by a known identifier points toward the key-value pattern; filtering nested records by fields fits the pattern; reading rows within a planned partition fits the wide-column pattern; and following many connections fits the graph pattern.

Then weigh consistency needs, scaling and availability goals, operational complexity, and how the data is likely to change. The best fit is not determined by a family’s advantages in isolation: a model that makes required queries awkward or inefficient may be a poor choice despite other strengths. No family is universally best.

Compare Database Families
FamilyOrganizationTypical queryMain tradeoff
Key-valueKey and valueRead or update by known keyContent searches may need added structures
DocumentNested documentsFilter, sort, or aggregate by fieldsFlexible records need careful modeling and indexing
Wide-columnPartitions, rows, and columnsRead rows within a designed partitionPartition design constrains query flexibility
GraphNodes and relationshipsMatch and traverse connectionsMay add complexity for simple record lookups
The families differ in how data is organized, which queries they directly support, and their main tradeoffs.
  • : The usual ways an application reads or changes its data.

  • : An entity represented in a .

  • : How well a database's organization supports an application's common queries and updates.