How many databases are needed for a social website? I have my tech team working on developing a social site but all their tables are in 1 database. I wanted to create separate table sets for user data, temporary tables, etc and thinking maybe have one separate database only for critical data, etc but I am not a tech person and now sure how this works? The site is going to be a local reviews website.


What is the reason that you want it in different databases?

You could just put all tables in one database without a problem, even with for example multiple installations of an open source package. In that case you can use table prefixes.

+1  A: 

This is what happens when management tries to make tech decisions...

Abe Miessler
Word of caution: Mark answers like these as being community wiki. Those without humour might downvote you, which your rep isn't affected for community wiki answers (up or down). Otherwise, use a comment.
OMG Ponies
+2  A: 

The simple answer, as always, is as few as possible.

The slightly more complicated answer is that once your begin to push the limits of your server and begin to think about multiple servers with master/slave replication then your may want your frequent write tables separated from your seldom write tables which will lower the master-slave update requirements.


Unless you are developing a really BIG website, one database is the way to proceed (by the way, did you consider the possible issues that may raise when working with various databases?).

If you are worried about performance, you can always configure different tablespaces on several storage devices in order to improve timings.

If you are worried about security, just increase it (better passwords, no direct root login, no port forwarding, avoid tunneling, etc.)

Federico Cristina

I am not a tech person only doing the functional analysis but I own the project so I need to oversee the tech team. My reason to have multiple database is security and performance.

Since this is going to be a new startup, there is no money to invest into strong security or getting the database designed flawless. Plus there are currently no backup policies in place so: 1) I want to separate critical data like user password/basic profile info, then separate out user media (photos they upload on their profile) and then the user content. Then separate out the system content. Current design is to have to layers of tables: Master tables for entire system and module tables for each individual module. 2) Performance: There are a lot of modules being designed and this is a data intensive social site with lots of reporting / analytic being builtin so lots of read/writes. Maybe better to distribute load across database based on purpose?

Since there isn't much funding hence I want to get it right the first time with my investment so the database can scale & work well until revenue comes in to actually invest in getting it right. Ofcourse that could be maybe 6 months away and say a million users away too.

Oh & there is plan to add staging/production mode also so seperate or same database?

Thomas, instead of giving an "answer", you should edit your own question, adding the extra information.
Federico Cristina
If you can't afford "strong security" or backups, multiple databases aren't going to help you. When a social website loses all of a user's data except their login and password, they're not coming back. And get used to getting it wrong the first time, because the smartest minds in the world can't predict performance of complex systems. The good news is that, unless you're getting a new user every 15 seconds, you're not going to hit 1M users in 6 months -- you have way more time than that. :-)
+1  A: 

If you start using seperate databases you can also run into an with you backup / restore strategy. If you have 5 databases and backup all five, what happens when you need to restore one of them, do you then need to restore all five?

I would opt for the fewest number of databases.

Amir Aliabadi

The reason you would want to have multiple databases is for scaling-out to multiple machines. In the context of a "social application" where large volume / high availability is a concern. If you anticipate the need to scale out to multiple machines to handle high volumes then the breakout of tables should be those that logically need to stay together.

So, for example, maybe you want to keep tables related to a specific subject area (maybe status updates) together in one database and other tables that are related to a different subject area (let's say user's picture libraries) together in a different database.

There are logical and performance reasons to keep tables in separate physical or logical databases.

Jay Stevens