29. Practice Exercises and Final Assignment
29.6 Modules 11–12: Data Modelling, Hierarchies and Groups
- Classify each table (Orders, Product, Customer, DarkStore, DeliveryPartner, Date) as fact or dimension and justify.
- Draw the star schema on paper with cardinality and filter direction.
- Create the date table with CALENDAR and add Fiscal Year (April–March). Mark it as a date table.
- Why does Month Name sort alphabetically, and how do you fix it?
- Create the inactive Delivered Date relationship. How can a measure use it?
- Why should the Date table relate to
Order Dateand not toOrder DateTime? - Create Location (State › City › Area › Store Name), Date and Product hierarchies. Turn off Auto date/time.
- Create a Region list group (West, Vidarbha, North Maharashtra, Marathwada, South Maharashtra) with an Other group, and a hierarchy Region › City.
- Create 5-minute bins on Delivery Time Mins and ₹100 bins on Amount, and build histograms.
Practice files (fictional): dark_stores_maharashtra.csv, visuals_orders_apr_may_2026.csv
Hints
- A fact records events (many rows); a dimension describes them.
Solutions (checked on the practice files)
- Facts: Orders. Dimensions: Product, Customer, DarkStore, DeliveryPartner, Date.
- Each dimension 1 → * Orders, single direction from dimension to fact.
- Fiscal Year = IF(MONTH([Date]) >= 4, YEAR([Date]), YEAR([Date]) - 1); 06-Apr-2026 → FY 2026-27. Mark as date table.
- Month Name is text; sort it by Month Number (or FY month number for April–March).
- USERELATIONSHIP(Orders[Delivered Date], 'Date'[Date]) inside CALCULATE.
- Order DateTime has times, so it would not match the Date table's whole dates.
- Location hierarchy example from
dark_stores_maharashtra.csv: Region › City › Store. Turn off Auto date/time in Options. - Region totals on the practice data: West Maharashtra ₹850, North Maharashtra ₹800, South Maharashtra ₹450.
- ₹100 bins on Amount: 0–99: 1 (308), 100–199: 1, 200–299: 2, 300–399: 2, 400–499: 2. 5-minute bins on delivery: 5–9: 3, 10–14: 3, 15–19: 1, blank: 1.
Ravindra Bagale's Tip
Friends, many students draw relationships until the visuals "look right" instead of checking cardinality and direction. For each relationship in the exercise, write down why it is one-to-many and single direction before you create it. Don't worry – after doing it two or three times, it becomes a habit.
Ravindra Bagale's Tip – मराठी
मित्रांनो, बरेच students cardinality आणि direction चेक करण्याऐवजी visuals "बरोबर दिसेपर्यंत" relationships काढत राहतात. Exercise मधली प्रत्येक relationship बनवण्याआधी ती one-to-many आणि single direction का आहे ते लिहून काढा. घाबरू नका, दोन-तीन वेळा केलं की सवय होते.
Ravindra Bagale's Tip – हिंदी
दोस्तों, बहुत से students cardinality और direction check करने की जगह तब तक relationships बनाते रहते हैं जब तक visuals "सही न दिखें". Exercise की हर relationship बनाने से पहले लिखो कि वह one-to-many और single direction क्यों है. घबराओ मत, दो-तीन बार करने पर आदत हो जाती है.