title: MyISAM Engine table relations (MySQL)
body: <p>I’m using a host which only supports MyISAM tables engines for MySQL. I’m trying to create a CMS using php and MySQL, however, I’m having issues working out how to create relationships between the tables. For example, one of the features within this system is being able to assign tags to an article/blogpost, similar to how stack overflow has tags on their questions. </p>
  
  <p>My question is, as I cannot change my tables to use InnoDB, how can I form a relationship between the two tables? I am unable to use foreign keys as they are not supported in MyISAM, or at least not enforced. </p>
  
  <p>So far, all I've found when searching is keeping track of it through PHP by ensuring that I update multiple tables at a time, but there must be a way of doing this on the MySQL side.</p>
  
  <p>Below are examples of the Article and Tag tables.</p>
  
  <pre>
      +---------------------------+  +---------------------------+
      |         Article           |  |            Tags           |
      +---------------------------+  +---------------------------+
      | articleID    int(11)      |  | tagID         int(11)     |
      | title        varchar(150) |  | tagString     varchar(15) |
      | description  varchar(150) |  +---------------------------+
      | author       varchar(30)  |  
      | content      text         |  
      | created      datetime     |  
      | edited       datetime     |  
      +---------------------------+  
  </pre>
  
  <p>I’ve found loads of related questions on this site, but most of them InnoDB, which I cannot do as my host does not support it.</p>
  
  <p>I've found a solution (kind of). I've added another table called ArticleTags</p>
  
  <pre>
      +---------------------------+
      |        ArticleTags        |
      +---------------------------+
      | articleID    int(11)      |
      | tagID        int(11)      |
      +---------------------------+  
  
  </pre>
  
  <p>This query returns the correct result, but I'm not sure if it's a bit of a hack, or if there is a better way to do it.</p>
  
  <pre>
  SELECT `tagString` 
  FROM `Tags` 
  WHERE id 
  IN (
       SELECT `tagID` 
       FROM `ArticleTags` 
       WHERE `articleID` = :id
     ) 
  ORDER BY  `Tags`.`tagString`
  </pre>
  
  <p>Can someone tell me if this this right?</p>