I have a project with a database with a lot of foreign keys built in from before. Most of these are made to connect tables but allow for NULL choices. Simple example below:
Code: Select all
USE `mydb`;
CREATE TABLE IF NOT EXISTS `mydb`.`for_test` (
`id` VARCHAR(15) NOT NULL ,
`text` VARCHAR(255) NULL DEFAULT NULL ,
PRIMARY KEY (`id`) )
ENGINE = InnoDB
CREATE TABLE IF NOT EXISTS `mydb`.`test` (
`id` VARCHAR(15) NOT NULL ,
`for_id` VARCHAR(15) NULL DEFAULT NULL ,
`text` VARCHAR(255) NULL
PRIMARY KEY (`id`) ,
INDEX `fk_test_1` (`for_id` ASC) ,
CONSTRAINT `fk_test_1`
FOREIGN KEY (`for_id` )
REFERENCES `mydb`.`for_test` (`id` )
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB
I look at two different solutions right now:
1. adding a post in each foreign keyed table with id being ''. Should work, but does not look like a reliable solution. If someone removes it the application will crash and the post cannot be put back using nuBuilder.
2. trying to make nuBuilder pass a NULL value for dropdown fields. Any idea how I should try that?
John