Skip to main content

Database ORMs

Choose an ORM that let's you use SQL but handles DB changes.

Solutions

What is the best ORM with Nextjs and Vercel platform?

Requirements

  • Type Safety
  • Declarative DB changes
  • Execution at the Edge

Multi-Tenant Schema

Key points for multi-tenant data modelling.

Problems

  • Adding multi-tenancy and teams functionality later in the development process is complex and painful

Insights

  • Humans are relational beings, so modelling human relationships in software is important to avoid impedance mismatch
  • The top-level tenant can be named various things like Account, Team, Company, Tenant, Workspace, or Organization
  • Most SaaS applications should use a single, shared database with an organization_id field in every table for data isolation, unless there are exceptional cases demanding separate databases per user

Best Practices

  • Build "teams" functionality on day one for SaaS applications
  • Use a single, shared database with an organization_id field in every table for data isolation in most cases
  • Choose an appropriate name for the top-level tenant model, such as Organization, that aligns with the concept of a tenant
  • Model human relationships in the software to create a better user experience
  • Consider the potential need for multiple teams or workspaces within an organization in the future