Hi Paul,

For cases like this, the database is the right, and only, place to guarantee 
this.

Chuck

From: Webobjects-dev 
<webobjects-dev-bounces+chill=gevityinc....@lists.apple.com> on behalf of Paul 
Hoadley <pa...@logicsquad.net>
Date: Monday, August 14, 2017 at 7:11 PM
To: WebObjectsDev <webobjects-dev@lists.apple.com>
Subject: Enforcing a maximum cardinality on a many-to-many relationship

Hello,

I have EOs Job and Worker. Job.workers is a many-to-many relationship to 
Worker, set up in the usual way, so there’s a JobWorker join table. 
Job.maxWorkers is a mandatory Integer attribute whose value will be 1 or 
greater.

I need to enforce a business rule such that Job.workers.count can never exceed 
Job.maxWorkers. It’s sufficient that this is enforced at save-time: if a 
particular in-memory Job has addToWorkersRelationship() called on it too many 
times, I’m not too bothered, but it can’t be saved that way. Further, it needs 
to be robust in the presence of multiple EOF stacks. (And although we use 
JGroups synchronisation in deployment, assume that we don’t. The sync may not 
happen fast enough.)

To me this sounds like a problem for database triggers: reject an insert on 
JobWorker that would cause Job.workers.count to exceed Job.maxWorkers for the 
referenced Job. Before I launch into that, though, does anyone know of (or can 
anyone think of) a robust EOF-only solution to this problem?


--
Paul Hoadley
https://logicsquad.net/
https://www.linkedin.com/company/logic-squad/



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

This email sent to arch...@mail-archive.com

Reply via email to