title: PostrgreSQL ForeignKeyViolation
body: <p>I am attempting to insert some data into my database via a lambda function.  I am getting the following error <code>ForeignKeyViolation: insert or update on table &quot;address&quot; violates foreign key constraint &quot;address_id_fkey&quot;</code></p>
  <p>I understand that this is because my address table has a foreign key linking it to the clients table, and the keys are not matching.</p>
  <p>Is there a way to format my tables so that I can input my client data and address data together?  Or will I need to input the client data first, then retrieve the id and use it to input the address data.</p>
  <p>Currently I am running the following two functions.</p>
  <pre><code>    postgres_insert_query = &quot;INSERT INTO clients (name, phone, contact) VALUES ('{0}','{1}','{2}')&quot;.format(data['name'], data['phone'], data['contact'])
      postgres_insert_query = &quot;INSERT INTO address (line1, city, state, zip) VALUES ('{0}','{1}','{2}', {3})&quot;.format(address['line1'], address['city'], address['state'], address['zip'])
  </code></pre>
  <p>Even if no address data is present I would still like to create a row for it (with the correct foreign key).</p>