title: Implement specialization in ER diagram
body: <p><img src="https://i.stack.imgur.com/9wRwR.png" alt="Er diagram"></p>
  
  <p>I want to implement this specialization relationship. Knowing that I will have different attributes for each account type. Here's my try:</p>
  
  <pre><code>accounts(account_id, email, username, password, ...)
  user_accounts(account_id, ..)
  admin_accounts(account_id, ..)
  messages(subject, body, from_account_id, to_account_id)
  </code></pre>
  
  <p>Where account_id in user_accounts and admin_acounts is the primary key and foreign key references account_id on accounts<br/>
  And from_account_id, to_account_id in messages references account_id on accounts.</p>
  
  <p>But what happens if I wanted to create a relationship with one of the account type only. For example I want to give permissions to admins to manage something, So I would do something like this:</p>
  
  <pre><code>permissions(admin_account_id, type, value, ..)
  </code></pre>
  
  <p>Where admin_account_id is a foreign key references account_id on admin_accounts</p>
  
  <p>Is that possible? And what would happen If I tried to enter a permission for a user_account_id instead?</p>
  
  <p>I hope my question is clear and excuse my English language.</p>