PDA

View Full Version : How many Databases (General Feedback)


its_superman
11-05-2009, 10:47 AM
Hi

I am picking up php and sql quite well and read a couple of good books (excluding Sams) done a few tutorials etc etc.

The one thing they all forget to mention is how many database's you should have on one site.

Just want everyones feedback on this one.

Lets for arguments sake you were going to build a directory with 10 different sections on.
1.Jobs
2.Auto
3.Insurance
4.etc etc

Would you:-

1.Have a different database for each catergory.
2.Have a table for each, in one main Database.
3.Something else...dont know what this could be.
4.Or is it a case of "do it how you want"

If you just want to put a number so I can get a general feel for what "the norm" is.

Thanks in advance

bazz
11-05-2009, 04:20 PM
I think it should be better to read up on 'database normalisation' and 'database ER' so the decision you may make, will be based upon your own requirements.
If a direct answer were to be given here, it may not be the correct one for your application.

However, in general, it is better to have one database per site. the number and types of tables is determined by your own application of database normalisation.

I suppose one other thing to consider (though this is sort of managed by your normalisation choice), is how to reduce the number of db connections per page and indeed, per query. fewer is better.

hth

bazz

Coyote6
11-05-2009, 06:07 PM
I always think it's best to just have one database if you can. I personally use one database to control several different sites that are mine. As for clients each one gets their own database so their records stay separated from the others. I also have another project I am currently working on that has one central database that determines which secondary database to use based on client login credentials. (This could also be done with one database but I prefer not to mix different companies' records.) So in general I would say stay with one database solution if possible as it looks like it easily is with your example.

Old Pedant
11-05-2009, 07:56 PM
Besides, if you find that you have some things in common between the "categories", you will get much better efficiency from using a single database and doing inTRA-db joins.

Maybe you need a table of people, for example, with names/addresses/email/phone. So you would use *one* table, in that single DB, for people and then use FK's from all the other tables to the PK's in the people table. Just one example.

Hard to imagine a need for multiple DBs to support a single web site. Possible, but seems unlikely to be helpful/needful.