Skip to content
GetITechSkills

Data and Databases

Relational vs NoSQL Databases

Intermediate · Concept · 6 min read · Updated October 30, 2026

Picture a cook with a box of recipe cards. Each card lists a title, a cooking time and a set of ingredients. Some cards carry extra notes, such as a tip for leftovers. There are two natural ways to turn this box into a database. One splits each card into neat tables. The other keeps each card whole, as a single document. Those two choices are a good picture of the difference between relational and NoSQL databases.

This entry explains how each style stores data, what trade-offs follow, and how to decide between them. It assumes you know what a database is, as covered in what a database is. It does not rank products. Both styles are mature, widely used and good at different jobs.

Two ways to store the same recipe

Start with the relational version. A recipes table holds one row per recipe, and a recipe_ingredients table holds one row per ingredient, pointing back to its recipe through recipe_id.

recipe_id title minutes
1 Tomato soup 35
2 Lentil curry 45
recipe_id item amount
1 tomatoes 800 g
1 onion 1
1 vegetable stock 500 ml
2 red lentils 250 g
2 onion 2

To read one full recipe, you combine the two tables with a join:

SELECT r.title, i.item, i.amount
FROM recipes AS r
JOIN recipe_ingredients AS i ON i.recipe_id = r.recipe_id
WHERE r.title = 'Tomato soup'
ORDER BY i.item;
title item amount
Tomato soup onion 1
Tomato soup tomatoes 800 g
Tomato soup vegetable stock 500 ml

Now the document version. Each recipe is one self-contained piece of JSON, with its ingredients nested inside:

{
  "title": "Lentil curry",
  "minutes": 45,
  "ingredients": [
    { "item": "red lentils", "amount": "250 g" },
    { "item": "onion", "amount": "2" }
  ],
  "tip": "Tastes better the next day"
}

Reading a recipe means fetching one document. There is no join, because the ingredients travel with the recipe. The Tomato soup document could have no tip field at all, and nothing would break. Documents in the same collection are allowed to differ.

How relational databases work

A relational database stores data in tables, the structure described in tables, rows, columns and keys. PostgreSQL's documentation defines the pieces: a table is a named collection of rows, each row has the same named columns, and each column has a data type.

Four traits define the style:

  • A schema decided in advance. You declare the tables, columns and types before adding data.
  • Relationships through keys. Tables point at each other with foreign keys, and joins combine them when you read.
  • SQL as the common language. The core of SQL is shared across products, although each adds its own extras.
  • Strong guarantees for changes. Transactions let several changes succeed or fail together, which matters for things like payments and inventory.

What NoSQL means

NoSQL is a loose label for databases that do not use the relational table model as their main design. Some people read it as "not only SQL". It covers several different families:

  • Document databases store flexible records, usually written like JSON.
  • Key-value stores return a value when you give a key, much like a dictionary.
  • Wide-column stores group data by column families, which suits very large, spread-out datasets.
  • Graph databases store things and the links between them, and are good at questions about connections.

Because the label covers so many designs, statements such as "NoSQL is faster" or "NoSQL scales better" are too broad to be useful. Judge a specific product against a specific need.

MongoDB's manual describes the document model this way: related data can be embedded inside a parent document, or kept in separate collections and linked by an identifier. It also says documents in one collection can have different fields, so the structure can change over time. A principle it highlights is to store together the data that is accessed together.

The trade-offs side by side

Topic Relational Document-style NoSQL
Structure Fixed up front, enforced by the database Flexible, can differ per document
Related data Split into tables, combined with joins Embedded in one document, or referenced by ID
Repeated facts Stored once, which keeps them consistent May be copied into many documents
Changing the design Needs a deliberate change to the tables Often simple to add a new field
Multi-record guarantees A long-standing core feature Varies by product, so check the documentation
Query language SQL, shared across products Specific to each product

None of these rows is a verdict. Flexibility is a benefit when the shape of your data is still changing. It is a cost when you need the database to enforce rules, because the application must then do that work.

