views:

84

answers:

2

Hi,

I'm currently developing a web application for a particular niche. The point is that users can create an account, manage specific data and use that data on their website through API calls. So it's actually some sort of WordPress CMS but without the front end functionality. It is also not open source.

So in short, user can manage their data and use it on another remote website through an API.

My question:

Should I create an empty database for each new account or should link each record with a unique ID for that account?

Which of the two is the most common way, which one is the most secure and which one requires the least maintenance?

+1  A: 

Usually it's a bad idea to start duplicating databases. As your system changes, you'll have to apply patches to all of the different databases so that they work with the code changes. This can be tricky. A much simpler solution is to just keep everything in a single database. Any data that is user-specific should have an identifier (such as UserID) so you know which user it belongs to.

The only case I can think were creating a new instance of the database makes sense is where the instances of the database will run on physically separate machines, for different clients.

FrustratedWithFormsDesigner
Just like I thought. Can it be a security issue? eg: there are a thousand accounts and one hacker. When a hacker manages to alter the database -> a thousand websites will be broken. When I use the other method (multiple databases) I don't have that problem.
Bundy
@Bundy: True, but if it's a technical exploit (versus a social one such as conning someone into giving up a password), they will all be vulnerable in the same way, especially if they are on the same physical machine. It might protect the other accounts a little bit, but it's hard to say how much. Is it worth the extra maintenance of *n* duplicated systems?
FrustratedWithFormsDesigner
A: 

i think that depends on what the site will do.

if it serves separate business, like what is provided by sourceforge, which is targeting a group of users's business, then separate your user tables or even dbs, or have some procurement process is necessary

if you are targeting your site to individual users it's easier to go with records of users

Andy Lin