Data Model:
Anthony
alanthonyc at gmail.com
Sun Apr 12 23:33:04 EDT 2009
On Apr 12, 8:10 pm, Aaron Brady <castiro... at gmail.com> wrote:
> On Apr 12, 9:14 pm, Anthony <alantho... at gmail.com> wrote:
>
>
>
> > I'm struggling on whether or not to implement GroupItem (below) with
> > two separate models, or with one model that has a distinguishing key:
>
> > Given:
> > class ParentGroup:
> > a group of values represented by class GroupItem
>
> > class ChildGroup:
> > a group of values represented by class GroupItem
> > foreign-key to ParentGroup (many Children sum to one Parent)
>
> > Option A:
> > class GroupItem:
> > foreign-key to ParentGroup
> > foreign-key to ChildGroup
> > GroupItemType in (ParentItem, ChildItem)
> > value
> > value-type
>
> > Option B:
> > class ParentGroupItem
> > foreign-key to ParentGroup
> > value
> > value-type
>
> > class ChildGroupItem
> > foreign-key to ChildGroup
> > value
> > value-type
>
> > What are my considerations when making this decision?
>
> > Thanks!
>
> You want a ChildItem to have membership in two collections:
> ParentGroup and ChildGroup. You also want a ParentItem to have
> membership in one collection. For example:
>
> parentA: itemPA1, itemPA2, childA, childB
> childA: itemCA1, itemCA2
> childB: itemCB1, itemCB2
>
> Or, listing by child,
>
> itemPA1: parentA
> itemPA2: parentA
> itemCA1: childA
> itemCA2: childA
> itemCB1: childB
> itemCB2: childB
> childA: parentA
> childB: parentA
>
> Correct so far?
Thanks for the insightful response.
Yes, everything you say is correct, with one clarification: The
ChildItem can be a member of ParentGroup OR ChildGroup, but never both
at the same time.
More information about the Python-list
mailing list