I'm working on a web application where i have database problem.
I have three tables : are as follows
Table 1:
CREATE TABLE mydb.emp( eID INT NOT NULL, eName VARCHAR(45) NULL, PRIMARY KEY(eID) );
Table 2:
CREATE TABLE mydb.empLocation( eLocateID INT NOT NULL, eArea VARCHAR(45) NULL, eCity VARCHAR(45) NULL, eZipcode VARCHAR(45) NULL, eID INT NULL, PRIMARY KEY(eLocateID), CONSTRAINT eID FOREIGN KEY (eID) REFERENCES mydb.emp(eID) ON DELETE CASCADE ON UPDATE CASCADE );
Table 3:
CREATE TABLE mydb.empLogin( eLoginID INT NOT NULL, eTimeIn TIMESTAMP NULL, eTimeOut TIMESTAMP NULL, eID INT NULL, PRIMARY KEY(eLoginID), CONSTRAINT eID FOREIGN KEY (eID) REFERENCES mydb.emp(eID) ON DELETE CASCADE ON UPDATE CASCADE );
While I am creating the table 3 there is a problem i can not insert the table because on delete and update cascade.
I want the cascade because when i delete a row in my emp table the data from the other tables should also be removed.
Please give me any solution for this problem or any alternate solution for this use case, Thanks in advance.