Courseiva
Data Modeling →hardMultiple Select

C100DEV Data Modeling Practice Question

A development team is designing a schema for an e-commerce application that stores product data. Products have a set of core fields (name, price, description) that are common to all products, but different product categories have unique attributes (e.g., 'screen_size' for electronics, 'fabric' for clothing). Queries often filter on these category-specific attributes. The team wants a flexible schema that supports efficient queries on any attribute. Which TWO of the following design approaches are most appropriate? (Choose two.)

⚠ Common exam trap

The trap here is assuming that separate collections per category or embedding all possible fields are good solutions, but they lead to complexity or inefficiency; the Polymorphic and Attribute patterns are the correct choices for flexible, queryable schemas.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

✓

Use the Polymorphic Pattern to store all products in one collection with a 'category' field and include category-specific fields at the top level.

The Polymorphic Pattern allows a single collection to store documents with different structures, while the Attribute Pattern converts variable attributes into an indexable array of key-value pairs. Together, they provide a flexible schema that supports efficient queries on any category-specific attribute. Both patterns are widely used in MongoDB for handling heterogeneous data and are appropriate here.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✗

    Use the Bucket Pattern to group products by category into buckets of 100 documents.

    Why it's wrong here

    The Bucket Pattern is designed for time-series data or high-volume streams to reduce document count and index size, not for storing heterogeneous product data. Grouping products into buckets would complicate queries that need to filter on individual product attributes and would not provide efficient indexing for those attributes. It is not suitable for this scenario.

  • ✗

    Embed all possible category-specific attributes in every product document, using null for missing attributes.

    Why it's wrong here

    Embedding all possible attributes in every document wastes storage and creates sparse indexes that are inefficient. It also requires schema changes whenever a new attribute is introduced, reducing flexibility. This approach contradicts the goal of a flexible schema and can lead to large documents and poor query performance due to many unused fields.

  • ✓

    Use the Polymorphic Pattern to store all products in one collection with a 'category' field and include category-specific fields at the top level.

    Why this is correct

    The Polymorphic Pattern allows documents in the same collection to have different shapes, which is perfect for products with varying attributes. By including a 'category' field, the application can easily filter by category and access the specific attributes. This approach provides flexibility and is a common MongoDB design pattern for heterogeneous data, enabling efficient queries on category-specific fields when indexed appropriately.

  • ✓

    Use the Attribute Pattern to store category-specific attributes as an array of key-value pairs, and create a compound index on the keys and values.

    Why this is correct

    The Attribute Pattern converts variable attributes into an array of key-value documents, which can be indexed with a compound index on the key and value fields. This allows efficient querying on any attribute without needing to know all possible fields in advance. It is ideal for this scenario where different categories have different attributes and queries filter on them, providing both flexibility and query performance.

  • ✗

    Create a separate collection for each product category with its own schema and indexes.

    Why it's wrong here

    Creating separate collections per category leads to a proliferation of collections and complicates application logic, especially when querying across categories. It also makes it difficult to maintain a unified product catalog. While it allows tailored indexes, it sacrifices the flexibility and simplicity of a single collection, which is a core strength of MongoDB. This approach is generally not recommended for this use case.

About these practice questions

One of 259 original C100DEV practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written and reviewed by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

Last reviewed September 2026 · checked against the official MongoDB exam blueprint

This C100DEV practice question is part of Courseiva's free MongoDB certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the C100DEV exam.