TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Ask HN: How to deal with multi-tenant SaaS database structure?

7 点作者 shahinghasemi超过 2 年前
Hello HN, I&#x27;m building a SaaS product. Each tenant can have their own database structure&#x2F;fields while many tables are common between the tenants. For example table A is common for all of them while table B might have different fields upon organization&#x2F;tenant&#x27;s need, in other words we have table B for all orgs with different fields.<p>I&#x27;m thinking of shared-codebase and shared-database paradigm for it&#x27;s simplicity(no synchronization needed). Have you encountered this situation? Is it possible&#x2F;and how to handle this objective with single database for all tenants? Further, I&#x27;m using PostgreSQL database.<p>Thanks in advance.

5 条评论

satya71超过 2 年前
You&#x27;re heading the right way. A correct design is not simple, but it can be done. You might be able to buy a boilerplate that&#x27;ll work as a starting point.<p>Separate database will only work if you&#x27;ll have a handful of customers, and even then a pain.
codingdave超过 2 年前
Possible to do with one database, yes - Add JSON columns to your tables to hold tenant-specific metadata. Deal with it in your app layer.<p>But I&#x27;d re-think whether a single database is truly the right answer. What is driving you to that solution?
评论 #33722242 未加载
ozzythecat超过 2 年前
If one tenant misbehaves and takes down your database, how will your other tenants feel?
评论 #33736954 未加载
PaulWaldman超过 2 年前
How many tenants and how many clients per tenant will you support?<p>Also how much data will each tenant consume?
评论 #33723444 未加载
joshxyz超过 2 年前
postgresql row level security excels on this right