title: 1-N relation with foreign key which is NOT a primary key (primary is auto_increment 'id') with doctrine2/symfony2
body: <p>I have the following two tables:</p>
  
  <pre><code>CREATE TABLE IF NOT EXISTS `skills` (
    `id` int(11) NOT NULL AUTO_INCREMENT,
    `skill_category` varchar(50) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
    `skill` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
    `icon_filename` varchar(50) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
    `display_priority` int(11) NOT NULL,
    PRIMARY KEY (`id`),
    KEY `skill_category` (`skill_category`)
  ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
  
  CREATE TABLE IF NOT EXISTS `skills_categories` (
    `id` int(11) NOT NULL AUTO_INCREMENT,
    `skill_category` varchar(50) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
    `display_priority` int(11) NOT NULL,
    PRIMARY KEY (`id`),
    UNIQUE KEY `IDX_95FF1C8D47E90E27` (`skill_category`)
  ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
  
  ALTER TABLE `skills`
    ADD CONSTRAINT `skills_ibfk_1` FOREIGN KEY (`skill_category`) REFERENCES `skills_categories` (`skill_category`);
  </code></pre>
  
  <p>Note the foreign key relation between the two skill_category columns.  </p>
  
  <p><img src="https://i.stack.imgur.com/Thpjj.png" alt="table structure"></p>
  
  <p>I am trying to create a manytoone/onetomany relation between these tables.  A one unique skill_category should have many skills.  This structure seems to work fine, except when I try and verify the mapping I get the error:</p>
  
  <blockquote>
    <p>The referenced column name 'skill_category' has to be a primary key
    column on the target entity class
    'Resume\ResumeBundle\Entity\SkillsCategories'.</p>
  </blockquote>
  
  <p>There is a requirement by doctrine that the referenced column be a primary key.  If I make this key a primary key, my id column is no longer auto incremented, which I want.  So mySQL seems to be ok with the fact that the foreign key is a primary key, however Doctrine complains about this case.   Someone said they fixed it by just recreating the columns:</p>
  
  <p><a href="http://goo.gl/vvq0tu" rel="nofollow noreferrer">http://goo.gl/vvq0tu</a></p>
  
  <p>i've tried this, and it didn't seem to help for me.  So either this is some sort of bug or I have a fundamental misunderstanding of RDBMS (completely possible).  Is my problem that I shouldn't be using an 'id' column at all?  That if I expect my 'skills_category' column to be unique that I should make THAT the primary key and just remove the 'id' column?  That would solve my problems, but is there any problems with making a VARCHAR the primary key?  Google's answer seems to be 'not really', but I would appreciate some perspective from someone else.</p>