title: Database ERD - Junction Table (one-to-many)
body: <p><strong>OBJECTIVE</strong></p>
  
  <p>Create a table for Accounts Receivable to input invoice/payment data per customers. Data will be used to determine Account Receivable Aging metrics.</p>
  
  <p><strong>APPROACH</strong></p>
  
  <ol>
  <li>Create a <code>customer</code> table with relevant information </li>
  <li>Create an <code>invoice</code> table with relevant information (including <code>customerID</code>)</li>
  <li>Create a <code>payments</code> table that ties <code>customer</code> and <code>invoices</code> together</li>
  </ol>
  
  <p><strong>ERD DIAGRAM</strong></p>
  
  <p><a href="https://i.stack.imgur.com/SR4tw.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/SR4tw.png" alt="enter image description here"></a></p>
  
  <p><strong>NOTES</strong></p>
  
  <ul>
  <li>1 Invoice can have multiple payments (e.g Customer makes partial payments until Invoice is complete)</li>
  <li>Each payment is related back to a single customer (multiple customers will not be paying on behalf of another customer)</li>
  </ul>
  
  <p><strong>QUESTION</strong></p>
  
  <ol>
  <li>Is my one-to-one for Customer > Payments a proper connection? Customers will be only paying their own invoices, so I believe it's a one-to-one relationship. However, a single Customer can have many payments (for different invoices). </li>
  <li>If a single customer makes multiple payments on one invoice, I intend to differentiate the payments by 'date_paid' (payments table). Is there a more robust way of distinguishing between 1 customer making multiple payments on 1 invoice?</li>
  </ol>