Best way to handle this scenario

Posts   
 
    
alexdresko
User
Posts: 336
Joined: 08-Jun-2004
# Posted on: 05-Jun-2005 00:17:07   

I have the following tables:

Task {TaskID} People {TaskID, PersonID, IsBuyer} Person {PersonID}

The people itermediary table is used because the same person can be assigned to the same task multiple times.

Is there a way I can set up my Task entity to have two collection properties, Buyers and Sellers, instead of having to go through the People entity?

I'm not a real DBA, I just play one on TV.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39750
Joined: 17-Aug-2003
# Posted on: 05-Jun-2005 10:08:52   

alexdresko wrote:

I have the following tables:

Task {TaskID} People {TaskID, PersonID, IsBuyer} Person {PersonID}

The people itermediary table is used because the same person can be assigned to the same task multiple times.

Is there a way I can set up my Task entity to have two collection properties, Buyers and Sellers, instead of having to go through the People entity?

Not directly. You can't have conditional FK's. Your collections are typically filled with a query with another filter, for IsBuyer. You can of course add the collections by hand, but you have to create the filters for filling them by hand too. (i.e. append the extra filter)

Frans Bouma | Lead developer LLBLGen Pro
alexdresko
User
Posts: 336
Joined: 08-Jun-2004
# Posted on: 05-Jun-2005 23:12:01   

That'll do, thanks! At least I can stop banging my head on the wall trying to think of a better way to do it. simple_smile