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.

New contributor
Brian Tang is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
  • 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 at 6: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 at 7:40
  • This technique is called "Multitenancy". – Robert Harvey May 15 at 19:20
  • What other real customer fields are you saving for these businesses? – Ahmed Masud May 16 at 0:47

Your Answer

Brian Tang is a new contributor. Be nice, and check out our Code of Conduct.

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.