Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
Star Schema for Device Telemetry
00:00
5 left

Star Schema for Device Telemetry

HardSQL · PostgreSQL

Problem

Design a dimensional star schema to track global device telemetry and recurring subscription lifecycle events at Apple.

Represent the design with device and subscription dimensions plus a combined event fact table. Write a query that summarizes January 2025 telemetry for subscriptions whose latest lifecycle status is available by the end of that month.

Output

  1. One row per region, device type, and subscription tier
  2. Columns: region, device_type, subscription_tier, active_subscriptions, telemetry_event_count, and avg_cpu_percent
  3. Include canceled subscriptions when telemetry exists, with zero active subscriptions
  4. Sort by region, device_type, and subscription_tier ascending

Schema

dim_device
ColumnTypeDescription
device_idPKINTSurrogate key for the device dimension
device_typeVARCHAR(50)Apple device category
regionVARCHAR(50)Device operating region
dim_subscription
ColumnTypeDescription
subscription_idPKINTSurrogate key for the subscription
subscription_tierVARCHAR(80)Apple subscription product or tier
fact_device_subscription_event
ColumnTypeDescription
event_idPKINTUnique telemetry or lifecycle event identifier
device_idINTReferenced device dimension key
subscription_idINTReferenced subscription dimension key
event_typeVARCHAR(30)Telemetry or subscription lifecycle event type
event_statusVARCHAR(30)Lifecycle status represented by the event
event_tsTIMESTAMPUTC timestamp when the event occurred
cpu_percentDECIMAL(5,2)CPU utilization captured by a telemetry event
Tablesdim_devicedim_subscriptionfact_device_subscription_event
Interviewer

Your question is Star Schema for Device Telemetry. Start with the requirements and the three tables in the Question tab.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.
CodePostgreSQL
You need to log in / sign up to run or submit.Ln 1
Run your query to see results here.