Skip to main content

Database ORMs

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

Context

Solutions

What is the best ORM for vercel edge?

ORM Checklist

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

Data Modeling

Key points for multi-tenant data modeling.

Problems

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

Insights

  • Humans are relational beings, so modeling 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