Need help with ORM constraint

R

Rickard Axne

Hi,

Consider the following. Sorry about the length:

F1: Project(Id) was given approval on Date
F2: Project(Id) was denied approval on Date
F3: Project(Id) has approval set by User(Id)

None of these facts are mandatory. Of course, a project can't be both
approved an unapproved. These are the constraints I've identified:

C1) Exclusion: Both F1 and F2 can't be true/present at the same time.

C2) Subset: If F1 then F3

C3) Subset: If F2 then F3

C4) Subset: If F3 then (F1 OR F2)

I have successfully created constraints C1, C2 and C3, but I have
problems creating the last constraint, C4.

Any suggestions?

Rickard
 
S

Scot Becker

Hi Rickard,
F1: Project(Id) was given approval on Date
F2: Project(Id) was denied approval on Date
F3: Project(Id) has approval set by User(Id)

None of these facts are mandatory. Of course, a project can't be both
approved an unapproved. These are the constraints I've identified:

C1) Exclusion: Both F1 and F2 can't be true/present at the same time.

C2) Subset: If F1 then F3

C3) Subset: If F2 then F3

C4) Subset: If F3 then (F1 OR F2)

I have successfully created constraints C1, C2 and C3, but I have
problems creating the last constraint, C4.

You can't really implement this as a native ORM constraint (ORM does have
the "rule constraint" which is basically an annotation of the rule on the
diagram as a reminder that it needs to be implemented, but I'm not counting
that as a constraint).

Instead, consider altering the model via:

1) Can you insist that the project is always in approve or denied status
such that you can make F3 mandatory?
2) Can you introduce a third status (pending) such that the above can be
done?
3) Can a project be approved and then later denied (or vice versa)? If so,
you could model it as a ternary (Project is given Status on Date) where
status is a code meaning approved/rejected and a UC is over Project and
Status and/or Project and Date. If not, then you don't really need both
dates. Instead, you can say Project is given status on Date, make it
optional, and then put an equality constraint between this fact and the user
id one.

Hope that helps,
Scot.
................................................
Scot Becker

Orthogonal Software
www.orthogonalsoftware.com

ORM Blog: www.objectrolemodeling.com

To e-mail me, please use my first name at the domain listed above. All mail
sent to the reply-to address gets routed to a junk e-mail folder where it
will likely be deleted without being read.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top