Closed Thread
Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: How to use multiple databases?

  1. #1
    xiou is offline Newbie
    Join Date
    Apr 2008
    Posts
    4
    Rep Power
    0

    How to use multiple databases?

    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.

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

     
  3. #2
    Join Date
    Sep 2007
    Location
    Karlstad, Sweden
    Posts
    3,082
    Blog Entries
    7
    Rep Power
    42

    Re: How to use multiple databases?

    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.
    Code:
    select b.field7 from myfirstdatabase.table1 a, myseconddatabase.mytable2 b
    where a.field1 = b.field2

  4. #3
    Join Date
    Jul 2006
    Posts
    16,494
    Blog Entries
    75
    Rep Power
    143

    Re: How to use multiple databases?

    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.
    Programming is a branch of mathematics.
    My CodeCall Blog | My Personal Blog

  5. #4
    xiou is offline Newbie
    Join Date
    Apr 2008
    Posts
    4
    Rep Power
    0

    Re: How to use multiple databases?

    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.

  6. #5
    Join Date
    Mar 2008
    Location
    The North Pole
    Posts
    13,174
    Blog Entries
    13
    Rep Power
    114

    Re: How to use multiple databases?


    Quote Originally Posted by Jordan View Post
    Good members, like yourself, stick around and post for ages to come!
    Mr. Xav | Blog | Forums

  7. #6
    Join Date
    Sep 2007
    Location
    Karlstad, Sweden
    Posts
    3,082
    Blog Entries
    7
    Rep Power
    42

    Re: How to use multiple databases?

    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.

  8. #7
    Sionofdarkness is offline Programming Expert
    Join Date
    Jul 2006
    Posts
    383
    Rep Power
    0

    Re: How to use multiple databases?

    I believe most large websites have multiple databases for different kinds of information.

  9. #8
    Join Date
    Sep 2007
    Location
    Karlstad, Sweden
    Posts
    3,082
    Blog Entries
    7
    Rep Power
    42

    Re: How to use multiple databases?

    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

  10. #9
    tecktalk is offline Programmer
    Join Date
    May 2008
    Posts
    179
    Rep Power
    0

    Re: How to use multiple databases?

    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

  11. #10
    Jordan Guest
    Quote Originally Posted by orjan View Post
    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
    I agree. In fact I think this would be slower (to divide dbs) but I've never seen benchmark tests.

    Posted via CodeCall Mobile

Closed Thread
Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 5
    Last Post: 04-04-2011, 07:34 AM
  2. C# and Databases
    By Forex91 in forum C# Programming
    Replies: 2
    Last Post: 10-18-2010, 06:04 AM
  3. multiple users, multiple applications, one server.
    By Fittersman in forum Programming Theory
    Replies: 3
    Last Post: 07-15-2010, 08:32 AM
  4. Impossible? Integrating multiple databases without access
    By zaindhanani in forum Database & Database Programming
    Replies: 3
    Last Post: 08-12-2009, 01:15 PM
  5. Databases and C++
    By Emir in forum C and C++
    Replies: 5
    Last Post: 05-26-2009, 01:02 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts