Bird
Raised Fist0
Intro to Computingfundamentals

NoSQL and alternative models in Intro to Computing - Flowchart & Logic Diagram

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
Flowchart Mode data not available for this pattern.

Practice

(1/5)
1. Which of the following best describes a key-value NoSQL database?
easy
A. Stores data as pairs of keys and their associated values
B. Organizes data strictly in rows and columns like a spreadsheet
C. Uses SQL queries to retrieve data from tables
D. Represents data as nodes and edges in a network

Solution

  1. Step 1: Understand key-value database structure

    Key-value databases store data as unique keys linked to values, like a dictionary.
  2. Step 2: Compare with other database types

    Relational databases use tables; graph databases use nodes and edges; key-value is simpler with pairs.
  3. Final Answer:

    Stores data as pairs of keys and their associated values -> Option A
  4. Quick Check:

    Key-value = key-value pairs [OK]
Hint: Key-value means simple pairs: key and its value [OK]
Common Mistakes:
  • Confusing key-value with relational tables
  • Thinking key-value uses SQL queries
  • Mixing key-value with graph database concepts
2. Which of the following is the correct way to represent a document in a document-based NoSQL database?
easy
A. {"name": "Alice", "age": 30}
B. ("name", "Alice", "age", 30)
C. ["name", "Alice", "age", 30]
D. name: Alice; age: 30;

Solution

  1. Step 1: Identify document format in NoSQL

    Document databases use JSON-like objects with key-value pairs inside braces {}.
  2. Step 2: Check each option's format

    {"name": "Alice", "age": 30} uses JSON object syntax; others use tuples, lists, or invalid syntax.
  3. Final Answer:

    {"name": "Alice", "age": 30} -> Option A
  4. Quick Check:

    Document = JSON object format [OK]
Hint: Documents look like JSON objects with braces {} [OK]
Common Mistakes:
  • Using parentheses instead of braces
  • Confusing lists with documents
  • Writing invalid key-value syntax
3. Given a graph database storing people and their friendships, which query result would you expect from: MATCH (p:Person)-[:FRIEND]->(f:Person) RETURN p.name, f.name?
medium
A. Only persons who have no friends
B. All person names without any relationships
C. A count of all persons in the database
D. Pairs of person names where the first is friends with the second

Solution

  1. Step 1: Understand the MATCH pattern

    The query finds nodes labeled Person connected by FRIEND relationships from p to f.
  2. Step 2: Interpret the RETURN clause

    It returns the names of p and f, showing pairs where p is friends with f.
  3. Final Answer:

    Pairs of person names where the first is friends with the second -> Option D
  4. Quick Check:

    Graph query returns connected pairs [OK]
Hint: MATCH with relationship returns connected node pairs [OK]
Common Mistakes:
  • Thinking it returns all persons regardless of friendship
  • Expecting counts instead of pairs
  • Confusing direction of FRIEND relationship
4. You wrote this query for a column-family NoSQL database: SELECT name, age FROM users WHERE age > 25. It returns an error. What is the likely problem?
medium
A. The age column cannot be filtered
B. The WHERE clause is missing a semicolon
C. Column-family databases do not use SQL syntax like SELECT
D. The table name 'users' is misspelled

Solution

  1. Step 1: Recall column-family query style

    Column-family NoSQL databases like Cassandra use CQL, similar but not always supporting full SQL syntax.
  2. Step 2: Identify syntax mismatch

    Some column-family databases require specific query formats; plain SQL SELECT with WHERE may cause errors.
  3. Final Answer:

    Column-family databases do not use SQL syntax like SELECT -> Option C
  4. Quick Check:

    Column-family ≠ standard SQL [OK]
Hint: Column-family queries differ from standard SQL [OK]
Common Mistakes:
  • Assuming all NoSQL use SQL syntax
  • Ignoring database-specific query language
  • Blaming typos without checking syntax
5. You want to model a social network with users and their followers using a NoSQL database. Which model is best suited to efficiently represent and query these relationships?
hard
A. Key-value store, because it stores user IDs and follower counts
B. Graph database, because it stores nodes and edges representing users and follower links
C. Document database, because it stores user profiles as JSON documents
D. Column-family database, because it stores data in wide tables

Solution

  1. Step 1: Understand social network data needs

    Social networks have complex, connected data with users linked by follower relationships.
  2. Step 2: Match data needs to NoSQL model

    Graph databases excel at storing and querying connected nodes and edges efficiently.
  3. Step 3: Compare other models

    Key-value and document stores handle data but less efficient for complex relationships; column-family is for wide tables.
  4. Final Answer:

    Graph database, because it stores nodes and edges representing users and follower links -> Option B
  5. Quick Check:

    Connected data = Graph database [OK]
Hint: Use graph DB for connected user relationships [OK]
Common Mistakes:
  • Choosing key-value for relationship queries
  • Assuming document DB handles connections best
  • Ignoring graph model strengths