saludos tengo un problema con mysql que no entiendo por que no me deja agregar registros en una tabla maestro/detalle, lo cual lo comprobe con mysql-front agregandole los regsitros: error de ejecucion sql 1062 respuesta de la bd duplicate entry '1' for key 1
Por tanto, ya no le aplico una primary key a mi tabla detalle, de lo cual modifique el script y quedando asi:
Código PHP:
CREATE TABLE `requision` (
`REQ_ID` int(11) NOT NULL default '0',
`REQ_FECHA` date default NULL,
PRIMARY KEY (`REQ_ID`),
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_spanish_ci;
CREATE TABLE `requision_det` (
`REQ_DET_ID` int(11) NOT NULL default '0', ---->(ya no hay Primary key)
`REQ_DET_ARTICULO int(11),
KEY `REQ_DET_ID_IX` (`REQ_DET_ID`), -->un indice
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_spanish_ci;
ALTER TABLE `requision_det` --->y le aplique una foranea
ADD FOREIGN KEY (`REQ_DET_ID`) REFERENCES `requision` (`REQ_ID`) ON DELETE CASCADE ON UPDATE CASCADE,
estoy en esa incertidumbre q- tengo, por que no me habia sucedido esto..
hice una pruebas y ya me permite agregar registros a mi detalle pero es bueno, recomendado... que hago
gracias.