MS SQL Lesson 2 – SQL vs NoSQL Databases | Dataplexa

SQL vs NoSQL Databases

Two Families of Database Technology

When engineers talk about databases, they almost always mean one of two families: SQL (relational) databases and NoSQL (non-relational) databases. Both store data, but they make very different assumptions about how that data is shaped, how it grows, and how it gets queried.

SQL databases have dominated structured business data since the 1970s. NoSQL databases emerged in the late 2000s to handle data that did not fit neatly into rows and columns — massive write volumes, flexible document structures, real-time feeds. Neither is universally better. The right choice depends on what you are building.

  • SQL — fixed schema, tables with enforced columns, queried with standard SQL
  • NoSQL — flexible schema, data stored as documents, key-value pairs, graphs, or column families
  • Many large systems use both — SQL for transactional core data, NoSQL for high-volume or flexible workloads

SQL — Relational Databases

A relational database stores data in tables with a fixed, predefined schema. Every row must match that schema — columns are defined upfront and data types are enforced. Tables link to each other through primary and foreign keys, and everything is queried with SQL.

The defining strength of relational databases is full ACID transaction support. Even if the server loses power mid-operation, the database will never be left in a broken state. For financial systems, inventory, payroll, and any application where correctness is non-negotiable, this is invaluable.

  • Fixed schema means bad data is rejected before it is ever stored
  • JOIN operations combine data from multiple tables in a single query
  • ACID guarantees correctness under failure and concurrent access
  • SQL is standardised — skills transfer across SQL Server, MySQL, and PostgreSQL

NoSQL — Non-Relational Databases

NoSQL is an umbrella term for databases that do not use the relational table model. The family includes document stores, key-value stores, column-family databases, and graph databases — each optimised for a different problem. What they share is a flexible schema and a design that prioritises horizontal scalability over strict consistency.

Most NoSQL systems trade some ACID guarantees for the ability to scale across hundreds of servers and handle data shapes that would be awkward to model as tables. The CAP theorem describes this trade-off: in a distributed system, you can only fully guarantee two of Consistency, Availability, and Partition tolerance at the same time.

  • Flexible schema — each record can have a different set of fields
  • Scales horizontally across many servers by design
  • Very fast for specific access patterns like key lookups or document retrieval
  • Weaker consistency in most implementations — eventual consistency is common

SQL vs NoSQL — Side by Side

Feature SQL (Relational) NoSQL (Non-Relational)
Data Model Tables with rows and columns Documents, key-value, graph, column-family
Schema Fixed — defined before data is inserted Flexible — each record can differ
Query Language SQL (standardised across engines) Varies by engine — MQL, CQL, Gremlin, etc.
Transactions Full ACID support Varies — often eventual consistency
Scalability Primarily vertical — bigger server Primarily horizontal — more servers
Relationships Enforced via foreign keys and JOINs Handled in application code or embedded
Best For Finance, e-commerce, ERP, reporting Real-time apps, big data, content platforms
Examples MS SQL Server, MySQL, PostgreSQL, Oracle MongoDB, Redis, Cassandra, DynamoDB, Neo4j

The Same Question in SQL and NoSQL

The clearest way to feel the difference is to see the same question answered by both systems. Below is "find all premium members" written first in T-SQL for MS SQL Server, then in MongoDB Query Language. Both return the same data — the syntax and mental model are completely different.

-- T-SQL (MS SQL Server)
-- Reads like plain English — structured, declarative
-- SELECT picks the columns, FROM names the table,
-- WHERE filters rows, ORDER BY sorts the result
SELECT Name, Email, City
FROM   Users
WHERE  Membership = 'premium'
ORDER BY Name ASC;
Name | Email | City
--------------|--------------------|----------
Alice Johnson | alice@example.com | New York
Clara Diaz | clara@example.com | Madrid
Eva Müller | eva@example.com | Berlin
(3 rows affected)
-- MongoDB Query Language (shown for comparison — not T-SQL)
-- Uses a JSON-style filter object instead of SQL keywords
-- db.collection.find( filter, projection ).sort()
db.users.find(
  { membership: "premium" },        -- filter: only premium users
  { name: 1, email: 1, city: 1 }    -- projection: only these fields
).sort({ name: 1 });                 -- sort A to Z by name
{ name: "Alice Johnson", email: "alice@example.com", city: "New York" }
{ name: "Clara Diaz", email: "clara@example.com", city: "Madrid" }
{ name: "Eva Müller", email: "eva@example.com", city: "Berlin" }
  • Both queries return the same three users — same data, completely different syntax
  • SQL is standardised — this T-SQL query runs on SQL Server, MySQL, and PostgreSQL with minor changes
  • Every NoSQL engine has its own query language — MongoDB knowledge does not transfer to Cassandra or Redis
  • SQL lets you JOIN multiple tables in one query — NoSQL typically embeds related data or handles it in application code

