title: Schema for address in Postgres
body: <p>I have <code>satffs</code> and <code>users</code> tables in database.</p>
  
  <pre><code>// staffs
  
  id Int
  role_id Int
  name String
  </code></pre>
  
  <pre><code>// users
  
  id Int
  name String
  </code></pre>
  
  <p>I need to add address for both. (Because I want to allow user to have multiple addresses in future, but may be not for staffs.)</p>
  
  <p>Which one would be better? </p>
  
  <p><strong>Option 1</strong>: Create dedicated address databases for each <code>users</code> and <code>staffs</code>.</p>
  
  <pre><code>// user_addresses
  
  id Int
  user_id &lt;FK&gt; Int
  street String
  city String
  </code></pre>
  
  <pre><code>// staff_addresses
  
  id Int
  staff_id &lt;FK&gt; Int
  street String
  city String
  </code></pre>
  
  <p><strong>Option 2</strong>: Or create <code>addresses</code> table and create 2 more tables with <code>users</code>, <code>staffs</code> and <code>addresses</code> id references.</p>
  
  <pre><code>// addresses
  
  id Int
  street String
  city String
  </code></pre>
  
  <pre><code>// user_addresses
  
  id Int
  user_id &lt;FK&gt; Int
  address_id &lt;FK&gt; Int
  </code></pre>
  
  <pre><code>// staff_addresses
  
  id Int
  staff_id &lt;FK&gt; Int
  address_id &lt;FK&gt; Int
  </code></pre>