Access to multiple databases

Discussion in 'MySQL' started by coolsitez, Dec 20, 2007.

  1. #1
    Anyone know how to access to multiple databases at a time? Are there such tools for it?

    I guess I would need one big database to do the same thing, but I don't know how. ;)
     
    coolsitez, Dec 20, 2007 IP
  2. blacknet

    blacknet Active Member

    Messages:
    709
    Likes Received:
    16
    Best Answers:
    2
    Trophy Points:
    70
    #2
    seriously?
    what db type(s) and language?
    + would you not be better knowing how to combine the db's..?
     
    blacknet, Dec 20, 2007 IP
  3. BungeeBones

    BungeeBones Peon

    Messages:
    109
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    The XML language was designed to exchange data between different db types.
     
    BungeeBones, Dec 20, 2007 IP
  4. coolsitez

    coolsitez Well-Known Member

    Messages:
    2,586
    Likes Received:
    246
    Best Answers:
    0
    Trophy Points:
    183
    #4
    How do you combine them? Just adding more tables and stuff?
     
    coolsitez, Dec 20, 2007 IP
  5. Guernica

    Guernica Peon

    Messages:
    268
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Im confused, you talking about connecting to 2 different databases, and exchanging information between them? You can just connect to them both with different variables of course and call the data in, then insert it later on.

    Unless I am total noob and missed something...
     
    Guernica, Dec 20, 2007 IP
  6. cmahale

    cmahale Peon

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Hi,

    If you have a two database, and you want to create one big database, you can import it the 2nd database in 1st and make it a one big database, If the database version is same.

    Or you can convert it into single version and and merge it.
     
    cmahale, Dec 21, 2007 IP
  7. bluegrass special

    bluegrass special Peon

    Messages:
    790
    Likes Received:
    50
    Best Answers:
    0
    Trophy Points:
    0
    #7
    If you are talking about managing 2 different databases then most of the developers have software to manage multiple databases of the same type. Those usually only work if they are all the same type of database (all SQL server, all Oracle, all MySQL, etc...). There are some third party solutions that allow you to manage multiple databases of different types, but they usually do not give you full functionality.

    If you are talking about accessing multiple databases from a web page, then your project needs multiple connection strings (one for each database).

    If you want the data to interact, it depends on where it needs to interact. Most major databases have some sort of data transfer protocol. They do not always work across database types, but many do. You would use this method if you want the interaction of data to occur in the database itself (say in stored procedure or function). If you want the data to ineract on a web page, depending on how it interacts it is best to do that within the page code itself for simple interactions (displaying two tables from different databases for example). If the interaction is complex (calculating totals or matching rows) it will probably be easier to do that in a database tranfer.
     
    bluegrass special, Dec 21, 2007 IP
  8. coolsitez

    coolsitez Well-Known Member

    Messages:
    2,586
    Likes Received:
    246
    Best Answers:
    0
    Trophy Points:
    183
    #8
    That's what I am talking about. Sorry, I failed to mention the databases are based on the same type. The thing is, I want to display them in one web page, admin control panel, to work with those databases at a time. I suppose it's all about programming the php. I just am no good with it.
     
    coolsitez, Dec 22, 2007 IP
  9. InFloW

    InFloW Peon

    Messages:
    1,488
    Likes Received:
    39
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Well I'm not sure what database engine you're using but on mysql and pgsql you can do the following:

    
    SELECT a.* b.* 
    FROM
    db1.table a
    JOIN db2.table b ON b.foreign_id=a.id
    
    Code (markup):
    As an example there where I joined two different tables from separate databases in the same query. Of course the basic idea here is you reference them via database_name.table opposed to just table if you had selected a specific db to interact with.
     
    InFloW, Dec 25, 2007 IP
  10. bfellow

    bfellow Active Member

    Messages:
    266
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    78
    #10
    coolsitez is right. Doing it via a PHP page is easy as long as you keep everything organized. You can have multiple connections to different DB's going at the same time. You can dump stuff into variables and them manipulate from there. This is fine with small datasets. Large datasets you should avoid this as it can be very taxing on the server. Also, for this operation, avoid the '*' marker. Only grab what you absolutely have to have. It loads everything from the selected table (or even the DB depending on your SQL statement) into memory! Imagine storing 1,000 images in long blob format and using the wildcard to load everything! Not a pretty sight.
     
    bfellow, Dec 26, 2007 IP
  11. kendo1979

    kendo1979 Peon

    Messages:
    208
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #11
    connect to both database with different variables, then you can manipulate those using a customized script. i think it shouldn't be hard.
     
    kendo1979, Dec 27, 2007 IP