Integridad Referencial

mloachamin
01 de Octubre del 2003
Estimados amigos, solo una pregunta, c贸mo puedo hacer para que MySql maneje integridad referencial?, puesto que ya he tranformado algunas tablas a InoDb pero a煤n as铆 recurre al mismo error, borra los datos de una tabla que tiene relaci贸n. Espero me puedan contestar al mail.

ALEX
01 de Octubre del 2003
NO SE PUEDE , MYSQL NO LO SOPORTA

Diego Quintero
01 de Octubre del 2003
Trabaja esta sintaxisCREATE TABLE product(

category INT NOT NULL,
id INT NOT NULL,
price DECIMAL,

PRIMARY KEY(category, id)) TYPE=INNODB;

###############################################

CREATE TABLE customer(

id INT NOT NULL,

PRIMARY KEY (id)) TYPE=INNODB;

################################################


CREATE TABLE product_order(

no INT NOT NULL AUTO_INCREMENT,
product_category INT NOT NULL,
product_id INT NOT NULL,
customer_id INT NOT NULL,

PRIMARY KEY(no),
INDEX (product_category, product_id),
FOREIGN KEY (product_category, product_id)
REFERENCES product(category, id)
ON UPDATE CASCADE ON DELETE RESTRICT,
INDEX (customer_id),
FOREIGN KEY (customer_id)
REFERENCES customer(id)) TYPE=INNODB;