title: Resolving Error Code: 1005. Can't create table '' (errno: 150) Error
body: <p>I am creating following three tables in mysql</p>
  
  <blockquote>
    <ol>
    <li>POSTMASTER  </li>
    <li>ADVERTISEMENT </li>
    <li>CANDIDATEMAIN</li>
    </ol>
  </blockquote>
  
  <p>Here are the create statements</p>
  
  <blockquote>
    <p>POSTMASTER</p>
  </blockquote>
  
  <pre><code>CREATE TABLE `postmaster` (
    `POSTCODE` int(2) NOT NULL DEFAULT '0',
    `POSTNAME` varchar(250) DEFAULT NULL,
    PRIMARY KEY (`POSTCODE`)
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8
  </code></pre>
  
  <blockquote>
    <p>ADVERTISEMENT</p>
  </blockquote>
  
  <pre><code>CREATE TABLE `advertisment` (
    `ADVTNO` varchar(35) NOT NULL,
    `ADVTDATE` date NOT NULL,
    `POSTCODE` int(2) NOT NULL,
    `ADVTOPENDATE` date NOT NULL COMMENT 'ADVERTISEMENT OPENING DATE',
    `ADVTCLOSEDATE` date NOT NULL COMMENT 'ADVERTISEMENT CLOSING DATE',
    `EDITCLOSEDATE` date NOT NULL COMMENT 'CLOSING DATE FOR EDITING APPLICATION',
    `LASTREPRINTDATE` date NOT NULL COMMENT 'LAST DATE FOR REPRINTING APPLICATION',
    `FEESCST` int(4) NOT NULL COMMENT 'FEE FOR SC/ST CATEGORY',
    `FEESTAFF` int(4) DEFAULT NULL COMMENT 'FEE FOR STAFF ',
    `FEEOBC` int(4) DEFAULT NULL COMMENT 'FEE FOR OBC CATEGORY',
    `ADVOCATEEXPERIENCE` int(2) DEFAULT NULL,
    PRIMARY KEY (`ADVTNO`,`ADVTDATE`,`POSTCODE`),
    KEY `fk_post` (`POSTCODE`),
    CONSTRAINT `fk_post` FOREIGN KEY (`POSTCODE`) REFERENCES `postmaster` (`POSTCODE`)
  ) ENGINE=InnoDB DEFAULT CHARSET=latin1
  </code></pre>
  
  <p>Everything till here is fine but when I go for creation of the <strong><code>CANDIDATEMAIN</code></strong> table I get error</p>
  
  <blockquote>
    <p>Here is the create statement of <strong>CANDIDATEMAIN</strong></p>
  </blockquote>
  
  <pre><code>CREATE TABLE `candidatemain` (
  
    `ADVTNO` varchar(35) NOT NULL DEFAULT '',
    `ADVTDATE` date NOT NULL DEFAULT '0000-00-00',
    `POSTCODE` int(2) NOT NULL DEFAULT '0',
    `REGISTRATIONNO` int(6) NOT NULL DEFAULT '0',
    `SALUTATION` varchar(10) NOT NULL,
    `FULLNAME` varchar(90) NOT NULL,
    `SURNAME` varchar(30) DEFAULT NULL,
    `NAME` varchar(30) NOT NULL,
    `LASTNAME` varchar(30) DEFAULT NULL,
    `LASTUPDATEDIP` varchar(20) NOT NULL DEFAULT '',
    `LASTUPDATEDDATE` date DEFAULT NULL,
    `ENTRYDATE` date NOT NULL,
    PRIMARY KEY (`ADVTNO`,`ADVTDATE`,`POSTCODE`,`REGISTRATIONNO`),
    KEY `FK_ADVT` (`ADVTNO`, `ADVTDATE`,`POSTCODE`) ,
    CONSTRAINT `FK_ADVT` FOREIGN KEY (`ADVTNO`, `ADVTDATE`,`POSTCODE`) REFERENCES `advertisment` (`ADVTNO`, `ADVTDATE`,`POSTCODE`)
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8
  </code></pre>
  
  <p>The Error I get is :</p>
  
  <pre><code>Error Code: 1005. Can't create table 'dbName.candidatemain' (errno: 150)
  </code></pre>
  
  <p>What could be the reason for this error?</p>
  
  <blockquote>
    <p>MYSql Verion: <strong>mysql  Ver 14.14 Distrib 5.1.53, for Win64</strong></p>
  </blockquote>