Walk me through your project's database design and why you made those choices.
Fast recall
Quick revision
Core answer
Understanding of data modeling, relationships, normalization, and whether you can justify design decisions beyond 'it worked'
Describing tables without explaining relationships or normalization, or claiming the design is perfect without acknowledging trade-offs
Mention a specific normalization decision—'I kept user addresses in a separate table for 3NF, but in hindsight, it added unnecessary joins for the common case'
Interview-ready guide
Interview answer
Here's how I'd walk through my database design.
My project had four main tables: users, orders, products, and order_items. The users table stores customer information like email and password hash. Each user can place multiple orders, so I have a one-to-many relationship there.
The orders table has a user_id foreign key that references the users table. For products, I needed a many-to-many relationship with orders because one order can contain multiple products and one product can appear in multiple orders. So I created a join table called order_items with a composite primary key of order_id and product_id, plus a quantity column.
That way I can link orders and products without duplicating data. I normalized the schema to third normal form to avoid repeating user data across multiple orders.
For example, if a user's email changes, I only update it in one place.
The trade-off is that fetching a complete order with all its product details requires joining three tables, which can be slow. In hindsight, I might denormalize by storing product names directly in the order_items table so I don't have to join the products table just to display order history. That would duplicate data but speed up the most common query.
I also considered putting addresses in a separate table, but since most users only have one address, I kept it in the users table to avoid unnecessary joins.
Walk me through your project's database design and why you made those choices.
Direct Answer
Describe your schema concisely: list the main tables, explain the key relationships (one-to-many, many-to-many), mention normalization decisions (why you split or combined tables), and acknowledge trade-offs like denormalization for performance or over-normalization that caused complex joins.
Code Example
// Main tables and relationships in my project
// users: stores customer information
CREATE TABLE users (
id BIGINT PRIMARY KEY,
email VARCHAR(255) UNIQUE NOT NULL,
password_hash VARCHAR(255) NOT NULL,
created_at TIMESTAMP
);
// orders: one user has many orders (one-to-many)
CREATE TABLE orders (
id BIGINT PRIMARY KEY,
user_id BIGINT NOT NULL, -- foreign key to users
total_amount DECIMAL(10,2),
status VARCHAR(50),
created_at TIMESTAMP,
FOREIGN KEY (user_id) REFERENCES users(id)
);
// products: catalog of items
CREATE TABLE products (
id BIGINT PRIMARY KEY,
name VARCHAR(255),
price DECIMAL(10,2)
);
// order_items: join table for many-to-many (orders <-> products)
CREATE TABLE order_items (
order_id BIGINT,
product_id BIGINT,
quantity INT,
PRIMARY KEY (order_id, product_id), -- composite key
FOREIGN KEY (order_id) REFERENCES orders(id),
FOREIGN KEY (product_id) REFERENCES products(id)
);
// Trade-off: Normalized design, but fetching one order requires joining 3 tables
Common Mistakes & Pitfalls
- No Relationships Explained: Listing table names without explaining foreign keys or how tables relate—"I have users, orders, products"—doesn't show you understand joins or referential integrity. Always explain the connections.
- Claiming Perfection: Saying "My design is perfect" or "I wouldn't change anything" signals lack of awareness. Every design has trade-offs—too normalized means complex joins, too denormalized means data duplication.
- Ignoring Normalization: Not mentioning whether your schema is normalized or why you chose a particular normal form suggests you didn't think about data integrity and duplication.
- No Trade-off Awareness: Failing to acknowledge performance vs integrity trade-offs shows you haven't considered how your design would perform under real load or why production apps sometimes denormalize intentionally.
Looking for a structured roadmap?
Every module on this page is also part of the full Java backend interview track.