Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should I use a single or multiple database setup for a multi-client application? [closed]

I am working on a PHP application that intends to ease company workflow and project management, let's say something like Basecamp and GoPlan.

I am not sure on what the best approach is, database-wise. Should I use a single database and add client-specific columns to each of the tables, or should I create a database for each new client? An important factor is automation: I want it to be dead simple to create a new client (and perhaps opening the possibility to signing up for yourself).

Possible cons I can think of using one database:

  • Lack of extensibility
  • Security problems (although bugs shouldn't be there in the first place)

What are your thoughts on this? Do you have any ideas what solution the above companies are most likely to have chosen?

like image 981
Aron Rotteveel Avatar asked Nov 01 '08 07:11

Aron Rotteveel


People also ask

Should you use more than one database?

Try to keep logically related information together and unrelated information separate. Try to avoid multiple databases or tables with the same design or purpose. Multiple database apps are usually apps which have their own data requirements but also have to integrate with another existing app or service's database.

Is it possible to use a single database with multiple backend technologies?

We also use Lucene (which is arguably a database), with some custom sharding code on top. Technology, yes. The same database program, not unless it's been developed to open more than one database at a time. But if you use MariaDB, you can use it on the same site to use dozens of databases, one for each access.

Can an application have multiple databases?

It's really a good question,, As I know that you are right, one can use multiple database system for a single web application.

Can we connect 2 database in web application?

Yes. Give it a go. "Is it possible to connect multiple database with one application." Yes. Very straightforward - two connection strings, two different connections.


1 Answers

I usually add ClientID to all tables and go with one database. But since the database is usually hard to scale I will also make it possible to run on different database instances for some or all clients.

That way you can have a bunch of small clients in one database and the big ones on separate servers.

A key factor for maintainability though, is that you keep the schema identical in all databases. There will be headache enough to manage the versioning without introducing client specific schemas.

like image 98
idstam Avatar answered Sep 18 '22 17:09

idstam