Data Modeling
30 bites tagged Data Modeling: interview questions with model answers, and 60-second explainers.
Test yourself: Top 30 Data Modeling interview questions →Multiple choice, with the correct answer and why it is correct on every question. Free, no sign-in.Designing a tiered entitlements backend
Plans map to features and limits, subscriptions link account to plan, an entitlement check enforces access; handle upgrade/downgrade with effective dates and proration.
Define a Mongoose schema and model
New mongoose.Schema with field options (type, required, default), then mongoose.model('Product', schema) to get a model.
Modeling IoT data with tags and fields
Tags are indexed identifying metadata, fields are unindexed measured values, and tag cardinality drives memory.
Sessionizing clickstream events into sessions
Order events per user, split on inactivity gap, assign session ids, pick event or session grain.
Denormalization: trading write cost for read speed
Duplicate or precompute data to avoid joins, accept harder writes and consistency risk, justify by read-heavy access.
When a graph database beats relational or document stores
Deeply connected data, variable-depth traversals, fraud or recommendation paths, index-free adjacency.
Embed or reference likes in a document database?
Embedding is fast for small bounded lists but unbounded likes hit document size limits; referencing scales for high-cardinality, write-heavy likes.
How do you choose between relational and NoSQL databases?
Relational gives schema, joins, and ACID for structured related data; document gives flexible schema and horizontal scale for varied or denormalized data.
Adjacency List versus Nested Set for hierarchies
Adjacency list is simple writes but recursive reads; nested set is fast subtree reads but costly writes.
Modeling one-to-many versus many-to-many relationships
One-to-many uses a foreign key on the many side; many-to-many needs a junction table with two foreign keys.
Normalizing a flat orders table to 3NF
Split repeating data, remove partial dependencies, remove transitive dependencies, define keys.
When to intentionally denormalize a schema
Identify read-heavy join cost, duplicate or precompute data, and own the consistency burden.
Data model for an editorial calendar
A content entity with publish_date and a status enum, a foreign key to authors, indexes on date and status.
Add a second access pattern to a key-value store
Add a global secondary index on EmailAddress, weighing extra storage, write amplification, and eventual consistency.
Define a consistent day across timezones
Store events in UTC, capture the local/source timezone, then convert to a single reporting timezone at query time.
Design an analytics event schema
Consistent object-action naming, snake_case, typed properties with units, and shared context like user, session, timestamp.
Design a referral feature's lifecycle and races
A referral entity with explicit states, a unique constraint on the invited user, and atomic transactions plus idempotency to prevent double credits.
How would you implement a last-touch attribution model for user signups?
Tests your ability to translate marketing concepts into warehouse SQL. A strong answer covers UTM/pageview events, sessionized tables, and a windowed join for the last touch within 30 days of signup.
Describe the SQL and data model for weekly cohort retention
Join users and activity, compute week offset per user, group by cohort and offset for retention.
What is the difference between primary, foreign, and unique keys?
This tests relational integrity basics. Answer: primary keys identify rows, foreign keys reference tables, and unique keys are alternate candidates. Red flag: saying unique keys are just for indexing or omitting a non-PK example like email.
How would you model cross-platform ad campaign data and adaptation logic?
Propose a canonical model, platform adapters mapping copy to each schema, and an async pipeline with validation.
Design a content versioning system with history and revert
Versions table with article_id, version_num, content_snapshot, timestamp; APIs for createVersion, getHistory, restoreVersion.
What data do you need and what steps build a WAU dashboard?
Tests defining a metric, modeling events, and wiring them into a BI tool. A strong answer names the feature event, sets a rolling 7-day window, counts distinct users by period, and configures the BI layer. Red flag: jumping to charts before defining active.
How would you build a weekly active user dashboard?
This tests translating a business need into a technical spec. First, clarify the definition of "active." Then, identify the event data needed (user_id, timestamp). Finally, outline the ETL and BI tool steps. A red flag is not clarifying the metric first.
Get Data Modeling bites daily.
Five a day, five minutes, offline. With quizzes so it sticks.
The iPhone app is on the way
We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.
Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.