Ring Constraint using two objects/Entities

A

Allan Wissing

I know how to set up a Irreflexive Ring constraint so that a object can not
parent itself.
i.e. No Academic is monitored by itself.

But how do I include a third element?
No Academic is monitored by itself.
The monitors must be in the same Department?


__Allan
 
S

Scot Becker

I know how to set up a Irreflexive Ring constraint so that a object can not
parent itself.
i.e. No Academic is monitored by itself.

But how do I include a third element?
No Academic is monitored by itself.
The monitors must be in the same Department?

Assuming an academic can belong to only one department, this constraint
cannot be expressed in ORM/UML/ER without using a note/textual rule.

Sorry,
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.
 
R

Rich R

Scot Becker said:
Assuming an academic can belong to only one department, this constraint
cannot be expressed in ORM/UML/ER without using a note/textual rule.

How about this? And I think it models the real world:

An Academic works for a Department
A Monitor works for a Department
Monitor is a subtype of Academic so it can have it's own roles
Declare a subset constraint on department between Academic/Department and
Monitor/Department
Declare a ring constraint between Academic and Monitor (So an Academic can't
monitor themselves). At first I thought this was contrived, until I
verbalized it.

The beauty of Mentor subtype is that it is the same as its supertype, but
can play different roles. A valid (if not sufficient) reason for using
subtypes.

Also, I have not generated a DB from this plan. I wanted to keep it
completely conceptual.

I can send you the diagram if it would make things clearer.

BTW, I always enjoy your articles.....

Rich
 
S

Scot Becker

Hi Rich,
How about this? And I think it models the real world:

An Academic works for a Department
A Monitor works for a Department
Monitor is a subtype of Academic so it can have it's own roles
Declare a subset constraint on department between Academic/Department and
Monitor/Department

I think you meant exclusion constraint? In any case, this would compare the
department roles such that a particular department must/must not appear in
the department role of Academic works for Department if it appears in the
Monitor works for department role. For the exclusion constraint, this would
mean no Academic could work for a given department if any Monitor
(regardless of which Academic is being monitored) works for that Department.

However, I think this would work if it were a join exclusion constraint.
Given the facts:

F1: Academic works for Department
F2: Monitor works for Department
F3: Academic is monitored by Monitor

If you create an exclusion constraint between (the role sequence of) the
academic and monitor roles of F3 and the (role sequence of) the Academic
role of F1 and the Monitor role of F2, this should express the rule. Adding
this constraint is analogous to creating a join subset constraint described
(http://objectrolemodeling.com/posts/234.aspx) and
(http://objectrolemodeling.com/posts/236.aspx).

I think this is the first non-trivial example of a join-exclusion constraint
I have come across.

(The subtype and ring constraints would be as you suggested, good idea by
the way).

So, I guess I have to take back my earlier statement; it can be done in ORM.
I have mixed feelings: I'm glad ORM can do it but hate being wrong. ; )

This constraint (nor any join set comparison constraints) will not show up
on the diagram in VEA, however. Further, it will generate no DDL code to
enforce this rule, but at least you have it captured.
BTW, I always enjoy your articles.....

Thanks for the feedback, I appreciate it!

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.
 
S

Scot Becker

By the way, in my example below F2 is derived since the department is
already recorded at the super type level.

Scot.
 

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