Clave foránea compuesta
Frecuentes
Visto 205 veces
0
I'm trying to create a table with a composite foreign key. I don't know what's the problem with this creation:
CREATE TABLE Album(
Name VARCHAR(30),
Bandname VARCHAR(30),
PRIMARY KEY(Name, Bandname),
Erscheinungsjahr VARCHAR(30),
MusiklabelName VARCHAR(30),
BName VARCHAR(30),
BGründungsjahr INT(11),
BGründungsort VARCHAR(30),
FOREIGN KEY (BaName, BaGründungsjahr, BaGründungsort) REFERENCES Band
(Name, Gründungsjahr, Gründungsort)
)
ENGINE=INNODB
I can tell you, that the columns "Name", "Gründungsjahr" and "Gründungsort" exist in the referenced Table Band como el composited primary key:
The displayed unspecific error is:
1005 - Can't create table 'band.album' (errno: 150)
I hope that someone of you will have an idea.
1 Respuestas
1
I assume this is a character conversion issue. Try changing the umlauts in the field names to vowels.
Respondido 26 ago 12, 21:08
Nice idea, thanks, but that didn't help, too. My solution was to replace the composite keys with single primary keys, so the whole thing got less complex. - 10ff
No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas mysql foreign-keys composite-key or haz tu propia pregunta.
This might not answer your question, but you might find this useful. aquí - Phani Rahul
Good link, thanks. But other users should know: that couldn't solve my problem. - 10ff