TargetPerEntity Hierarchy with Unlimted leveled Parent-Child Data

Posts   
 
    
greenstone
User
Posts: 132
Joined: 20-Jun-2007
# Posted on: 19-Nov-2008 02:05:05   

Hi,

Following models a case I have...

The hierarchy (of unlimted levels) is of a top female horse and her female ancestors.

The "business" rule is that female horses can have daughter horses or daughter mules. Daughter mules can have daughter

horses, but daughter mules can have no children.

Example: TopFemaleHorse ChildFemaleMule(can have no children) ChildFemaleHorse GrandChildFemaleMule(can have no children) GrandChildFemaleHorse GreatGrandChildFemaleMule (can have no children) GreatGrandChildFemaleHorse GreatGreatGrandChildFemaleMule(can have no children) GreatGreatGrandChildFemaleHorse ...

In the database, there are three tables for the TargetPerEntity hierarchy. FemaleEquine FemaleHorse FemaleMule

In the FemaleEquine table, there is an ID column and a ParentID column. Foreign keys: FemaleEquine.ParentID referencing FemaleEquine.ID (for unlimited hierarchy) FemaleHorse.ID referencing FemaleEquine.ID (for TargetPerEntity) FemaleMule.ID referencing FemaleEquine.ID (for TargetPerEntity)

This works fine with llblgen (SqlServer database script and .NET project attached), except that FemaleMules are not constrained (in the database) to prevent them from being listed as parents.

Suggestion on the best way to reorganize to allow the FemaleHorses to be parents, but constrain the FemaleMules from being parents (in the database)?

Thanks!

Walaa avatar
Walaa
Support Team
Posts: 14983
Joined: 21-Aug-2005
# Posted on: 19-Nov-2008 11:05:49   

The "business" rule is that female horses can have daughter horses or daughter mules. Daughter mules can have daughter horses, but daughter mules can have no children.

I'm not an expert in horses but I think the above business needs a revisit. simple_smile

From what I understand a female parent can only be a horse not a mule. And hence I think FemaleEquine.ParentID should reference FemaleHorse.ID.

greenstone
User
Posts: 132
Joined: 20-Jun-2007
# Posted on: 19-Nov-2008 13:44:20   

Hi Walaa,

Yes, genetics has put some tight constraints on those mules! flushed

Sounds like a good way to constrain. Thanks for your help!

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39749
Joined: 17-Aug-2003
# Posted on: 19-Nov-2008 14:13:37   

Walaa wrote:

The "business" rule is that female horses can have daughter horses or daughter mules. Daughter mules can have daughter horses, but daughter mules can have no children.

I'm not an expert in horses but I think the above business needs a revisit. simple_smile

if memory serves me right, a mule is a child of a horse and a donkey, but also proof that horses and donkies aren't the same species, as mules are sterile, correct?

Frans Bouma | Lead developer LLBLGen Pro