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
This is a Pro chapter
Sign in, then upgrade to Pro or Power to unlock this and the full Databases Mastery library.
Design a MongoDB schema for a product catalog with highly variable attributes.