Answer the question
In order to leave comments, you need to log in
What is the best way to globally partition data in a DB?
Hello!
Tell me, who had experience in creating SaaS solutions, what mechanism was used for global data sharing? Different databases for each company, or some sign of a company for all data? Or was no global scope used at all, but just entity relationships?
Answer the question
In order to leave comments, you need to log in
https://www.postgresql.org/docs/9.5/static/ddl-sch...
PostgreSQL has schemas. It is an abstraction layer between the database and the table.
There are different schemes for different accounts. You can keep the same tables in them, you can use different ones. Shared tables can be kept in the public schema. Everything is very flexible. The main thing is that your application handles all this business.
Example. The customer account is located on the subdomain customer.saasapp.com or saasapp.com/customer. When accessing this url, the cursor is placed on the corresponding scheme. All calls to the database within this query go to tables within this schema. If the requested table does not exist, then it is searched for in the public schema.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question