title: Connect multiple many-to-many relationships to each other
body: <p>I want to model a scheme in which there are some items, some user and some tags. So I have a database in which I have three tables: <code>User</code>, <code>Tag</code> and <code>Item</code>.</p>
  
  <p>Each user can assign some tags to the item. Just looking at the relationship between <code>Item</code> and <code>Tag</code> I would say that this is a classical many-to-many relationship - each <code>Item</code> can have multiple <code>Tag</code> elements assigned. So far it is clear.</p>
  
  <p>The problematic part now is that each user can use its own tags and they may or may not be the same that other users have used. In SQL I think this can be modeled with a unique slug for each <code>Tag</code> that is reused if it exists and will be created if not.</p>
  
  <p>Now this seems like an additional many-to-many relationship. Each <code>Tag</code> can be assigned by multiple <code>User</code> elements (for multiple items). But how do I join both many-to-many relationships efficiently?</p>
  
  <p>In the end I want to be able to say something like this:</p>
  
  <ul>
  <li><code>Tag1</code>, <code>Tag2</code> are assigned to <code>Item1</code></li>
  <li><code>Tag1</code> is shared by <code>User1</code> and <code>User2</code> for <code>Item1</code> but not by <code>User3</code></li>
  <li><code>Item1</code> is tagged by <code>Tag1</code> by <code>N</code> users</li>
  </ul>
  
  <p>How can I translate this idea into a SQL scheme?</p>
  
  <p>Thanks in advance for any ideas.</p>