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 as the composited primary key:

Table Band

The displayed unspecific error is:

1005 - Can't create table 'band.album' (errno: 150)

I hope that someone of you will have an idea.

Community
  • 1
  • 1
10ff
  • 813
  • 4
  • 16
  • 31
  • 1
    This might not answer your question, but you might find this useful. [link](http://stackoverflow.com/q/1749332/1101823) – Phani Rahul Aug 26 '12 at 19:37
  • Good link, thanks. But other users should know: that couldn't solve my problem. – 10ff Sep 01 '12 at 15:12

1 Answers1

1

I assume this is a character conversion issue. Try changing the umlauts in the field names to vowels.

Alex Monthy
  • 1,827
  • 1
  • 14
  • 24
  • 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 Sep 01 '12 at 15:11