# Setup create table parent ( pk int primary key, id1 int unique, id2 int unique, ref1 int, ref2 int, constraint fk_p1 foreign key ref1_idx(ref1) references parent (id1), foreign key ref2_idx(ref2) references parent (id2) ) engine ndb; # Verify the foreign keys on parent SHOW CREATE TABLE test.parent; Table Create Table parent CREATE TABLE `parent` ( `pk` int NOT NULL, `id1` int DEFAULT NULL, `id2` int DEFAULT NULL, `ref1` int DEFAULT NULL, `ref2` int DEFAULT NULL, PRIMARY KEY (`pk`), UNIQUE KEY `id1` (`id1`), UNIQUE KEY `id2` (`id2`), KEY `fk_p1` (`ref1`), KEY `ref2_idx` (`ref2`), CONSTRAINT `fk_p1` FOREIGN KEY (`ref1`) REFERENCES `parent` (`id1`), CONSTRAINT `parent_fk_1` FOREIGN KEY (`ref2`) REFERENCES `parent` (`id2`) ) ENGINE=ndbcluster DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci Foreign keys consistent across NDB and all connected mysqld's DDs create table child ( pk int primary key, ref1 int, ref2 int, constraint fk_c1 foreign key ref1_idx(ref1) references parent (id1), foreign key ref2_idx(ref2) references parent (id2) ) engine ndb; # Verify the foreign keys on child SHOW CREATE TABLE test.child; Table Create Table child CREATE TABLE `child` ( `pk` int NOT NULL, `ref1` int DEFAULT NULL, `ref2` int DEFAULT NULL, PRIMARY KEY (`pk`), KEY `fk_c1` (`ref1`), KEY `ref2_idx` (`ref2`), CONSTRAINT `child_fk_1` FOREIGN KEY (`ref2`) REFERENCES `parent` (`id2`), CONSTRAINT `fk_c1` FOREIGN KEY (`ref1`) REFERENCES `parent` (`id1`) ) ENGINE=ndbcluster DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci Foreign keys consistent across NDB and all connected mysqld's DDs # Drop foreign keys one by one and verify the other FKs integrity alter table parent drop foreign key fk_p1, algorithm = inplace; # Verify the foreign keys on parent and child SHOW CREATE TABLE test.parent; Table Create Table parent CREATE TABLE `parent` ( `pk` int NOT NULL, `id1` int DEFAULT NULL, `id2` int DEFAULT NULL, `ref1` int DEFAULT NULL, `ref2` int DEFAULT NULL, PRIMARY KEY (`pk`), UNIQUE KEY `id1` (`id1`), UNIQUE KEY `id2` (`id2`), KEY `fk_p1` (`ref1`), KEY `ref2_idx` (`ref2`), CONSTRAINT `parent_fk_1` FOREIGN KEY (`ref2`) REFERENCES `parent` (`id2`) ) ENGINE=ndbcluster DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci Foreign keys consistent across NDB and all connected mysqld's DDs SHOW CREATE TABLE test.child; Table Create Table child CREATE TABLE `child` ( `pk` int NOT NULL, `ref1` int DEFAULT NULL, `ref2` int DEFAULT NULL, PRIMARY KEY (`pk`), KEY `fk_c1` (`ref1`), KEY `ref2_idx` (`ref2`), CONSTRAINT `child_fk_1` FOREIGN KEY (`ref2`) REFERENCES `parent` (`id2`), CONSTRAINT `fk_c1` FOREIGN KEY (`ref1`) REFERENCES `parent` (`id1`) ) ENGINE=ndbcluster DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci Foreign keys consistent across NDB and all connected mysqld's DDs alter table parent drop foreign key parent_fk_1, algorithm = inplace; # Verify the foreign keys on parent and child SHOW CREATE TABLE test.parent; Table Create Table parent CREATE TABLE `parent` ( `pk` int NOT NULL, `id1` int DEFAULT NULL, `id2` int DEFAULT NULL, `ref1` int DEFAULT NULL, `ref2` int DEFAULT NULL, PRIMARY KEY (`pk`), UNIQUE KEY `id1` (`id1`), UNIQUE KEY `id2` (`id2`), KEY `fk_p1` (`ref1`), KEY `ref2_idx` (`ref2`) ) ENGINE=ndbcluster DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci No foreign keys found on table `test.parent` SHOW CREATE TABLE test.child; Table Create Table child CREATE TABLE `child` ( `pk` int NOT NULL, `ref1` int DEFAULT NULL, `ref2` int DEFAULT NULL, PRIMARY KEY (`pk`), KEY `fk_c1` (`ref1`), KEY `ref2_idx` (`ref2`), CONSTRAINT `child_fk_1` FOREIGN KEY (`ref2`) REFERENCES `parent` (`id2`), CONSTRAINT `fk_c1` FOREIGN KEY (`ref1`) REFERENCES `parent` (`id1`) ) ENGINE=ndbcluster DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci Foreign keys consistent across NDB and all connected mysqld's DDs alter table child drop foreign key fk_c1, algorithm = inplace; # Verify the foreign keys on child SHOW CREATE TABLE test.child; Table Create Table child CREATE TABLE `child` ( `pk` int NOT NULL, `ref1` int DEFAULT NULL, `ref2` int DEFAULT NULL, PRIMARY KEY (`pk`), KEY `fk_c1` (`ref1`), KEY `ref2_idx` (`ref2`), CONSTRAINT `child_fk_1` FOREIGN KEY (`ref2`) REFERENCES `parent` (`id2`) ) ENGINE=ndbcluster DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci Foreign keys consistent across NDB and all connected mysqld's DDs alter table child drop foreign key child_fk_1, algorithm = inplace; # Verify the foreign keys on child SHOW CREATE TABLE test.child; Table Create Table child CREATE TABLE `child` ( `pk` int NOT NULL, `ref1` int DEFAULT NULL, `ref2` int DEFAULT NULL, PRIMARY KEY (`pk`), KEY `fk_c1` (`ref1`), KEY `ref2_idx` (`ref2`) ) ENGINE=ndbcluster DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci No foreign keys found on table `test.child` # Cleanup drop table child, parent;