Bird
Raised Fist0
DBMS Theoryknowledge~30 mins

NoSQL database types (document, key-value, column, graph) in DBMS Theory - Mini Project: Build & Apply

Choose your learning style10 modes available

Start learning this pattern below

Jump into concepts and practice - no test required

or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Explore NoSQL Database Types with Sample Data
📖 Scenario: You are working as a junior database assistant in a company that wants to understand different NoSQL database types. They want you to create simple examples of data stored in four common NoSQL types: document, key-value, column, and graph databases.This will help the team see how data looks and is organized differently in each type.
🎯 Goal: Create small sample data structures for each NoSQL database type: document, key-value, column, and graph. You will build each step by adding data or configuration to represent these types clearly.
📋 What You'll Learn
Create a document database example with a collection of user profiles
Create a key-value store example with product prices
Create a column store example with sales data organized by region and month
Create a graph database example with nodes representing people and edges representing friendships
💡 Why This Matters
🌍 Real World
Understanding how different NoSQL databases store and organize data helps in choosing the right database type for specific applications like user profiles, product catalogs, sales analytics, or social networks.
💼 Career
Many jobs in data engineering, backend development, and database administration require knowledge of NoSQL database types and how to model data effectively for each.
Progress0 / 4 steps
1
Create a document database example
Create a variable called document_db that holds a list of dictionaries. Each dictionary represents a user profile with these exact keys and values: {'id': 1, 'name': 'Alice', 'age': 30}, {'id': 2, 'name': 'Bob', 'age': 25}, and {'id': 3, 'name': 'Charlie', 'age': 35}.
DBMS Theory
Hint

Use a list with three dictionaries inside. Each dictionary has keys 'id', 'name', and 'age' with the exact values given.

2
Create a key-value store example
Create a variable called key_value_store that is a dictionary with these exact key-value pairs: 'apple': 0.5, 'banana': 0.3, and 'cherry': 0.2 representing product prices.
DBMS Theory
Hint

Use a dictionary with the exact keys and prices given.

3
Create a column store example
Create a variable called column_store that is a dictionary with keys as region names 'North' and 'South'. Each key maps to another dictionary with months as keys 'Jan' and 'Feb' and sales numbers as values. Use these exact values: North: Jan=100, Feb=150; South: Jan=200, Feb=250.
DBMS Theory
Hint

Use a dictionary with region keys and nested dictionaries for months and sales.

4
Create a graph database example
Create a variable called graph_db that is a dictionary with two keys: 'nodes' and 'edges'. 'nodes' is a list of dictionaries representing people with 'id' and 'name': {'id': 1, 'name': 'Alice'}, {'id': 2, 'name': 'Bob'}, {'id': 3, 'name': 'Charlie'}. 'edges' is a list of dictionaries representing friendships with 'from' and 'to' keys: {'from': 1, 'to': 2}, {'from': 2, 'to': 3}.
DBMS Theory
Hint

Use a dictionary with 'nodes' and 'edges' keys. 'nodes' is a list of people dictionaries, 'edges' is a list of friendship dictionaries.

Practice

(1/5)
1. Which NoSQL database type is best suited for storing data as JSON-like documents with flexible schemas?
easy
A. Graph database
B. Document database
C. Column database
D. Key-value database

Solution

  1. Step 1: Understand document database structure

    Document databases store data as documents, often JSON-like, allowing flexible and nested data.
  2. Step 2: Compare with other NoSQL types

    Key-value stores use simple key-value pairs, column stores organize data by columns, and graph databases focus on relationships.
  3. Final Answer:

    Document database -> Option B
  4. Quick Check:

    Flexible JSON-like storage = Document database [OK]
Hint: JSON-like flexible data means document DB [OK]
Common Mistakes:
  • Confusing key-value with document stores
  • Thinking column stores handle JSON
  • Assuming graph DB stores documents
2. Which of the following is the correct way to describe a key-value store?
easy
A. Stores data as nested JSON documents
B. Stores data as interconnected nodes and edges
C. Stores data in tables with rows and columns
D. Stores data as simple pairs of keys and values

Solution

  1. Step 1: Define key-value store

    Key-value stores save data as pairs: a unique key and its associated value.
  2. Step 2: Eliminate other options

    Nodes and edges describe graph DB, tables describe relational or column DB, nested JSON describes document DB.
  3. Final Answer:

    Stores data as simple pairs of keys and values -> Option D
  4. Quick Check:

    Key-value = key and value pairs [OK]
Hint: Key-value means simple pairs, not complex structures [OK]
Common Mistakes:
  • Mixing graph DB with key-value store
  • Confusing column DB with key-value
  • Thinking document DB is key-value
3. Given a graph database storing people and their friendships, which query result would you expect from a query asking for all friends of 'Alice'?
medium
A. A set of nodes connected to 'Alice' by edges labeled 'friend'
B. A table with columns for friend names and ages
C. A list of key-value pairs with friend names
D. A JSON document containing Alice's profile

Solution

  1. Step 1: Understand graph database query

    Graph DB queries return nodes and edges; friends of Alice are nodes connected by 'friend' edges.
  2. Step 2: Compare expected outputs

    Key-value pairs or tables are not typical graph DB outputs; JSON document is for document DB.
  3. Final Answer:

    A set of nodes connected to 'Alice' by edges labeled 'friend' -> Option A
  4. Quick Check:

    Graph DB returns connected nodes and edges [OK]
Hint: Graph DB queries return nodes and edges, not tables or JSON [OK]
Common Mistakes:
  • Expecting tabular output from graph DB
  • Confusing document DB JSON with graph DB output
  • Thinking key-value pairs represent graph edges
4. You wrote a query to retrieve data from a column-family NoSQL database but got an error. Which mistake likely caused this?
medium
A. Using nested JSON documents in the query
B. Querying nodes and edges instead of tables
C. Trying to access data by key only without specifying column family
D. Using key-value pairs without keys

Solution

  1. Step 1: Understand column-family DB query requirements

    Column-family DBs require specifying column families to access data properly.
  2. Step 2: Identify error cause

    Accessing data by key alone without column family causes errors; other options relate to different DB types or invalid syntax.
  3. Final Answer:

    Trying to access data by key only without specifying column family -> Option C
  4. Quick Check:

    Column DB needs column family in queries [OK]
Hint: Column DB queries must specify column family [OK]
Common Mistakes:
  • Using document DB JSON syntax in column DB
  • Ignoring column family in queries
  • Confusing graph DB queries with column DB
5. You need to design a social network app that stores users, their posts, and complex friend relationships with recommendations. Which NoSQL database type should you choose and why?
hard
A. Graph database, because it efficiently manages complex relationships
B. Key-value database, because it is fastest for any data
C. Document database, because it handles nested posts well
D. Column database, because it stores large tables efficiently

Solution

  1. Step 1: Analyze app data needs

    The app needs to store users, posts, and complex friend relationships with recommendations.
  2. Step 2: Match database type to needs

    Graph DBs excel at managing complex relationships and traversals, ideal for social networks.
  3. Step 3: Evaluate other options

    Document DB handles nested data but less efficient for relationships; key-value is simple but not relationship-focused; column DB is for wide tables, not relationships.
  4. Final Answer:

    Graph database, because it efficiently manages complex relationships -> Option A
  5. Quick Check:

    Complex relationships = Graph DB [OK]
Hint: Complex relationships? Choose graph DB [OK]
Common Mistakes:
  • Choosing document DB for relationship-heavy data
  • Assuming key-value is best for all speed needs
  • Ignoring graph DB strengths in relationships