Question: 1 . Data Model Design with javascript: Design a MongoDB schema to store customer profiles, transactions, and products. Your schema should be efficient and support
Data Model Design with javascript:
Design a MongoDB schema to store customer profiles, transactions, and products. Your schema should be efficient and support quick queries for analysis.
Requirements:
ACustomercollection with information likecustomeridnameemailphoneloyaltystatus, andcreatedat
ATransactioncollection to track each purchase. Each document should include fields liketransactionidcustomeridproductsarray of product itemstotalamount,dateandstorelocation.
AProductcollection that storesproductidnamecategorypriceandbrand
Design considerations for managinghigh cardinality fieldslike product categories and customer locations.
Data Ingestion:
Write a script PythonNodejsor MongoDB shellto insert sample data into MongoDB for customers each with transactions
Each transaction should include product items, selected randomly from a product catalog.
Query Development:
Create MongoDB queries to support the following business requirements:
Customer Insights: Query the total spending per customer, sorted by highest to lowest.
Top Products: Identify the top most frequently purchased products.
Purchase Trends: Aggregate monthly spending trends across all customers for the last months
Customer Segmentation: Segment customers based on their spending behavior:
High Spenders: Customers who spend over $annually
Frequent Buyers: Customers who have made more than purchases in the last months
Infrequent Buyers: Customers who have fewer than transactions
Indexing: Identify and create indexes that will optimize query performance.
Aggregation Pipeline for Reporting:
Design an aggregation pipeline to create a report that shows:
The average transaction amount per customer.
Most popular categories by total sales.
Percentage of revenue by loyalty status egGoldSilverBronze
Data Visualization RecommendationsBonus:
Propose MongoDBcompatible BI tools or frontend frameworks that could be used to visualize the data on a customer insights dashboard.
Describe a few example visualizations egbar charts for top products, line graphs for monthly spending trends
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
