Re: pseudo one-to-one

2012-01-16 Thread Mike Dewhirst
On 17/01/2012 12:57pm, Bill Beal wrote: How about this (or has it been mentioned already?): All children in one table, all with FK to the parent. One FK in the parent pointing to the one special child. Does there really have to be a one-to-one anywhere? And I don't understand why anyone needs

Re: pseudo one-to-one

2012-01-16 Thread Ovnicraft
On Mon, Jan 16, 2012 at 12:55 AM, Mike Dewhirst wrote: > I need a one-to-many to behave like a one-to-one. > In -many side add a constraint, unique. Regards, > > The parent instance of my model can only ever have one current child > instance of another model. Multiple child instances have to ex

Re: pseudo one-to-one

2012-01-16 Thread Bill Beal
How about this (or has it been mentioned already?): All children in one table, all with FK to the parent. One FK in the parent pointing to the one special child. Does there really have to be a one-to-one anywhere? And I don't understand why anyone needs to chain from child to child. If they are

Re: pseudo one-to-one

2012-01-16 Thread Mike Dewhirst
On 17/01/2012 4:13am, Jeff Heard wrote: You might modify the manager to store historical entries in a different table with the same structure. I once built a work invoicing system like that where the work records got transferred from work_in_progress to work_invoiced as part of the invoicing

Re: pseudo one-to-one

2012-01-16 Thread Mike Dewhirst
On 17/01/2012 4:05am, Bill Freeman wrote: Two thoughts: 1. Have both a one to one and a one to many onto the same children. There's no reason that the current child can't be in both relationships, or you could keep them disjoint by "moving" the old current child to the collection when it id dis

Re: pseudo one-to-one

2012-01-16 Thread Jeff Heard
You might modify the manager to store historical entries in a different table with the same structure. On Jan 16, 2012, at 2:18 AM, Mike Dewhirst wrote: > On 16/01/2012 5:19pm, Bill Beal wrote: >> Why not have a child model that differs from the one-to-one child model >> in that the parent k

Re: pseudo one-to-one

2012-01-16 Thread Bill Freeman
Two thoughts: 1. Have both a one to one and a one to many onto the same children. There's no reason that the current child can't be in both relationships, or you could keep them disjoint by "moving" the old current child to the collection when it id displaced by a new child. 2. Have a many to ma

Re: pseudo one-to-one

2012-01-15 Thread Mike Dewhirst
On 16/01/2012 5:19pm, Bill Beal wrote: Why not have a child model that differs from the one-to-one child model in that the parent key is now a foreign key to the parent? When another child needs to replace the current one in the one-to-one relationship, move the child to the second table where t

Re: pseudo one-to-one

2012-01-15 Thread Bill Beal
Why not have a child model that differs from the one-to-one child model in that the parent key is now a foreign key to the parent? When another child needs to replace the current one in the one-to-one relationship, move the child to the second table where there is a many-to-one relationship to the