title: MySQL - Link two elements from the same table in another table
body: <p>I have created a table in MySQL, and i would like to make connections between those elements.</p>
  
  <p>It should be a many-to-many relationship, and what i've come up with is the following:</p>
  
  <ul>
  <li><p>Create a table with the elements:</p>
  
  <p>table Medicine</p>
  
  <p><strong>| id | name | description |</strong></p></li>
  <li><p>Create a table with the links:</p>
  
  <p>table Incompatibilities</p>
  
  <p><strong>| medicine_id_1 | medicine_id_2 |</strong></p></li>
  </ul>
  
  <p>So when i want to create an incompatibility between medicine 1 and medicine 2, i should do:</p>
  
  <pre><code>INSERT INTO incompatibilities VALUES 1,2
  </code></pre>
  
  <p>And when i would like to retrieve all the medicine that are incompatible with medicine ID = 1 i should do:</p>
  
  <pre><code>SELECT * FROM incompatibilities WHERE medicine_id_1=1 OR medicine_id_2=1
  </code></pre>
  
  <p>Is this the correct way to do it? Are those queries work as intended? Is there a more efficient way to do what i am after?</p>
  
  <p>thank you in advance</p>