Multi-tenant SaaS data
Accounts, teams, roles and per-customer data kept apart with tenant keys and policies, not just filters in code.
Technology expertise / Ali Nawaz
PostgreSQL is my first choice for new custom applications with complex, connected data: SaaS products with accounts and teams, booking and order systems, and anything where rules must hold no matter which part of the code writes the data. I use it with Node.js and TypeScript, and I like how much it lets the database itself enforce.
Enlarge screenshot: SavyDive homepage hero

Recent project
SavyDive
SaaS product
Product research dashboard. A data-rich research dashboard that lets sellers search, filter and compare Walmart products in one table.
Read the case studyThe approach
PostgreSQL can do a lot: JSON columns, full-text search, partial indexes, row-level security, check constraints. The skill is choosing the few features that remove code from the application and leaving the rest alone. A check constraint that blocks a negative price is worth it. A clever trigger nobody on the team understands usually isn't.
You work directly with me from requirements through launch. That keeps product context close to technical decisions and avoids the gaps that appear when strategy, interface, backend, and deployment are treated as separate problems.
What I can build
The scope is shaped around your users, operating reality, and the smallest responsible path to value.
Accounts, teams, roles and per-customer data kept apart with tenant keys and policies, not just filters in code.
Data with many connections, such as projects, tasks, people and permissions, modeled so joins stay simple and fast.
Schemas with clean dates, IDs and statuses, so reports and exports don't need a cleanup step first.
Orders, invoices and balances protected by transactions and constraints, so two requests can't break the totals.
Features I use
Each feature here earns its place only when it removes work or risk from the application.
| Feature | When I use it |
|---|---|
| Check and exclusion constraints | To block invalid values and overlapping bookings in the database, whatever code writes the row |
| JSONB columns | For settings and attributes that vary by record, next to typed columns for anything the app filters or joins on |
| Partial and expression indexes | To index only active rows or a lowercased email, keeping indexes small and queries fast |
| Row-level security | As a safety net in multi-tenant apps, so every query is limited to the current tenant |
| Transactions with the right isolation | For payments, stock and balances, where two requests at once must not both succeed |
| Full-text search | For search inside the app before reaching for a separate search service |
Modeling
I start with the business nouns and the rules between them: a booking belongs to one customer, a customer can have many, two bookings can't share a room at the same time. Each rule becomes a foreign key, a unique key or a constraint. Then I list the queries the main screens run and design indexes for those, not for every column.
I keep IDs, timestamps with time zones and status values consistent across tables. It sounds minor, but it's what makes reporting, exports and later features easy.
Pitfalls
N+1 queries from an ORM loading related rows one at a time. Timestamps stored without time zones, so a US and a UK user see different days. JSONB used for fields the app filters on constantly, where a real column would be faster and safer. Too many connections from serverless functions. Migrations that rewrite a big table during business hours. And tables that are never vacuumed or analyzed properly because nobody checked the defaults suit the workload.
Choosing a database
When the project is a WordPress or WooCommerce site, MySQL is the database, and fighting that makes no sense. When records are self-contained documents read whole, such as event logs or content blocks, MongoDB can be simpler. And for a small tool with little data, a managed option that the team already pays for may be the right call. I choose based on the data and the hosting, then explain the choice in writing.
What the work should create
Pricing
How pricing works
Client feedback
Reviews from clients I have worked with remotely, quoted as they wrote them.
The process
You get a senior engineering partner—not a black box. The process stays direct, collaborative, and focused on outcomes.
Clarify the problem, users, constraints, and measure of success.
Shape the right product, technical plan, and delivery path.
Create in focused iterations with quality visible at every step.
Test, deploy, measure, and improve with confidence.
Common questions
For new apps with rich relationships, PostgreSQL's constraints, JSONB support, partial indexes and row-level security often let me enforce rules in the database instead of in every query. MySQL is still my choice next to WordPress or where the host only offers it.
Yes. A JSONB column holds flexible attributes and can be indexed and queried, while the core fields stay in typed columns with constraints. For many apps that removes the need for a separate document database.
Usually one database with a tenant ID on every tenant-owned table, indexes that start with that ID, and row-level security policies as a second guard, so a missed filter in code can't leak another customer's data.
Yes, with care. Serverless functions can open many short connections, and PostgreSQL handles a limited number well, so I use a connection pooler or a host that provides one.
Indexes are built concurrently, new columns are added without defaults that rewrite the table, and data is backfilled in batches before constraints are switched on.
Often a lightweight query builder or ORM for everyday queries, with plain SQL for reports and anything performance-sensitive. Whatever the tool, I read the SQL it generates, because most slow pages I fix come from queries nobody looked at.
The database development service page explains how I scope schema design, migrations and performance work, and what it costs.
Start a conversation
Tell me what you’re building, where you are in the process, and what success looks like. I’ll get back to you with a clear next step within 24 hours.
ali@bealinawaz.com