1

My users will be businesses with a small number of accounts each: e.g. Business #1 with 3 users, Business #2 with 5 users, etc.

I am trying to determine the best way to organise the relation (on Postgresql, hosted on AWS) for each business client: for e.g. each business will have their own sets of customers, logs, products, config relations.

I want to create a scaleable database across all client businesses.

  • Do I create a single relation, e.g. of customers, for all my clients? E.g. each business client is given a unique ID, and during onboarding of the business user, the user's account is tied to the specific business UID. Examples in 2 images below.

enter image description here


enter image description here

This seems like a huge security risk given that all business information is stored in a single table/DB.

  • OR, do I create individual databases hosted separately in AWS for each business? This seems safe, but also practically not scaleable and expensive!

I'm pretty sure there's a middle path where all B2B apps tread which my inexperience simply makes me oblivious to.

I've read this and this. My question is more directed to the implementation of the table if I were to go with a shared DB and shared schema.

lionbigcat
  • 111
  • 2
  • 1
    `This seems safe, but also practically not scalable and expensive!` Expensive maybe, not scalable... I don't think so. Scaling out small databases is easier (no single point of failure that may mess the whole system) an cheaper (in terms of resources: knowledge and time) than scaling out a big database. Don't confuse "convenience" with "practicality". – Laiv May 15 '19 at 06:23
  • 2
    Having a single database seems far simpler. I don't really see the security issue unless you are giving the customers direct access to the database. If data goes through an application layer, then you have to handle authorization in both cases. – JacquesB May 15 '19 at 07:40
  • https://stackoverflow.com/questions/255616/should-i-use-a-single-or-multiple-database-setup-for-a-multi-client-application/255646#255646 – idstam May 15 '19 at 13:26
  • This technique is called "[Multitenancy](https://en.wikipedia.org/wiki/Multitenancy)". – Robert Harvey May 15 '19 at 19:20
  • What other real customer fields are you saving for these businesses? – Ahmed Masud May 16 '19 at 00:47

0 Answers0