Skip to main content
Data modeling is where architectural decisions cement. Get the schema right early; it’s the most expensive layer to change later.

Common patterns

Multi-tenant scoping

Every domain table has a workspaceId. Every query filters by it.
See Multi-tenancy.

Soft delete

Active queries filter deletedAt === undefined. Cleanup job deletes hard after 30 days.

Audit trail

Insert from every write mutation.

Hierarchies (tree)

For deep hierarchies needing fast ancestry lookup, also store path (array of ancestor IDs) — slower writes, instant ancestry queries.

Polymorphism

When the same field can point to different entity types:
Lookups still need the type to resolve the right table.

Many-to-many

A join table:

Time series

For analytics-style data:
Partition by user/team if cardinality requires:

Tips

Name fields what they are. dueAt is clearer than due_date (and deadline is clearer still in business contexts). Future-you will thank you.
Index fields you filter or sort by. Without an index, queries do table scans.
For event sourcing, store the events. Aggregate views can be re-derived; events are the truth.

Convex schema

The schema definition reference.

Indexes

Make queries fast.

Multi-tenancy

Multi-tenant patterns.
Last modified on April 18, 2026