Is it possible to use multiple databases for one website. What I have in mind is having one database that stores user information and administration information. Then I would have different databases depending on the user's information. The admins will have full privileges to everything on the site but the members could only use one database based on their email/state/sex/etc.
Is this possible to do? I kinda want it to be like facebook's site right when it came out in how only people from one college could look at people from the same college. If they tried to look at someone from a different college, they were denied.
If someone could point me in the right direction, I would thankful.
How to use multiple databases?
Started by xiou, May 22 2008 11:08 AM
10 replies to this topic
#1
Posted 22 May 2008 - 11:08 AM
|
|
|
#2
Posted 22 May 2008 - 11:46 AM
ofcourse it is, as long as your serverprovider allows more than one db.
I do it in a system I run.
make a sort of a base db with a table with users, and you set a db name as a parameter on the user.
when user is verified, just do a changedb($usertable[database]) or similar in your programming language, then just carry on running your page. if you have identical tables on every database,
in MySQL, you can otherwise access different databases by addresing the table with punktuation: database.table.field
Here's an example for MySQL, i guess most SQL is alike.
I do it in a system I run.
make a sort of a base db with a table with users, and you set a db name as a parameter on the user.
when user is verified, just do a changedb($usertable[database]) or similar in your programming language, then just carry on running your page. if you have identical tables on every database,
in MySQL, you can otherwise access different databases by addresing the table with punktuation: database.table.field
Here's an example for MySQL, i guess most SQL is alike.
select b.field7 from myfirstdatabase.table1 a, myseconddatabase.mytable2 b where a.field1 = b.field2
#3
Posted 22 May 2008 - 01:51 PM
The answer will depend a little bit on the server-side language you use, but I expect it is always "yes". The details will depend on the language, of course. Everything you are describing could be done with a single database, however.
#4
Posted 26 May 2008 - 08:25 AM
Thanks for the responds.
The language I plan on using is PHP. Do either of you know any tutorials that will set me on the path to understanding this problem? Thanks again for the responds.
The language I plan on using is PHP. Do either of you know any tutorials that will set me on the path to understanding this problem? Thanks again for the responds.
#5
Posted 26 May 2008 - 09:07 AM
Try PHP Tutorial.
#6
Posted 26 May 2008 - 01:58 PM
the most common way to solve the problem of user grouping and such is to set either a column with group number in the user table so you always query out the user's group. the other way is if user is to be in several groups, make another table with just groupnumber and userid (and prefferably an auto-incrementing id, and index on both groupid and userid separately) and first query which groups the user is member of, then query all members of all those groups, one at a time or all at one as wished.
#7
Posted 28 May 2008 - 10:42 AM
I believe most large websites have multiple databases for different kinds of information.
#8
Posted 28 May 2008 - 01:30 PM
not necessarily, as far as I know, you don't gain speed of dividing in databases unless you split large tables into several?
better would be to build a clustered server instead, with one great database.
things where you can gain with using several databases would be if you run several identical sites with no need to communicate between sites...
as a site of many forums put a new db for each forum to separate customers or similar.
thats my thaughts
better would be to build a clustered server instead, with one great database.
things where you can gain with using several databases would be if you run several identical sites with no need to communicate between sites...
as a site of many forums put a new db for each forum to separate customers or similar.
thats my thaughts
#9
Posted 03 June 2008 - 09:01 AM
yes you can.. please check with your hosting service provider if he has allowed you to do so.. is it in you package or not.
Lyf come without guarantees, except that smiling will brighten ur face, laughing will enhance ur eyes, and falling in luv will change ur lyf
#10
Guest_Jordan_*
Posted 03 June 2008 - 11:27 AM
Guest_Jordan_*
orjan said:
not necessarily, as far as I know, you don't gain speed of dividing in databases unless you split large tables into several?
better would be to build a clustered server instead, with one great database.
things where you can gain with using several databases would be if you run several identical sites with no need to communicate between sites...
as a site of many forums put a new db for each forum to separate customers or similar.
thats my thaughts
better would be to build a clustered server instead, with one great database.
things where you can gain with using several databases would be if you run several identical sites with no need to communicate between sites...
as a site of many forums put a new db for each forum to separate customers or similar.
thats my thaughts
I agree. In fact I think this would be slower (to divide dbs) but I've never seen benchmark tests.
Posted via CodeCall Mobile
#11
Posted 03 June 2008 - 04:54 PM
I think it would be slower if you need to access data from all the tables at some points, and you need to union all tables from all databases that you need a total view of.
a pure select must be faster than making loads of unions.
a pure select must be faster than making loads of unions.


Sign In
Create Account

Back to top