How to choose

Ask these questions about your project:

  1. Is the data naturally tabular and connected? Customers, products and payments fit tables well.
  2. Do you need strict rules? If a wrong or duplicate value would be costly, a relational schema helps.
  3. Do records vary a lot in shape? Product catalogs with very different attributes per item often fit documents.
  4. How will you read the data? If you almost always fetch one whole record at a time, a document can be convenient. If you ask many different questions across many kinds of records, SQL's flexibility is valuable.
  5. What does your team already know? Skills and tooling count. A familiar tool used well beats an exotic one used badly.

For many projects, a relational database is a safe default, because its structure keeps data consistent as the project grows. Choose another style when a clear need points to it.

The lines are blurring

The two worlds borrow from each other. PostgreSQL, a relational system, has json and jsonb column types that store JSON documents inside a table. Its documentation recommends jsonb for most applications, since it is faster to process and supports indexing. So a team can keep ordinary columns for the stable parts of a record and a JSON column for the flexible parts.

Document databases have likewise added features such as schema validation, which lets you require some structure when you want it. In practice, many systems use more than one kind of database, each for what it does best.

Common mistakes

  • Choosing NoSQL because it sounds modern. Pick the tool that fits the data and the questions, not the trend.
  • Choosing relational for data that has no stable shape, then fighting the schema. If every record differs, forcing one table can leave many empty columns.
  • Copying the same fact into many documents. When it changes, you must update every copy, and missed copies create contradictions.
  • Treating "schema-less" as "no design needed". Flexible databases still need planning. The structure just lives in your application instead of the database.
  • Assuming one style fits the whole system. Different parts of a system can use different databases.
  • Comparing products instead of models. Judge the data model first and the brand second.

FAQ

Is NoSQL a replacement for SQL?

No. They solve overlapping problems with different designs. Relational databases remain widely used, and NoSQL databases cover needs that fit them well.

Can a relational database store JSON?

Yes. PostgreSQL offers JSON column types, and other relational systems have similar features, with details that vary by product.

Which is easier for a beginner?

Relational databases have more up-front structure, but the rules are consistent and the skills transfer across products. Starting with reading data with SELECT is a practical first step.

Do NoSQL databases have no structure at all?

They have structure, but it is often defined by the application or by optional validation rules rather than a required table design.

What should I learn first for an IT career?

Relational databases and SQL appear in many roles that touch data, so they are a sound foundation. Learning one NoSQL database afterward is easier once you understand the trade-offs above. The Data and Databases area lists the next steps in order.

Sources

  1. PostgreSQL Documentation: Concepts (Tutorial) (opens in a new tab) — The PostgreSQL Global Development Group. Tables, rows, columns and data types in a relational system
  2. PostgreSQL Documentation: JSON Types (opens in a new tab) — The PostgreSQL Global Development Group. How a relational database can also store JSON documents
  3. MongoDB Manual: Data Modeling (opens in a new tab) — MongoDB, Inc.. The document model, flexible schemas, embedding and referencing

Next in Data and Databases: CSV vs JSON: Common Data File Formats

  • Data and Databases

    What Is a Database?

    A database stores organized data so it can be searched, changed and protected. Learn what one is, how it differs from a file, and where you already use one.

    • Beginner
    • Concept
    • 6 min read

    Updated October 30, 2026

  • Data and Databases

    CSV vs JSON: Common Data File Formats

    Compare CSV and JSON: how each file is written, what each handles well, where each breaks, and which to pick, shown with one food truck menu.

    • Beginner
    • Concept
    • 6 min read

    Updated October 30, 2026

  • Data and Databases

    Database Design Basics: Entities and Relationships

    Learn how to design a small database: list entities, choose keys, map one-to-many and many-to-many relationships, and avoid repeated data, with a music school.

    • Intermediate
    • Skill
    • 6 min read

    Updated October 30, 2026