Sorry, not a hard-coded example here, I have been having difficulty
framing this question. I suppose what I'm asking about here is how to
ensure data integrity when adding new rows to one table where it
contains columns that are foreign keys to a second table when the
referenced rows do not exist in the second table yet. And these FKs
are displayed in a select box in the add/edit views of the first
table, so I may be trying to reference a FK that does not yet exist in
the select box.

I guess my question is, how can I add new items to a select box (or
include a toggle to an alternate text box) without forcing the user to
switch to the add view of the second table to enter a (likely
incomplete) new row before proceeding with data entry on the first
table.

Again, sorry about the muddled explanation here.
Thanx, DaveT.

Some background:
I have a collection of clones that can be mated to produce a
population of seed, and from each population of seeds new trees are
selected to clone (and assigned a NEW clon.name) which may then be
bred to produce new populations of seed (and assigned a NEW pop.name).
The clons and pops models have many-to-many relationships through two
models, mated and generated as defined below (only keys shown to
simplify).

CREATE TABLE `clons` (
        `id` INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
        `orig_id` INT NULL DEFAULT NULL,
        `donor_id` INT NULL DEFAULT NULL,
        CONSTRAINT `fk_clon_orig` FOREIGN KEY (`orig_id`) REFERENCES `origs`
(`id`),
        CONSTRAINT `fk_clon_donor` FOREIGN KEY (`donor_id`) REFERENCES
`donors` (`id`)
) ENGINE = InnoDB;

CREATE TABLE `pops` (
        `id` INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
        `orig_id` INT NULL DEFAULT NULL,
        `donor_id` INT NULL DEFAULT NULL,
        CONSTRAINT `fk_pop_orig` FOREIGN KEY (`orig_id`) REFERENCES `origs`
(`id`),
        CONSTRAINT `fk_pop_donor` FOREIGN KEY (`donor_id`) REFERENCES
`donors` (`id`)
) ENGINE = InnoDB;

CREATE TABLE `generated` (
        `id` INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
        `clon_id` INT NULL DEFAULT NULL,
        `pop_id` INT NULL DEFAULT NULL,
        CONSTRAINT `fk_generated_clon` FOREIGN KEY (`clon_id`) REFERENCES
`clons` (`id`),
        CONSTRAINT `fk_generated_pop` FOREIGN KEY (`pop_id`) REFERENCES
`pops` (`id`)
) ENGINE = InnoDB;

CREATE TABLE `mated` (
        `id` INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
        `motherID` INT NULL DEFAULT NULL,
        `fatherID` INT NULL DEFAULT NULL,
        `pop_id` INT NULL DEFAULT NULL,
        CONSTRAINT `fk_mated_mother` FOREIGN KEY (`motherID`) REFERENCES
`clons` (`id`),
        CONSTRAINT `fk_mated_father` FOREIGN KEY (`fatherID`) REFERENCES
`clons` (`id`),
        CONSTRAINT `fk_mated_pop` FOREIGN KEY (`pop_id`) REFERENCES `pops`
(`id`)
) ENGINE = InnoDB;
Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to