Designing a product database starts with modeling the products themselves, not the tables: separate what a product is from what it is sold as, store money in integer minor units, and treat attributes that vary by category as structured data rather than a pile of spare columns. If you get those three decisions right, the schema survives new categories, multiple currencies, and a catalog that grows from hundreds of SKUs to millions. If you get them wrong, every new product type turns into a migration.
This guide walks through the design in the order you should actually do it: requirements, core entities, money and units, variation modeling, attributes, media, search and indexing, integrity rules, migrations, and when to stop adding structure. It uses PostgreSQL-style examples because relational databases remain the default for transactional catalogs, but the reasoning carries over to MySQL, SQL Server, or a document store.
Start With Queries and Write Paths, Not Tables
Before drawing an entity diagram, write down the five to ten questions the database must answer fastest. Typical candidates: "show all active products in category X sorted by price," "find the variant for this SKU," "what did this order line cost at purchase time," and "search the catalog for the term the customer typed." Your indexing and normalization choices follow from this list.
Then map the write paths: who creates products (admins, suppliers, imports), how often, in what volume, and how changes are approved. A catalog with 500 hand-entered products and a catalog with 2 million supplier-fed items need the same logical model but very different physical treatment.
Two requirements deserve early answers because they're expensive to retrofit:
Do you sell in more than one currency or region? If yes, decide now whether prices are stored per currency or converted at read time. Per-currency prices are the usual choice for retail, because exchange-rate round trips produce ugly numbers like 23.47 and break price-parity promises. Do you need historical accuracy on product data? Order records must snapshot what was bought (name, price, tax), but a full audit trail on product edits is a separate, heavier decision.
A short written spec — entities, the query list, expected volumes, currency scope, and who edits what — prevents most of the redesigns that hit catalogs in year two.
Formalize the Core Entities Before Typing Any DDL
The most common structural mistake is collapsing everything into one products table. A workable decomposition:
Product: the conceptual item the customer browses — a t-shirt model, a laptop model, a book title. Holds title, description, brand, category membership, status. Variant (or SKU): the thing you actually stock and sell — size medium in navy, the 16 GB/512 GB laptop, the paperback edition. Holds SKU code, price, stock, barcode, dimensions. Category: the browse hierarchy. Usually a tree, sometimes with a product in several categories. Attribute definition and attribute value: the per-category fields (color, screen size, material) and their values per product. Media: images, documents, and their ordering and alt text. Supplier/offer (if you multi-source): who provides which variant at what cost.
Products and variants are separate because almost every real catalog has one-to-many variation and because price and stock live at the sellable unit. Putting price on the product forces you into "starting at" hacks the moment one size costs more.
Keep identifiers boring but deliberate. Use a surrogate integer or UUID primary key internally, and a human-meaningful unique sku string on variants. UUIDs help if you'll merge catalogs or generate IDs offline; sequential integers are simpler and index better. Either way, enforce uniqueness in the database — application-level checks lose races.
Category hierarchies are worth a note. A simple parent_id self-reference handles most catalogs. If you need fast "everything under this category" queries on deep trees, consider a materialized path or a closure table; both trade write complexity for read speed. Don't reach for those until the recursive query actually hurts.
Get Money, Units, and Time Right the First Time
These are small decisions with outsized blast radius.
Money. Store amounts as integers in the currency's minor unit (cents for USD and EUR, yen for JPY which has no minor unit, and so on), plus a separate currency code. NUMERIC(12,2) is acceptable in PostgreSQL, but binary floating point is not — 0.1 + 0.2 issues and rounding drift will surface eventually. A price of $19.99 becomes 1999 with currency = 'USD'.
Don't store a formatted price string anywhere a calculation uses it. If you cache display prices, derive them from the integer amount on read or at publish time, and rebuild caches when prices change.
Units. Weight, dimensions, and capacity should be stored with an explicit unit or converted to one canonical unit per attribute. A weight_grams integer beats a weight float whose unit lives only in someone's memory. Consistent canonical units make shipping-rate logic and filters far simpler.
Time. Use timezone-aware timestamps (timestamptz in PostgreSQL) for everything, store in UTC, and render in the customer's zone. Order and price-history records especially need this, because "did the price change before or after the sale" is a legal and accounting question, not a display nicety.
Model Variants So Options and SKUs Don't Collide
There are two related but distinct concepts and conflating them causes pain:
1: Options: the axes of variation — size, color, capacity. 2: Variants/SKUs: the specific sellable combinations — "Medium / Navy."
A minimal, flexible model:
product_option (product_id, name) — e.g., "Size." product_option_value (option_id, value) — e.g., "S," "M," "L." variant (product_id, sku, price_minor, currency, stock, barcode, weight_grams, active). variant_option_value (variant_id, option_value_id) — maps each variant to its combination.
This handles three-option products without schema changes, and it lets you power the size/color selector on the product page directly from the data. Many catalogs also add a generated option_signature (a sorted hash of the option value IDs) with a unique constraint per product, which stops duplicate combinations at the database level.
Two practical cautions. First, not every product has variants; make the product sellable directly or always create at least one variant (often called the "default variant"). The latter is more uniform and I'd lean toward it in a new schema, because order lines then always point at a variant and reporting doesn't need to branch. Second, variant counts explode combinatorially — 5 sizes × 6 colors × 3 capacities is 90 SKUs for one product. That's fine, but your admin tooling and bulk-edit paths need to handle it, and you should think about whether every combination is actually orderable before generating rows.
Handle Category-Specific Attributes Without Column Sprawl
Laptops have screen sizes and RAM; t-shirts have fabric and fit; books have ISBNs and page counts. The tempting shortcut is one wide table with nullable columns for every attribute anyone might need. It starts convenient and ends as a 200-column table where nobody knows which fields matter for which category, and every new attribute is a migration on a hot table.
The usually better pattern is entity-attribute-value (EAV) or a JSON column per product, chosen by how you query:
EAV: product_attribute (product_id, attribute_id, value_text, value_number, value_boolean, unit). Flexible and filterable with joins, but verbose queries and weak type enforcement. JSONB column: attributes jsonb on product with per-attribute validation in application code or a schema. Fast to add fields, excellent for display, but cross-catalog numeric filters ("screen size ≥ 15") need GIN indexes and careful casting.
A pragmatic middle ground that many production catalogs land on: define an attribute catalog (attribute table with name, data type, unit, applicable categories), store values in a typed EAV table, and materialize a JSONB copy on the product row for read performance. That gives you governance (only defined attributes, known types) and query speed (one row read for the detail page). It costs you a sync step when attributes change; keep it in a transaction or a reliable trigger and it stays honest.
Whichever you choose, keep the facetable attributes — the ones customers filter by — in typed columns or numeric EAV, not in free text. Filters on untyped text are where catalog search quality dies.
Design Media, Categories, and Search as Separate Concerns
Media. Store image metadata (product_id, variant_id nullable, URL, position, alt text, mime type, dimensions) in the database and the bytes in object storage. Don't put images in the database unless volume is tiny and operations are simple. Add a unique ordering constraint so the "primary image" is deterministic, and delete or soft-delete rather than mutating rows in place if caching and CDNs are involved.
Categories and merchandising. A product-to-category link table (product_category) lets items appear in more than one browse path — a laptop under both "Computers" and "Back to School." Decide whether the canonical category (used for breadcrumbs and attribute applicability) is distinct from merchandising placements, and name the columns so nobody confuses them.
Search. Relational databases can do decent full-text search (PostgreSQL's tsvector plus trigram indexes handle millions of rows reasonably), but the moment you need typo tolerance, relevance tuning, synonyms, or faceting at scale, a dedicated search index earns its complexity. The architectural rule: the database is the source of truth; the search index is a derived, rebuildable projection. Design a change feed or outbox so product and variant edits reliably reach the index, and test a full rebuild so you know it's possible.
Enforce Integrity Where It Cannot Be Bypassed
Application code will have bugs; constraints don't. Minimum set worth adding:
NOT NULL on every column that's conceptually required, including currency wherever a price lives. CHECK constraints: positive prices, non-negative stock, valid status values. Unique constraints: sku, product slug, (product_id, option_signature), and per-currency price uniqueness if you model prices that way. Foreign keys with deliberate ON DELETE behavior: restrict deletes on order-line references, cascade only where the child is meaningless without the parent (a variant's option links, for instance).
For order history, the key principle is snapshot, don't join. Order lines should carry the product name, unit price, currency, and tax amount as purchased. Joining live product rows to build an old invoice means a price edit retroactively rewrites history — a bug that shows up in accounting, in disputes, and in audits at exactly the worst time.
Status fields (draft, active, archived, discontinued) should be an enum or constrained string, and every read path should be explicit about which statuses it includes. "Active" appearing by accident in an admin listing is a common, embarrassing leak.
Plan for Change: Migrations, Imports, and Versioning
Product schemas change. New attribute types, new currencies, new regions, new tax rules. Three habits keep that manageable.
Migration discipline. Version your schema (Flyway, Liquibase, Alembic, Rails migrations, whatever fits your stack), keep migrations forward-only in production, and test them against a realistic copy of the data. Adding a nullable column is cheap; backfilling and then adding NOT NULL is the safe three-step pattern for making it required.
Bulk imports. Supplier feeds and spreadsheets are the most common source of duplicate SKUs and half-populated products. Design the import as: stage raw rows, validate (required fields, unit parsing, currency codes, unknown attribute handling), diff against existing data by stable keys, then apply in a transaction or idempotent batches. Log every import so a bad feed can be traced and reversed.
Schema versioning for attributes. If attributes change meaning over time (a "size" that used to be numeric and is now a labeled string), record the change in the attribute definition and, where possible, migrate values rather than overloading one field. Mixing meanings in one column is a silent corruption that surfaces during reporting weeks later.
A rough sense of cost: a catalog of 100,000 SKUs with a few hundred thousand attribute rows and modest image metadata sits comfortably in a single well-indexed relational database. It's usually around millions of variants, heavy faceted search, and multi-region serving that the architecture conversation shifts toward search engines and read replicas. Your numbers will differ; the point is to know yours before scaling out.
Know When to Stop Normalizing
Normalization is a tool, not a virtue. Fully normalized catalogs produce correct data and painful read paths: a product page assembled from ten joins. Targeted denormalization — a materialized JSONB attribute blob, a cached "primary image URL" on the product, a precomputed min_price per product for listing sort — is normal in mature catalogs. The rules that keep it safe:
Every denormalized field has a clear, single source of truth elsewhere. There's a rebuild path that reproduces the cache from base tables. Staleness is bounded and acceptable for the use case (a listing's "starting at" price can lag a few seconds; an order's charged price cannot).
The same logic applies to read models for search and analytics: derive them, don't let them become the place edits happen.
Verify the Design Before It Ships
You can check a product database design without waiting for production problems. Work through this checklist:
1: Walk the query list. For each of the top ten queries, write the actual SQL against the schema and run it on seeded data. If any query needs five joins to answer a browse page, revisit the model. 2: Add an unusual product. Create a product with no variants, one with three options, and one with an attribute type that doesn't exist yet. The first two should be insert-only; if the third forces a migration, your attribute model is too rigid. 3: Change a price after a sale. Confirm the old order's total is unchanged. If it moved, your order lines are joining live data. 4: Try to break it. Attempt duplicate SKUs, negative prices, a variant with no option values, a product in a category it doesn't belong to, a currency-less price. Every attempt should fail at the database, not in a code review. 5: Rebuild the search index from scratch. Time it on realistic volume; if you can't, the index isn't really derived. 6: Simulate an import. Feed malformed rows and confirm they're rejected with useful errors and no partial writes.
If those checks pass, the schema is ready for real data. If one fails, fix it now — it's the cheapest it will ever be.
FAQ
Should I use a NoSQL document store for products? Sometimes, especially when attributes vary wildly and read patterns are document-shaped. The trade-off is weaker cross-entity integrity and more application-level work for uniqueness, money handling, and joins across orders. If your catalog is genuinely heterogeneous or you're serving at very high read scale, a document store with a relational source of truth for orders can work well. For most transactional commerce, a relational core with a JSONB attribute column gets the flexibility without giving up constraints.
How many attribute tables do I need? One definition table and one value table is the usual shape. Avoid creating a new table per attribute type or per category; that's how schemas reach hundreds of tables and migrations become an event.
Do I need a separate table for prices? If you support multiple currencies, multiple regions, or sales/promotions with history, yes — a price table keyed by (variant, currency, region, valid_from) gives you time-bounded pricing and clean audits. If you sell one currency at one static price, a price_minor column on the variant is fine, and you can migrate later.
When should the database stop being the whole answer? When faceted search, typo tolerance, and sub-second filtering on millions of variants become requirements. At that point, keep the relational database as the system of record and add a search engine as a derived index. The design work up front — typed attributes, stable SKUs, reliable change feeds — is what makes that transition a configuration task instead of a rewrite.