title: Insert Data Into Tables Linked by Foreign Key
body: <p>I am using PostgreSQL.</p>
  
  <pre><code>Customer
  ==================
  Customer_ID | Name
  
  Order
  ==============================
  Order_ID | Customer_ID | Price
  </code></pre>
  
  <p>To insert an order, here is what I need to do usually,</p>
  
  <p>For example, "John" place "1.34" priced order.</p>
  
  <pre><code>(1) Get Customer_ID from Customer table, where name is "John"
  (2) If there are no Customer_ID returned (There is no John), insert "John"
  (3) Get Customer_ID from Customer table, where name is "John"
  (4) Insert "Customer_ID" and "1.34" into Order table.
  </code></pre>
  
  <p>There are 4 SQL communication with database involved for this simple operation!!!</p>
  
  <p>Is there any better way, which can be achievable using 1 SQL statement?</p>