I ran into this error
when I tried to run
...
DROP TABLE IF EXISTS mcp_manufactures;
DROP TABLE IF EXISTS mcp_models;
DROP TABLE IF EXISTS mcp_names;
DROP TABLE IF EXISTS mcp_types;
DROP TABLE IF EXISTS mcps;
...
But when I look at all the mcp tables
create table mcps (
mcp_id SMALLINT NOT NULL AUTO_INCREMENT,
name VARCHAR(50) NOT NULL,
type VARCHAR(25),
manufacturer VARCHAR(50),
model VARCHAR(25),
capacity VARCHAR(25),
frequency INT,
voltage INT,
notes TEXT NULL,
created_by VARCHAR(50) DEFAULT 'lurtnowski@industechnology.com',
created_date TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_by VARCHAR(50) NULL,
updated_date TIMESTAMP NULL,
enabled BOOLEAN DEFAULT 1,
PRIMARY KEY ( mcp_id )
);
create table mcp_names (
mcp_name_id SMALLINT NOT NULL AUTO_INCREMENT,
mcp_id SMALLINT,
name VARCHAR(25),
FOREIGN KEY ( mcp_id ) REFERENCES mcps ( mcp_id ),
PRIMARY KEY ( mcp_name_id )
);
create table mcp_types (
mcp_type_id SMALLINT NOT NULL AUTO_INCREMENT,
mcp_id SMALLINT,
name VARCHAR(25),
FOREIGN KEY ( mcp_id ) REFERENCES mcps ( mcp_id ),
PRIMARY KEY ( mcp_type_id )
);
create table mcp_manufacturers (
mcp_manufacturer_id SMALLINT NOT NULL AUTO_INCREMENT,
mcp_id SMALLINT,
name VARCHAR(25),
FOREIGN KEY ( mcp_id ) REFERENCES mcps ( mcp_id ),
PRIMARY KEY ( mcp_manufacturer_id )
);
create table mcp_models (
mcp_model_id SMALLINT NOT NULL AUTO_INCREMENT,
mcp_id SMALLINT,
name VARCHAR(25),
FOREIGN KEY ( mcp_id ) REFERENCES mcps ( mcp_id ),
PRIMARY KEY ( mcp_model_id )
);
I’m confused cause aren’t I supposed to drop tables with FK first, then the table with no FK.
So why the error?