SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2004
    0 Post(s)
    0 Thread(s)

    Referential Integrity Error

    I'm learning how to publish databases online by exporting them as SQL files, then going into my online C-Panel and importing them.

    On my first attempt, just one of six tables was successfully imported. I understand the error message referred to a "Referential Integrity" issue. The second table couldn't be imported because one of its fields is associated with a field on another table that had not yet been imported.

    I've determined that the solution is to insert two statements in a dump file that contains create table statements.

    SET FOREIGN_KEY_CHECKS = 0; [at the beginning of the file]
    SET FOREIGN_KEY_CHECKS = 1; [at the end of the file]

    Because I don't know how to use the command line client with MySQL, I'd like to know if I can open this document with Notepad and insert the statements. If so, can someone tell me where to find this file?

    Also, I wondered if a second strategy would work: Can I export and import my database one table at a time?

    And here's my last question. I don't understand what I have to do to prepare for a database import. Suppose a database on my local computer is named jack_star.

    1. Do I have to create a database named jack_star on my remote site before I can import my local jack_star? Or can I open up phpMyAdmin on a remote site with a "blank slate" and just import whatever databases I want?

    2. After I've imported a database online, can I import successive databases on top of it? In other words, suppose I publish jack_star online. Later I modify a table on my LOCAL jack_star database online. Can I then republish jack_star online, with the amended table? I'm a little confused because on a recent attempt, I received a "table already exists error." I thought it would simply write over it.


  2. #2
    SitePoint Wizard
    Join Date
    Jul 2003
    1 Post(s)
    0 Thread(s)
    The order you create tables is important.

    First do all the tables that have no foreign keys.
    Then do those which only have foreign keys from the tables above.
    Then do those which only have foreign keys from those now above, etc.

    This is true for all relational databases


Posting Permissions

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