MongoDB Data Modeling Decisions Quiz Quiz

  1. Embedding vs. Referencing Basics

    In MongoDB, which use case is generally best for embedding documents?

    1. Storing an address within a user document
    2. Linking a user to multiple orders across different collections
    3. Creating separate collections for user preferences
    4. Storing products and their reviews in different collections
    5. Using references for small, unchanging child objects
  2. When to Use Referencing

    Which scenario is a good case for referencing instead of embedding documents in MongoDB?

    1. When child documents are accessed independently from the parent
    2. When the child object is always loaded with the parent
    3. For small, rarely changing data tightly related to the parent
    4. When you want to avoid using ObjectId fields
    5. If parent and child data must always be updated together
  3. Choosing Collections

    What is a recommended practice when creating collections in MongoDB for a blog with posts and comments?

    1. Embed comments within each post document
    2. Store each comment in a separate collection
    3. Put both posts and comments in a single 'postscomments' colllection
    4. Store comments as separate databases
    5. Avoid collections and use JSON files instead
  4. Dealing With Document Growth

    If a MongoDB document could grow unbounded over time (such as a user with messages), what is the best modeling choice?

    1. Reference messages from the user document
    2. Embed all messages inside the user document
    3. Create a capped collection for users
    4. Store user messages in memory only
    5. Keep messages as a single field in the user record
  5. Modeling Many-to-Many Relationships

    Suppose you are modeling a 'students' and 'courses' relationship, where each student can enroll in many courses and each course can have many students. What is a typical approach?

    1. Reference course Ids in the student document and student Ids in the course document
    2. Embed all students inside each course document
    3. Create one collection for both students and courses mixed together
    4. Only store course Ids within students and not vice versa
    5. Create a flat collection without nesting or references
  6. Minimizing Write Operations

    Which modeling choice can help minimize write operations in a high-traffic e-commerce application?

    1. Store product reviews in a separate 'reviews' collection and reference them from products
    2. Embed all reviews directly inside each product document, regardless of review count
    3. Delete and rewrite entire product documents on each review
    4. Avoid referencing and use just arrays of review IDs
    5. Store reviews in the same collection as products
  7. Denormalization in MongoDB

    Why might you choose to denormalize data by embedding documents in MongoDB?

    1. To improve read performance by reducing the number of queries
    2. To enforce strict relational constraints
    3. To avoid using ObjectId fields
    4. To decrease storage usage at any scale
    5. Because normalization is always slower in MongoDB
  8. Implications of Large Document Size

    What problem can arise if you embed too much data within a single MongoDB document?

    1. You might exceed the 16MB document size limit
    2. Queries will always run faster
    3. Index sizes will shrink
    4. You can store unlimited child documents per parent
    5. Referential integrity is automatically enforced
  9. Code: Referencing Example

    Given this scenario:nnusers: { _id: 1, name: 'Eva', favoriteBook: ObjectId('abcd1234') }nbooks: { _id: ObjectId('abcd1234'), title: 'MongoDB Guide' }nnWhat modeling approach is being used for favorite books?

    1. Referencing
    2. Emedding
    3. Normalizzation
    4. Flat data
    5. Mirroring
  10. Choosing Between Embedding and Referencing

    If a web application needs fast access to a user's profile along with their social media links, which data model is generally suitable?

    1. Embed social media links inside the user document
    2. Reference each link in a separate collection
    3. Store all users and all links in the same collection
    4. Use one huge document for all user profiles and links
    5. Save links as a comma-separated string