title: How to setup relationship between tables In phpMyAdmin
body: <p>The question I have is, when I create a table for example: <code>table1</code> with the following columns:</p>
  
  <ul>
  <li><code>customerId</code></li>
  <li><code>CustomerName</code></li>
  <li><code>Address</code></li>
  <li><code>State</code></li>
  </ul>
  
  <p>Where <code>customerId</code> is the <code>PRIMARY KEY</code> with <code>AUTO_INCREMENT</code>.</p>
  
  <p>And then <code>table2</code> for example with columns:</p>
  
  <ul>
  <li><code>purchaseId</code></li>
  <li><code>customerId</code></li>
  <li><code>product</code></li>
  <li><code>cost</code></li>
  </ul>
  
  <p>Where the <code>PRIMARY KEY</code> is <code>purchaseId</code> and the foreign Key is <code>customerId</code> from <code>table1</code>.</p>
  
  <p>It should mean that I already established a relationship between <code>table1</code> and <code>table2</code> using the <code>customerId</code>.</p>
  
  <p>Both these tables are initially empty so I wrote this SQL command:</p>
  
  <pre><code>INSERT INTO table1 (CustomerName,Address,State) VALUES('value1','value2','value3')
  </code></pre>
  
  <p>This works fine, but when I try to insert into the child table (<code>table2</code>) it tells me:</p>
  
  <blockquote>
    <p>ERROR a foreign key constraint</p>
  </blockquote>
  
  <p>So basically what I want to do is insert into the parent table then into the child table so that the <code>customerId</code> shows up in <code>table2</code> (child Table) as a foreign key and corresponds with <code>customerId</code> in <code>table1</code> (parent Table).</p>
  
  <p>DO I HAVE TO CREATE THE TWO TABLES FIRST WITHOUT THE FOREIGN KEY THEN TRY TO ESTABLISH A RELATIONSHIP. It Keeps saying there is a constraint as long as the relationship was there.</p>