MySQL: FOREIGN KEYS

cursillo

New Member
Messages
10
Reaction score
0
Points
0
Manu, From Teruel (Spain):cool:

Hi everyone!

I'm trying to build a BD with 3 relational tables, something like: C = A + B.

The A and B tables are InnoDB and they're OK, my problem comes with the last one (C)

I can't use FOREIGN KEY. Is it because I'm using MySQL Admin? Is there a limitation on the server? Am I writing something wrong? :dunno:

Thanks for your help. (Excuse me for my poor English)

That's my code:

CREATE TABLE score (
id INT NOT NULL AUTO_INCREMENT,
id_composer INT NOT NULL,
id_work INT NOT NULL,
PRIMARY KEY (id),
FOREIGN KEY (id_composer) REFERENCES composer (id),
FOREIGN KEY (id_work) REFERENCES work (id)
);
ENGINE = InnoDB;
 

ah-blabla

New Member
Messages
375
Reaction score
7
Points
0
I don't have much SQL experience, but I'll try help:
Try removing the ; after the last bracket, i.e. the last three lines should be:
Code:
FOREIGN KEY (id_work) REFERENCES work (id)
)
ENGINE = InnoDB;
All the examples on this page don't have that semicolon, so that *could* be causing the problem. Also try posting the error message you get. (Posting all the sql code you run beforehand would also be useful to help debug the problem.)
 

cursillo

New Member
Messages
10
Reaction score
0
Points
0
Problem solved :biggrin:

first: CREATE TABLE (MyISAM)
second: ALTER TABLE TYPE:InnoDB


Thanks for your help!
 
Last edited:
Top