Skip to content

Core entities and the data model

The handful of things a system stores, named before any boxes are drawn, with how they relate and the few fields that decide a trade-off. It gives you and the interviewer one vocabulary for the rest of the round.

On this page

What it is

Core entities are the things a system has to remember to do its job: the users, the orders, the messages. The idea comes from entity-relationship modeling, which Peter Chen published in 1976 and which is still commonly used to teach database design. An ER model has entity types (the kinds of things), the relationships that can hold between them, and attributes that describe either. A useful shorthand from that tradition: entities are nouns, relationships are verbs joining two or more nouns. "A user uploads a photo" gives you two entities and one relationship.

In a system design round, this is the step between requirements and the API. You name what the system stores and passes around before you draw any architecture, so you and the interviewer are using the same words for the rest of the hour. It is not a schema: nobody needs the full column list of the user table at this point, and you don't know enough yet to choose them. Two questions get you most of the way: who acts on the system, and what does it have to hold to meet each functional requirement? Our advice: aim for two to five entities. If you have one, check whether you've merged two things that behave differently; if you have eight, check whether some are attributes of another, or details you can introduce later.

PartWhat you sayWhy the interviewer needs it

The entities

Two to five nouns the system stores, each in a word or two.

Shows you've read the requirements and found the things that persist.

The relationships

Which entity owns which, and the count on each side: one-to-many, many-to-many.

A many-to-many link usually becomes its own entity, and that decision shapes the storage.

The fields that matter

A status, an expiry, a version, a partition key. Not name and email.

These are the fields a later trade-off turns on, so naming them early shows you see it coming.

The shape

A table per entity, or a child kept inside its parent, and the reason.

Ties the model to the store you'll pick and the queries it has to serve.

Counts are part of the model. ER modeling attaches cardinality to a relationship: the classic example is that a building holds zero or more apartments while an apartment sits in one building. Say the count out loud for each relationship. In a relational store, a one-to-many link (a photo has many comments) usually becomes a foreign key on the child. A many-to-many link (users follow users) has no natural home on either side, so it becomes a thing of its own, a Follow row with two user IDs.

The shape depends on the store. AWS's DynamoDB guide draws the line plainly: with a relational database you can build a normalized model, one table per kind of data, without knowing the access patterns, and extend it as new queries show up. With DynamoDB it says to hold off on the schema until you know which questions it has to answer, and to start from the query patterns, including how much data each one touches and what shape it wants back. MongoDB's manual gives the matching test for document stores: keep a child inside its parent when the two are read together, updated together or in a has-a relationship, and split it into its own collection when the child side has many rows, grows without bound, or gets written at different times. So after you name the entities, say which of these worlds you're in. That decision connects to Choosing a database.

When to use it

Use it right after the functional requirements, before the API and the first diagram. The requirements tell you what the system does; the entities tell you what it keeps, and the API then becomes operations on those entities. Stating them first means that when you later say "the write path stores the reservation and sets its expiry," both of you know what a reservation is.

Come back to it during deep dives. A field you didn't need at minute ten often becomes the point of the discussion at minute thirty: a version column when you argue for optimistic locking, an expires_at when a held seat has to be released, a status when a job moves through states. Add the field to the entity as you introduce it rather than leaving it implied. The same applies to the partition key when you reach sharding: say which field, or combination of fields, it comes from.

When not to

Our advice: a few kinds of prompt deserve less time here, and spending five minutes on the model is the wrong call for them.

  • The prompt centers on an algorithm or a flow. When what the system keeps is a small, obvious set, say it in a sentence and move to the part the prompt is about.
  • The interviewer hands you the schema. If the prompt already lists the tables, repeating them back wastes time. Confirm the one or two relationships you'll lean on and go.
  • It's a low-level design round built around classes and interfaces. There the storage model may be a side note; give the entities as a quick check and spend the time on the object model.
  • You're tempted to write the full schema. In a high-level design round, listing each column before any box is on the board tells the interviewer little, and most of those columns are obvious. The fields worth naming are the ones that decide correctness or scale, and many of them show up as the design takes shape.

One more limit: don't pick the physical layout before you know the queries. The normalized, one-table-per-entity model is the right default for a relational store, and designing from access patterns is right for a key-value store like DynamoDB. Choosing either shape before you've said which kind of store you want, and what it has to answer, is modeling in the wrong order.

Compared

ChoicePick this whenPick the other when

A table per entity, normalized vs embedding the child in the parent

The child side is large or grows without bound (comments on a popular post), or it's written at different times from the parent, or it has to exist on its own.

The two are read together and updated together, and the child is small and bounded (an address on an order). Embedding saves a join and keeps the code simpler.

Reference by ID vs copying a field into the other entity

The copied value changes often. Each change then has to be written in two places, and frequent duplicate updates cause heavy write loads.

Reads dominate and the value rarely changes (the author's display name on a post). The copy removes a lookup from each read, which is the point of duplicating.

Model from the domain (nouns in the requirements) vs model from access patterns

You're on a relational store, where you can normalize first and extend the model as new queries show up.

You're on a key-value store like DynamoDB, where the schema waits until the questions it must answer are known, and the data is shaped to those queries.

Entities plus a few fields vs the full column list

It's a high-level design round. The fields that matter show up as the design does, and listing the rest spends minutes for little.

The interviewer asks for the table definitions, or the prompt is about the schema itself. Then the columns are what's being asked for.

In a picture

FunctionalrequirementsNouns in them

Step 1 of 5

Pull the nouns out of the requirements

Each functional requirement names things. "Users upload photos and follow each other" gives you user, photo and follow. Write them down without judging yet.

How to say it in an interview

The common mistake

Quiz

Users can follow each other. How does "follow" show up in your data model?
You're modeling a seat-booking system at the entity step. Which field is worth saying out loud now?
The interviewer says the store will be DynamoDB. What changes about how you model?
In a document store, the comments on a photo keep growing with no upper limit. Keep them inside the photo document or in their own collection?

Related

Sources

  1. Entity-relationship model (Wikipedia)
  2. A framework for system design interviews (SWE Quiz)
  3. NoSQL design for DynamoDB (Amazon DynamoDB Developer Guide)
  4. Best Practices for Data Modeling in MongoDB: Embedding vs. References (MongoDB Manual)
Sign in to report a mistake