Sample Header Ad - 728x90

Handling multiple users/ databases in postgres

0 votes
0 answers
1486 views
Whats the best way to organize seperate companies/users in postgres? I've developed a multi user platform, where users have access to only their companies data. I'm no DB engineer and initially the project was only for one user, but now I've had interest from others. Although it's not an issue currently, I'm just looking ahead, and don't want to host each companies version on another server. Should I be creating multiple databases for each company/user set? Or should I keep all the data in one database and with the tables (i.e customers) and company_id column to each table and add this clause to all queries from that user? I feel like multiple databases would keep the users data separate and probably help with execution speed as there is less bloat in the tables? But harder to migrate any changes across all when an update is required. On the other hand, adding the new fields to all tables and updating all the queries is a bit of a pain, but keeps things all in one place. Any help or guidance appreciated.
Asked by Lewis Morris (101 rep)
Jun 13, 2022, 07:36 AM
Last activity: Jun 13, 2022, 09:33 AM