MySQL não pode criar restrição de chave estrangeira

Estou tendo problemas para criar uma chave estrangeira para uma tabela existente em um banco de dados mysql.

Eu tenho a mesaexp:

+-------------+------------------+------+-----+---------+-------+
| Field       | Type             | Null | Key | Default | Extra |
+-------------+------------------+------+-----+---------+-------+
| EID         | varchar(45)      | NO   | PRI | NULL    |       |
| Comment     | text             | YES  |     | NULL    |       |
| Initials    | varchar(255)     | NO   |     | NULL    |       |
| ExpDate     | date             | NO   |     | NULL    |       |
| InsertDate  | date             | NO   |     | NULL    |       |
| inserted_by | int(11) unsigned | YES  | MUL | NULL    |       |
+-------------+------------------+------+-----+---------+-------+

e não quero criar uma nova tabela chamadasample_df referenciando isso, usando o seguinte:

CREATE TABLE sample_df (
df_id mediumint(5) unsigned AUTO_INCREMENT primary key,
sample_type mediumint(5) unsigned NOT NULL,
df_10 BOOLEAN NOT NULL,
df_100 BOOLEAN NOT NULL,
df_1000 BOOLEAN NOT NULL,
df_above_1000 BOOLEAN NOT NULL,
target INT(11) unsigned NOT NULL,
assay MEDIUMINT(5) unsigned zerofill NOT NULL,
insert_date TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
inserted_by INT(11) unsigned NOT NULL,
initials varchar(255),
experiment VARCHAR(45),
CONSTRAINT FOREIGN KEY (inserted_by) REFERENCES user (iduser),
CONSTRAINT FOREIGN KEY (target) REFERENCES protein (PID),
CONSTRAINT FOREIGN KEY (sample_type) REFERENCES sample_type (ID),
CONSTRAINT FOREIGN KEY (assay) REFERENCES assays (AID),
CONSTRAINT FOREIGN KEY (experiment) REFERENCES exp (EID)
);

Mas eu recebo o erro:

ERROR 1215 (HY000): Cannot add foreign key constraint

Para obter mais informações, eu fiz:

SHOW ENGINE INNODB STATUS\G

De onde obtive:

FOREIGN KEY (experiment) REFERENCES exp (EID)
):
Cannot find an index in the referenced table where the
referenced columns appear as the first columns, or column types
in the table and the referenced table do not match for constraint.

Para mim, os tipos de coluna parecem coincidir, pois ambos são varchar (45). (Eu também tentei configurar oexperiment coluna para não nulo, mas isso não foi corrigido) Então, acho que o problema deve ser esseCannot find an index in the referenced table where the referenced columns appear as the first columns. Mas não sei ao certo o que isso significa ou como verificar / corrigir isso. Alguém tem alguma sugestão? E o que se entende porfirst columns?

SOLUÇÃO:

Eu descobri o meu problema. Eu tinha um agrupamento diferente para a tabela exp (utf8_unicode_ci) e o padrão para o banco de dados (utf8_general_ci). Então adicionando

CHARACTER SET utf8 COLLATE utf8_unicode_ci

no final da consulta de criação da tabela, corrigi meu problema.

Mas ainda estou curioso sobre o que se entende porfirst columns. Tem algo a ver com índices?

questionAnswers(9)

yourAnswerToTheQuestion