I just noticed, you mentioned other books have the same rule on the same event. 
In which case, you’d make

Event
->>eventBooks
->>primaryEventBooks

EventBook
->event
o>person
->book
o>primaryForEvent
distinct index (primaryForEventId, bookId)
check constraint (eventId = primaryForEventId or primaryForEventId = null)

This enforces one primary per book per event in your to-many relationship. You 
would do the same validity checks in your validateForSave.

On Feb 12, 2015, at 10:15 AM, Ramsey Gurley <[email protected]> wrote:

> 
> On Feb 11, 2015, at 10:46 PM, Theodore Petrosky <[email protected]> wrote:
> 
>> But there are rules about these books. There are 15 persons assigned to the 
>> Reed1 book for Show01.  Only one of them is the PrimaryPlayer. Likewise 
>> there are 20 other books assigned to this Show.
> 
> How do you know who is the primary if you have 15 people assigned to the 
> book? Enforce that in the model.
> 
> Event
> ->>eventBooks
> ->primaryEventBook
> 
> Now an event can only have one primary. Note, this creates a circular 
> relationship. Your database has to be able to do deferred constraints. Pick a 
> good one. 
> 
> Notice that now you have created this relationship, your problem is solved. 
> You can have a wizard interface
> 
> ([tab1], show, date, [tab2], eventBooks, [tab3], primaryEventBook)
> 
> You select a show and date. When you go to the next page, you can auto 
> populate your event books relationship with persons based on PersonShow. When 
> you go to the next page, you can have the user select one of your existing 
> EventBooks filtered by isPrimaryPlayer from PersonBook. If there’s only one, 
> then it is automatically assigned. If there are none, then you auto populate 
> a new event book with a null person.
> 
> Problem solved with no magic going on behind the user’s back :)


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to