How To Link Multiple Databases Together?

Discussion in 'Databases' started by andrewbr549, Jul 18, 2012.

  1. #1
    Hello,

    I am wondering how do you link multiple My SQL databases together for a website. It is for usernames and passwords so people can register for one thing on the website and be automatically registered for everything else.

    Thanks,

    Andrew
     
    andrewbr549, Jul 18, 2012 IP
  2. Klar

    Klar Peon

    Messages:
    10
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I don't think there is a good solution for doing that directly. You can always use triggers to copy the data to other databases and have other triggers for data validation (i.e. consistent passwords). Or you can change the design where there is a user table and everything links off of it.
     
    Klar, Jul 21, 2012 IP
  3. sarahk

    sarahk iTamer Staff

    Messages:
    28,807
    Likes Received:
    4,534
    Best Answers:
    123
    Trophy Points:
    665
    #3
    You can login to multiple databases at one time and http://nz.php.net/manual/en/function.mysql-connect.php shows you how you can have different $link variables to identify each database you have connected to.

    You'd just need to code the update through each relevant database. The links could even be held in an array so that you could use foreach() to work through each connection without having to be particularly mindful of how many connections there are - which makes it flexible you add/remove sites in the future.
     
    sarahk, Aug 1, 2012 IP
  4. lolpasslol

    lolpasslol Peon

    Messages:
    860
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #4
    For linking database use key such as ,primary key,secondary key etc.
    Also have others procedure like inner joint,outer joint etc.
    If you take a short course everything will be clear I think.
     
    lolpasslol, Aug 12, 2012 IP
  5. andrewbr549

    andrewbr549 Greenhorn

    Messages:
    26
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    11
    #5
    Where would I take a course like that?
     
    andrewbr549, Aug 12, 2012 IP
  6. sarahk

    sarahk iTamer Staff

    Messages:
    28,807
    Likes Received:
    4,534
    Best Answers:
    123
    Trophy Points:
    665
    #6
    No, you use keys to link tables within a database.

    The OP is asking about linking databases together
     
    sarahk, Aug 12, 2012 IP