advancedTop 30 Scenario-Based Questions

Design a MongoDB schema for a product catalog with highly variable attributes.

JSONB/document model shines here: 1) Single collection with embedded attributes: {_id, name, category, price, attributes:{ram:16, cpu:'i7'} for laptops; {size:'XL', color:'red'} for shirts}. 2) Indexes on common attributes: createIndex({'attributes.ram':1}) for laptop-specific queries. 3) Wildcard index: createIndex({'attributes.[* ]':1}) for flexible attribute queries (MongoDB 4.2+). 4) Schema va

Ready to master this question?

Generate a complete walkthrough — background, the full answer in plain language, a working code example explained line by line, a real-world scenario, common mistakes, and how this same question gets asked in different ways.

Sign in to generate a response

Next Step

Continue to How would you migrate from a monolithic PostgreSQL to a microservices NoSQL architecture?← Back to all NoSQL questions