When to Choose SQL vs NoSQL

The decision is not about which is better — it is about which fits the problem. Most large-scale systems use both: SQL for the transactional core, NoSQL for high-volume or flexible workloads sitting alongside it.

Choose SQL When… Choose NoSQL When…
Your data has clear, stable relationships Your data structure changes frequently
Data integrity and correctness are critical You need to scale to billions of records horizontally
You need complex multi-table queries and reporting You are storing unstructured or semi-structured data
Regulatory compliance requires auditable records You need extremely high write throughput
Your team already knows SQL Your use case is caching, sessions, or real-time feeds

Why MS SQL Server for This Course

MS SQL Server is one of the most widely deployed relational databases in the world, dominant in enterprise Windows and Microsoft stack environments. It pairs full ACID compliance and a world-class query optimiser with deep integration across Azure, Power BI, .NET, and SSMS — a free, powerful GUI that makes development and administration fast.

For a structured e-commerce platform like DataplexaStore — customers, orders, products, payments, reviews — a relational database is exactly the right tool. The data has clear relationships, correctness is non-negotiable, and SQL Server gives us the performance and tooling to handle it at any scale.

  • Used by tens of thousands of enterprises globally, including Fortune 500 companies
  • T-SQL is closely aligned with ANSI SQL — skills transfer directly to MySQL and PostgreSQL
  • Free Developer Edition gives full Enterprise feature access for learning and development
  • Azure SQL provides a fully managed cloud version with zero server administration

Lesson Summary

Concept What It Means Quick Example
SQL Database Relational database — fixed schema, tables, standard SQL MS SQL Server, MySQL, PostgreSQL
NoSQL Database Non-relational — flexible schema, varied data models MongoDB, Redis, Cassandra, Neo4j
Schema The defined structure of a database — tables, columns, data types Fixed in SQL; flexible in NoSQL
Horizontal Scaling Adding more servers to share the load — common in NoSQL MongoDB sharding across 10 nodes
Vertical Scaling Upgrading one server with more CPU, RAM, or storage — common in SQL Upgrading SQL Server to a 64-core machine
Eventual Consistency Data becomes consistent across all nodes eventually, not immediately Common default in Cassandra and DynamoDB
CAP Theorem A distributed system can only guarantee two of: Consistency, Availability, Partition tolerance Shapes every NoSQL design decision
JOIN SQL operation that combines rows from two or more tables in one query Orders joined to Users to show order + customer name
T-SQL Microsoft's extension of SQL — the language used in MS SQL Server Adds TOP, GETDATE(), stored procedures, variables

Practice Questions

Practice 1. What does ACID stand for?



Practice 2. What type of NoSQL database does MongoDB use to store data?



Practice 3. What term describes adding more servers to distribute load — the scaling approach common in NoSQL?



Practice 4. What SQL feature links rows in one table to rows in another and enforces the relationship?



Practice 5. What consistency model means data will sync across all nodes eventually but not immediately?



Quiz

Quiz 1. Which is a key advantage of SQL databases over most NoSQL databases?






Quiz 2. Which NoSQL type is best for a real-time session cache storing millions of login tokens?






Quiz 3. Why is a relational database the right choice for DataplexaStore's orders and payments?






Quiz 4. What does the CAP theorem state about distributed systems?






Quiz 5. Which scenario is best suited for a NoSQL database?






Next up — What Is MS SQL Server — What makes it different from other databases and why it is the engine used throughout this course.