Relation btween tables
General and Desktop
3
Posts
2
Posters
894
Views
1
Watching
-
hello this my code
@if((query.exec("CREATE TABLE artist ( id INTEGER PRIMARY KEY,name VARCHAR(40) NOT NULL,country VARCHAR(40))"))&&(query.exec("CREATE TABLE cd ( id INTEGER PRIMARY KEY,title VARCHAR(40) NOT NULL,artistid INTEGER NOT NULL,year INTEGER NOT NULL,FOREIGN KEY (artistid) REFERENCES artist)")))@
am trying to create to tables and relation btween but i have this errorCan't create table 'test.cd' (errno: 150) QMYSQL: Unable to execute query
please help me -
My SQL is a little rusty but shouldn't it be something like this?
@...FOREIGN KEY (artistid) REFERENCES artist(id)@
with the (id) at the end.