title: Database - Create table with 2 fields pointing to the same table
body: <p>I need to create a table in a database that includes - the following columns - </p>
  
  <pre><code>table name - transaction  
  time, source-address, destination-address
  </code></pre>
  
  <p>I have a table of addresses like this - </p>
  
  <pre><code>table name - address
  address id, address, type (home/office/etc...)
  </code></pre>
  
  <p>I would like to keep only a pointer from the fields source-address and destination-address to the entries in the table "address".</p>
  
  <p>Transaction can be done between the same address as well - for example it can be done from home address to home address or from home address to work address and all of it is legal.</p>
  
  <p>What is the best way to do it?</p>
  
  <pre><code>SAMPLE DATA -  
  ADDRESS  
  ID    ADDR       TYPE  
  1     x-street   home  
  2     y-street   work  
  
  TRANSACTION  
  TIME    SRC      DST     
  08:00      1     1  
  08:15      2     1  
  ....
  </code></pre>
  
  <p>I would like to connect <code>TRANSACTION</code> table to the <code>ADDRESS</code> table but I am not sure if I can do it using foreign keys as here I have the same key - ID from the table ADDRESS which is connected to the <code>SRC</code> and <code>DST</code> fields in the table TRANSACTION.</p>
  
  <p>I would appreciate to get an approach description of what is the best way to do what I need to do - like a design suggestion.</p>