title: MySql on delete cascade concept?
body: <p>I am trying to figure out how cascade delete works. I know the general concept but not the specifics of it.</p>
  
  <p>I have 3 tables (a)||---|&lt;(B)>o---||(C)</p>
  
  <p>Table A:</p>
  
  <pre><code>Aid
  Tag
  </code></pre>
  
  <p>Table B:</p>
  
  <pre><code>Aid (f)
  Cid (F)
  </code></pre>
  
  <p>Table C:</p>
  
  <pre><code>Cid
  Other
  </code></pre>
  
  <ul>
  <li>A row in table A must have at least one reference to table c or else it should be deleted. </li>
  <li>A row in table A is made only when Table C tries creating a tag that does not exist. If table C removes that tag and no other rows from table C reference that tag then the tag should be removed. If another row from table C references that tag then the tag should not be deleted.</li>
  </ul>
  
  <p>If I set Table B [Aid] to delete cascade would it:</p>
  
  <ol>
  <li>If the tag from table A is deleted automatically remove any links in table B</li>
  <li>I delete a row from table B belonging to tagz. There is another row in table B that references tagz. Would that deletion cause tagz to be deleted as well or would tagz remain so long as any row references it?</li>
  </ol>