title: in mysql, on delete cascade not working
body: <p>similar to <a href="https://stackoverflow.com/questions/5308255/on-delete-cascade-not-working-in-mysql">ON DELETE CASCADE not working in MySQL</a>, but something is not right:</p>
  
  <h3>The ANSI Way</h3>
  
  
  
  <pre class="lang-sql prettyprint-override"><code>-- test delete cascade
  CREATE TABLE t1(
      id SERIAL PRIMARY KEY,
      data TEXT
  );
  
  CREATE TABLE t2(
      id INT PRIMARY KEY REFERENCES t1(id) ON DELETE CASCADE,
      data2 TEXT
  );
  
  INSERT INTO t1 VALUES(1, 'one');
  INSERT INTO t2 VALUES(1, 'first');
  
  DELETE FROM t1;
  SELECT * FROM t2; -- should have not rows - have one!
  </code></pre>
  
  <p>use this <em>all the time</em> in postgres, but for some reason cannot get it going in mysql.</p>
  
  <hr />
  
  <p>I am slowly learning, there is the ansi-standard, postgreql way, and there is the mysql way.  Each time I think I have somewhat appreciated the difference, I haven't come close.</p>
  
  <h3>The MySQL Way</h3>
  
  <pre class="lang-sql prettyprint-override"><code>CREATE TABLE `t2` (
      `id` BIGINT(20) UNSIGNED NOT NULL,
      `data2` TEXT,
      PRIMARY KEY (`id`),
      CONSTRAINT `FK_t2_1` FOREIGN KEY (`id`) REFERENCES `t1` (`id`) ON DELETE CASCADE
  ) ENGINE = InnoDB DEFAULT CHARSET = latin1;
  </code></pre>
  
  <p>To me, the code I have is ansi standard, makes perfect sense, and is (as far as SQL goes) aesthetically pleasing, whereas, the mysql way (thanks for the help!) reminds me of Visual Basic or something - it's really ugly as sin and imho it's wrong to ask intelligent people to debase themselves to write such a thing.</p>
  
  <p>I apologize if ranting, and justly deserve any number of negative ratings. You guys who write this code with ease have my greatest respect.  I just hate to see this sort of meaningless punishment inflicted on friends ;-)</p>