I created 2 tables inside mysql database. i used following codes for that.
CREATE TABLE Country
(
CountryID VARCHAR(8) PRIMARY KEY,
CountryName VARCHAR(15) UNIQUE NOT NULL
)ENGINE=INNODB;
CREATE TABLE Agent
(
AgentNo VARCHAR(10) PRIMARY KEY,
AgentName VARCHAR(50) UNIQUE NOT NULL,
AddNo VARCHAR(8) NOT NULL,
Street VARCHAR(25) NOT NULL,
City VARCHAR(20) NOT NULL,
ContactPerson VARCHAR(20),
Email VARCHAR(40),
CountryID VARCHAR(8) NOT NULL REFERENCES Country(CountryID)
)ENGINE=INNODB;
But when i try to drop Country table it allow to drop that table. but Agent table still in the database.
I think foreign key reference does not properly implemented between these table. How can i solve this problem.
I am not familiar with mysql. I have familiar with MS SQL Server and i did not face problem like that before.
you need to add foreign key fk_country_id(CountryID) before reference to implement foreign key: