Amazon DynamoDB Tutorial 0/6 lessons ~6 min read Lesson 2

    Why NoSQL? Understanding the Database Revolution

    NoSQL databases were created because internet-scale applications changed the rules of database design.

    Course progress0%
    Focus
    15 guided sections
    Practice signal
    Examples included
    Career prep
    Interview Q&A included

    Introduction

    NoSQL databases were created because internet-scale applications changed the rules of database design. Traditional relational databases remain excellent for many systems, but global traffic, mobile apps, gaming, IoT, streaming, and real-time personalization created workloads that needed a different scaling model.

    Imagine a Diwali sale on a large e-commerce platform. At 8:00 PM, millions of users open the app, search products, add items to carts, complete payments, and trigger inventory updates. Every user action becomes a database request. If every request depends on one relational database server, CPU, memory, connections, and disk I/O can become bottlenecks.

    The solution was not simply a bigger server. Companies like Amazon, Google, Facebook, Netflix, Uber, and Airbnb needed databases that could distribute data across many machines. That shift gave rise to NoSQL.

    The story

    In a normal shopping app, a relational database might handle customers, orders, payments, inventory, and shipments beautifully. But during a massive flash sale, the workload changes suddenly. Millions of users search and update carts at the same time. Payment events spike. Inventory counters change continuously. Connections fill up and slow JOIN-heavy queries start blocking critical paths.

    This is where NoSQL thinking begins: instead of forcing every workload through one normalized relational model, split high-volume access patterns into data models that can scale horizontally.

    Purpose of this lesson

    By the end of this lesson, you will understand why relational databases can struggle at internet scale, how SQL and NoSQL evolved, the difference between vertical and horizontal scaling, the four major NoSQL families, the CAP theorem, and how to decide between SQL and NoSQL for real systems.

    Understanding the topic

    Database architecture evolved in phases. Each phase solved the problems of the previous one, but also introduced new limits as application scale increased.

    • File-based storage: simple text files, but hard to search, secure, back up, and update safely.
    • Relational databases: tables, rows, columns, SQL, joins, constraints, and ACID transactions. Still the best choice for many business systems.
    • Internet-scale systems: global users, mobile devices, real-time feeds, streaming, gaming, and IoT created workloads that needed distributed scale.
    • NoSQL databases: flexible data models and horizontal scaling for high-throughput distributed applications.
    FeatureSQLNoSQL
    SchemaFixedFlexible
    ScalingOften vertical firstHorizontal by design
    JOINsSupportedUsually avoided or denormalized
    TransactionsStrong ACID by defaultDepends on database and design
    Best fitBanking, ERP, CRM, reportingSocial, gaming, IoT, sessions, feeds

    Internal architecture

    Relational databases can be scaled, but the simplest scaling path is often vertical: buy a larger machine. NoSQL databases popularized horizontal scaling: distribute data across many machines and add capacity by adding nodes.

    Vertical Scaling

    Make One Server Bigger

    8 CPU / 16 GB RAM
    starter database
    16 CPU / 32 GB RAM
    bigger instance
    64 CPU / 256 GB RAM
    expensive ceiling

    Simple to operate, but costly, limited by hardware, and often a single failure point.

    Horizontal Scaling

    Add More Servers

    Server A
    Data 1-1M
    Server B
    Data 1M-2M
    Server C
    Data 2M-3M

    More scalable and fault tolerant, but requires distributed data design and consistency trade-offs.

    Data flow

    Traditional SQL applications often answer business questions by joining normalized tables. This is powerful, but at billions of rows, joins, indexes, replication, and sharding can become expensive.

    text
    Customers
    |
    | JOIN
    v
    Orders
    |
    | JOIN
    v
    Payments

    NoSQL designs often store data in the shape the application reads it. That can remove expensive joins from hot paths, but it shifts responsibility to the data model: you must understand access patterns before designing tables.

    Visual explanation

    NoSQL does not mean one single database shape. It is a family of database models optimized for different access patterns.

    NoSQL Families

    Choose the Model That Matches the Access Pattern

    Key-Value

    NoSQL
    Key -> Value

    Best for: Sessions, carts, tokens, cache

    Examples: DynamoDB, Redis, Riak

    Document

    NoSQL
    JSON-like documents

    Best for: CMS, product catalogs, blogs

    Examples: MongoDB, CouchDB

    Column-Family

    NoSQL
    Wide rows and column groups

    Best for: Analytics, time-series, big data

    Examples: Cassandra, HBase

    Graph

    NoSQL
    Nodes and relationships

    Best for: Social graphs, fraud, recommendations

    Examples: Neo4j, Amazon Neptune

    Real-world use

    Real-world NoSQL adoption

    • Amazon: shopping carts, customer sessions, product recommendations, and personalization.
    • Netflix: streaming history, viewing recommendations, and device synchronization.
    • Uber: live driver locations, ride requests, dynamic pricing, and trip tracking.
    • Facebook: likes, comments, notifications, user feeds, and high-volume social interactions.
    • Airbnb: property availability, booking sessions, search indexing, and recommendation systems.

    Scalability analysis

    The CAP theorem explains the core tension inside distributed databases. During a network partition, a distributed system cannot perfectly guarantee consistency, availability, and partition tolerance at the same time.

    CAP Theorem

    Distributed Databases Must Make Trade-offs

    C
    Consistency

    Every user sees the latest data.

    A
    Availability

    Every request receives a response.

    P
    Partition Tolerance

    The system continues despite network splits.

    Production insight: network failures are unavoidable, so distributed databases must tolerate partitions and then balance consistency and availability based on business needs.

    Decision framework

    • Choose SQL for banking systems, payroll, ERP, CRM, complex joins, strict relational constraints, and strong ACID workflows.
    • Choose NoSQL for e-commerce carts, social feeds, gaming profiles, chat, IoT telemetry, recommendations, event-driven systems, and serverless applications.
    • Use SQL when relationships and correctness dominate the design.
    • Use NoSQL when scale, flexible shape, high availability, and access-pattern-driven reads dominate the design.
    • Do not choose a database by popularity. Choose it by access patterns, consistency needs, scale, operations model, and cost.

    Best practices

    • Select the database based on application access patterns.
    • Understand scalability requirements before choosing a database.
    • Avoid assuming NoSQL is always faster than SQL.
    • Design for distributed systems from the beginning.
    • Benchmark performance with realistic production workloads.
    • Document consistency requirements for each critical feature.

    Common mistakes

    • Assuming SQL is outdated.
    • Using NoSQL for highly relational applications.
    • Ignoring consistency requirements.
    • Choosing a database based only on popularity.
    • Forgetting that every database involves trade-offs.
    • Moving to NoSQL without redesigning the data model around access patterns.

    Advanced interview questions

    Interview Prep

    Practice concise answers, then expand each card for the explanation.

    5 questions
    1BeginnerQuestionWhat does NoSQL mean?+

    Answer

    NoSQL means Not Only SQL. It refers to databases designed for flexible schemas, distributed architecture, horizontal scaling, and high-volume application workloads.
    2BeginnerQuestionWhy were NoSQL databases introduced?+

    Answer

    They were introduced to handle scalability, performance, availability, and flexibility challenges that appeared in large-scale internet applications with millions or billions of users.
    3IntermediateQuestionWhat are the four major categories of NoSQL databases?+

    Answer

    The four major categories are key-value, document, column-family, and graph databases.
    4IntermediateQuestionWhat is horizontal scaling?+

    Answer

    Horizontal scaling means adding more servers to increase capacity instead of upgrading one server. This lets distributed databases spread data and traffic across many machines.
    5AdvancedQuestionExplain the CAP theorem.+

    Answer

    The CAP theorem states that a distributed system cannot perfectly guarantee Consistency, Availability, and Partition Tolerance at the same time. Since network partitions are inevitable, systems must balance consistency and availability based on business requirements.

    Hands-on exercise

    You are designing a food delivery application. Decide whether SQL or NoSQL is a better fit for each feature, then explain your reason.

    FeatureSQL or NoSQL?Reason
    Customer Accounts?
    Restaurant Menu?
    Live Driver Location?
    Payment Transactions?
    Order History?
    User Notifications?

    Summary

    NoSQL databases were created because modern internet applications needed flexible data models, horizontal scaling, high availability, and distributed architectures. SQL is not outdated; it remains the right choice for many relational and transactional systems. NoSQL is another tool for workloads where access patterns, scale, and distributed performance matter most.

    Next: Lesson 3 covers DynamoDB core concepts: tables, items, attributes, primary keys, partition keys, sort keys, partitions, key design strategies, and real-world table examples.

    Ready to mark this lesson complete?Track your journey across the entire course.