-3

I am building a web application where we have the concept of groups. A group can be roughly thought of like a Facebook group where you have a number of people attached to it. The DB for the app is going to be Postgres. Ideally, all data relating to a group would be independent of others and hence a need to isolate all tables pertaining to a group. What is the right way to do it so that we can scale, backup easily as usage grows? Should we have one DB per group OR one schema per group?

  • 1
    You could call "groups" in the above case "manbearpigs" and it would tell us nothing more of the concept you're trying to implement. How about telling us what you mean by a "concept of a groups" and what you're doing in the app or business? – Evan Carroll Jan 6 at 7:46
  • added more info – Saurav Prakash Jan 6 at 8:25
3

A group can be roughly thought of like a Facebook group where you have a number of people attached to it.

There is nothing about a Facebook Group that in any fashion requires a new a database, schema, nor table; and, there is nothing to be gained by the added complexity. All groups on Facebook have the same capabilities. They have the same meta-data. They're for the same-type of thing "Facebook Users." There all accessed through the same endpoints on their graph API, and they're all rendered with the CSS, and HTML.

  • alright if its still not clear let's draw another analogy. let's say a college/school can be a group and each college would have many entities(which I want to map as tables) like teachers/students/staffs etc. Now the schema is the same for all such colleges but for each college, I want to store data in isolation. – Saurav Prakash Jan 6 at 8:32
  • 1
    That still wouldn't be another database, you'd have table for institutions and likely another one for staff and students or whatever (or even have that combined too) – Evan Carroll Jan 6 at 8:34
  • so for each college should i have a schema? e.g institution_cornell, institution_stanford – Saurav Prakash Jan 6 at 8:36
  • No... Schemas are to separate discrete concepts of a database, not different values or sets of values. For example, admission, cafeteria, and accounting could be different schemas. – Evan Carroll Jan 6 at 8:37

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.