Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails web app: do you create a separate database per account opened?

I'm about to finish building a simple subscription based support ticket Web app. I'm setting up authorization. But since this it's going to be my very own Web app that I'm going to deploy I'm wondering about this.

Do you create a separate database per account opened?

Let's say you have this support ticket Web app. You have ONE and ONLY ONE account owner. Account owner can setup agents that can respond to support tickets. Also, there are customer roles that open support tickets.

So as you can see the database will contain users, support tickets and more.

What is the best way to go?

1) Create one database for the whole application? That way every time somebody signs up, everything is added to the same database with the other tickets and users data and everything else or...

2) Everytime someone signs up, create a separate database per account subscription.

I'm thinking that maybe option number 2 would be a best choice for security and data integrity purposes. If so, how have you gone about tackling this issue?

like image 619
leonel Avatar asked Dec 27 '22 14:12

leonel


1 Answers

It sounds like what you want is Multitenancy:

Multitenancy refers to a principle in software architecture where a single instance of the software runs on a server, serving multiple client organizations (tenants). Multitenancy is contrasted with a multi-instance architecture where separate software instances (or hardware systems) are set up for different client organizations. With a multitenant architecture, a software application is designed to virtually partition its data and configuration, and each client organization works with a customized virtual application instance. - Wikipedia article on Multitenancy

This article while a little dated is the general idea of how I would go about doing it. Simple Rails Multi-Tenancy. It's clean and efficient and saves you from writing code that you don't need to.

like image 164
Devin M Avatar answered Dec 30 '22 02:12

Devin M