title: How becomes MySQL constraint invalid?
body: <p>We have got two tables. One is called "Station" and has several columns; one of them is "CityCode". The second table is called "StationTimezone" and it has also the column "CityCode".
  On StationTimezone we have defined a constraint on "CityCode" - it references "CityCode" in "Station".</p>
  
  <pre><code>CREATE TABLE `StationTimezone` (
    `CityCode` varchar(3) NOT NULL,
    `Timezone` varchar(50) NOT NULL COMMENT 'Name of the timezone',
    PRIMARY KEY (`CityCode`),
    CONSTRAINT `StationTimezone_ibfk_1` FOREIGN KEY (`CityCode`) REFERENCES `Station` (`CityCode`)
  ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='CityCode to Timezone name mapping';
  </code></pre>
  
  <p>We saw now, that StationTimezone has got entries which are not defined to Station. This means, after deleting the constraints, we cannot rebuild it.
  Now I've got the question how could we ever get to this problem. How was it possible to add "CityCodes" to StationTimezone without adding the same "CityCode" to "Station"?</p>