Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: two databases

  1. #1
    Join Date
    Jun 2011
    Location
    Pearl of the East
    Posts
    54
    Thanks
    1
    Thanked 2 Times in 2 Posts

    Default two databases

    gud day everyone,.

    my program is using two databases; the one database is for other details and other is for the names and account id of the said details

    my problem is when im only retrieving the two fields from the other database my program gets crushed,.
    but when im only retrieving the account id, i got no errors at all,.

    my question is, is it because i got two databases? or is it because my script got a long algorithm?

    but when im trying to run it with two separate programs it is working,.
    eg. a page that retrieves the account id and the names - it works
    the other page is for the details - it works,.





    thx in advance,.
    i hope you got my point ^_^


    GOD bless
    more power,.

    regicide del feroz

  2. #2
    Join Date
    Jul 2010
    Location
    Minnesota
    Posts
    256
    Thanks
    1
    Thanked 21 Times in 21 Posts

    Default

    This would be hard to say without seeing the code. Now are you actually talking about 2 separate db's or 2 separate tables within one db? It's not common practice to have more than one db per site. If you're getting info from 2 separate tables in one db then you could look into JOIN to help make it one query.

  3. #3
    Join Date
    Jun 2011
    Location
    Pearl of the East
    Posts
    54
    Thanks
    1
    Thanked 2 Times in 2 Posts

    Default

    thanks for the reply,.

    sir, i'm getting two separate dbs,. because they are from different categories,.
    i already tried to combine them in only one db but still i got the same problem,.

    what do you think sir?,. is it with my codes?

  4. #4
    Join Date
    Jun 2011
    Location
    Pearl of the East
    Posts
    54
    Thanks
    1
    Thanked 2 Times in 2 Posts

    Default

    bump!

  5. #5
    Join Date
    Sep 2007
    Location
    Maui
    Posts
    642
    Thanks
    284
    Thanked 15 Times in 15 Posts

    Default

    I can't imagine a situation where you would require 2 separate databases. You haven't really provided enough information for anyone to help you, but my guess would be that the problem stems from the tables not being in the same database. You just need to add a category table. What are the items that are in the categories? What are you dealing with? That would help shed some light.

    It just sounds so wrong to have the account_ids in one database and then the details in a separate database that are presumabley identified by the account_id in the other database. Is that even possible?

  6. #6
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    You can use one database with multiple tables. It will be much easier. Is there a reason that can not work?
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  7. #7
    Join Date
    Jun 2011
    Location
    Pearl of the East
    Posts
    54
    Thanks
    1
    Thanked 2 Times in 2 Posts

    Default

    i already tried them in using one database but i still got the same problem,.

  8. #8
    Join Date
    Sep 2007
    Location
    Maui
    Posts
    642
    Thanks
    284
    Thanked 15 Times in 15 Posts

    Default

    And we have yet to see the problem. What does it mean that your program gets "crushed?" Please show us your code and the table structures in your databases. One of the geniuses on this forum would have had your problem solved already if they had some clue what you were doing.

  9. #9
    Join Date
    Jun 2011
    Location
    Pearl of the East
    Posts
    54
    Thanks
    1
    Thanked 2 Times in 2 Posts

    Default

    i mean crashed,.

    on the first table:
    |----------------------|
    | ID | Account_Name |
    |----------------------|
    | 1 | Coca Cola |
    | 2 | Mountain Dew |
    |----------------------|

    table 2:

    |-------------------------|
    | ID | Size | Price |
    |-------------------------|
    | 1 | 8 oz. | Php 8 |
    | 1 | 12 oz. | Php 12 |
    | 2 | 12 oz. | Php 14 |
    |-------------------------|



    the output that i wanted to be is:

    |---------------------------------------|
    | ID | Account_Name | Size | Price |
    |---------------------------------------|
    | 1 | Coca Cola | 8 oz. | Php 8 |
    |<no value>|<no value>| <br>12 oz. | Php 12|
    | 2 | Mountain Dew | 12 oz. | Php 14|
    |----------------------------------------|


    *Php stands for Philippine Peso


    hope you understand,. i can't format the table because our forum does not support
    nor [pre][/pre]


    thanks

  10. #10
    Join Date
    Sep 2007
    Location
    Maui
    Posts
    642
    Thanks
    284
    Thanked 15 Times in 15 Posts

    Default

    Thank you. This should definitely be done using only one database. Think of it this way.

    product table
    product_id | product
    ---------------------------
    1 Coca Cola
    2 Mountain Dew

    inventory table
    product_id | size | price
    ---------------------------
    1 8 oz Php 8
    1 12 oz Php12
    2 12 oz Php 14

    Code:
    SELECT t1.product_id, t1.product, t2.size, t2.price FROM product t1, inventory t2 WHERE t1.product_id = t2.product_id ORDER BY product
    There is a one-to-many relationship between the product and inventory tables. Generally you store the data in the tables in a concise form (no redundant data) and then use reports or scripts to format the output so that it looks nice with non-repeating headings and such. In other words, you use SQL commands to retrieve the data from your tables but you format the data for display on a website, or to print a report, using php and html or some other scripting language. I'm sure Daniel or one of the other geniuses can explain this much better than I.
    Last edited by kuau; 07-01-2011 at 02:06 PM. Reason: forgot to add code tags

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
  •