Hola
Estoy atascado intentado crear una foreign key, he creado dos tablas:
cTb[55]:="CREATE TABLE estudio_ratio ("
cTb[55]+="id int(6) unsigned NOT NULL auto_increment,"
cTb[55]+="idestudio int NOT NULL,"
cTb[55]+="nporcentaje decimal(4,2) default NULL,"
cTb[55]+="ningreso decimal(16,2) default NULL,"
cTb[55]+="npagos decimal(16,2) default NULL,"
cTb[55]+="ntotal decimal(16,2) default NULL,"
cTb[55]+="ccliente varchar(100) default NULL,"
cTb[55]+="ncliente int(6) unsigned NOT NULL,"
cTb[55]+="cnotas text NULL,"
cTb[55]+="PRIMARY KEY (id)"
cTb[55]+=") ENGINE=MyISAM;"
cTb[56]:="CREATE TABLE gastos ("
cTb[56]+="id int(6) unsigned NOT NULL auto_increment,"
cTb[56]+="idgastos int NOT NULL,"
cTb[56]+="cgasto char(60) default NULL,"
cTb[56]+="ngasto decimal(16,2) default NULL,"
cTb[56]+=" PRIMARY KEY (id),"
cTb[56]+=" FOREIGN KEY (idgastos) REFERENCES estudio_ratio(idestudio) ON DELETE CASCADE"
cTb[56]+=") ENGINE=MyISAM;"
La idea es cuando elimine una fila de la tabla estudio_ratio, se haga el delete en cascade en la tabla gastos, pero algo estoy haciendo mal, que no me funciona, pueden ayudar ?
Un saludo y perdón por las molestias
Gabriel