On 5/29/07, James Masters <[EMAIL PROTECTED]> wrote: > Rose clearly cleverly deals with cascading deletes etc. regardless of > whether foreign keys are used or not. But where foreign keys are in use, if > I delete a parent table, does Rose know not to attempt the cascading delete > itself and just let the database handle it?
RDBO doesn't do cascading deletes unless explicitly asked to via the "cascade" option: http://search.cpan.org/dist/Rose-DB-Object/lib/Rose/DB/Object.pm#delete > I see that quite a lot of the Extra.pm files I've written won't be necessary > if foreign keys are in use because the relationships are established from > them. But presumably I will still need the Extra.pm files to specify that > the foreign key relationship found is "many to one" instead of "one to one". > What would the syntax for this be within the Extra.pm file? i.e. the > relationship has been defined automatically - how do I add the type of it? If you want to change the type of a relationship, you have to delete and then re-create it (and then re-initialize(replace_existing => 1)). > Also, from the documentation, it appears that the foreign keys can only > specify "X to one" relationships. I suppose this is because foreign keys > are specified from child to parent. Most of what I've been doing has been > with "one to many" relationships from parent to child. So, is it the case > that even once I've set up all the foreign keys in my converted InnoDB > tables (assuming I can actually manage that), I will still need to be > specifying lots of Extra.pm files with all the reverse "one to many" > relationships in the parent tables? When auto_initialize()ing, RDBO will create most "reverse" one-to-many relationships. Read the docs for the "with_relationships" option here: http://search.cpan.org/dist/Rose-DB-Object/lib/Rose/DB/Object/Metadata.pm#auto_init_relationships -John ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ Rose-db-object mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/rose-db-object
