NoSQL databases (concept)

Computer Science · Databases

Question 1 of 10

0

    Sharding a database means:

    Stuck? Read the explanation

    Unlocks at a streak of 5 correct answers in a row.

    Print a free worksheet (PDF)

    Embed this practice on your site or class page

    Paste this HTML into your page. Students practise right there; it is free and needs no account.

    NoSQL databases (concept) explained

    NoSQL databases store data in forms other than fixed relational tables, such as documents, key-value pairs, wide columns or graphs. They trade some of the strict structure and joins of relational databases for flexible schemas and easier spreading of data across many servers.

    Relational databases store data in tables with a fixed schema and link tables with joins. NoSQL is a broad term for systems that do not follow that model. Common types include:

    • Key-value stores, which map a key to a value, often used for caches and session data.
    • Document stores, which keep a self-contained record, often in JSON form, that can contain nested fields and lists.
    • Graph databases, which store nodes and the relationships between them.

    The main benefits are flexible schemas and horizontal scaling, meaning servers can be added to hold more data. The costs are that joins across collections are often limited or done in application code.

    Worked example

    A hypothetical app builds a profile page from a user record, the user's 3 most recent orders and the items in those orders.

    1. In a relational design the data sits in three tables (users, orders and items), so the app may need 3 queries, or one larger JOIN query, per page view.
    2. In a document design the user and recent orders are stored together, so one read returns everything.
    3. At 10,000 page views per minute, that is 3×10,000=30,0003 \times 10{,}000 = 30{,}000 reads per minute, compared with 1×10,000=10,0001 \times 10{,}000 = 10{,}000 reads per minute.

    The document design reads less, but duplicated data must be updated everywhere it is stored.

    What you will practise

    105 multiple-choice questions (Easy, Medium, Hard). Each answer is followed by an explanation.

    Example questions

    • NoSQL databases are:
    • Document stores hold:
    • Key-value stores:
    • NoSQL excels at:
    • A trade-off of NoSQL is:
    • Which type of NoSQL database stores data as nodes and edges?
    • Traditional SQL databases store data in:
    • MongoDB is an example of a:

    …and 97 more.