title: Enforce unique rows in MySQL
body: <p>I have a table in <code>MySQL</code> that has 3 fields and I want to enforce uniqueness among two of the fields.  Here is the table <code>DDL</code>:</p>
  
  <pre><code>CREATE TABLE `CLIENT_NAMES` (
  `ID` int(11) NOT NULL auto_increment,
  `CLIENT_NAME` varchar(500) NOT NULL,
  `OWNER_ID` int(11) NOT NULL,
  PRIMARY KEY  (`ID`),
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
  </code></pre>
  
  <p>The <code>ID</code> field is a surrogate key (this table is being loaded with ETL).
  The <code>CLIENT_NAME</code> is a field that contains names of clients
  The <code>OWNER_ID</code> is an id indicates a clients owner.</p>
  
  <p>I thought I could enforce this with a unique index on <code>CLIENT_NAME</code> and <code>OWNER_ID</code>, </p>
  
  <pre><code>ALTER TABLE `DW`.`CLIENT_NAMES` 
  ADD UNIQUE INDEX enforce_unique_idx(`CLIENT_NAME`, `OWNER_ID`);
  </code></pre>
  
  <p>but MySQL gives me an error: </p>
  
  <blockquote>
    <p>Error executing SQL commands to update table.
    Specified key was too long; max key length is 765 bytes (error 1071)</p>
  </blockquote>
  
  <p>Anyone else have any ideas?</p>