Multi tables having a to-many relationship to the same table

"Rohrbaugh, John H" <[email protected]> Thu, 27 Apr 2006 10:37:55 -0400
Newsgroups gmane.comp.web.webobjects.eof
Message-ID <[email protected]>
We have a change history logging table named 'ChangeHistory' and would
like several tables to have a to-many relationship to it.  

 

Student table has a to-many relationship to ChangeHistory named
'toStudentChangeHistory'

 

School table has a to-many relationship to ChangeHistory named
'toSchoolChangeHistory'

 

ChangeHistory includes an attribute named 'foreignKeyId' that will
contain the primary key of the table that points to it; ie studentId or
schoolId.  Thought I would also have a ChangeHistory attribute named
'changeHistoryType' that would distinguish the tables (value either
'STUDENT' or 'SCHOOL')

 

toStudentChangeHistory  join would be:

   Where Student.studentId = ChangeHistory.foreignKeyId   and
ChangeHistory.changeHistoryType = 'STUDENT'

 

toSchoolChangeHistory  join would be:

   Where School.schoolId = ChangeHistory.foreignKeyId   and
ChangeHistory.changeHistoryType = 'SCHOOL'

 

I can not figure out how to specify the changeHistoryType part of the
join in the EOModeler.

 

Thought of a few work-a-rounds, but would rather not add additional
attributes.  For instance, could add the changeHistoryType to both the
Student and School tables.  Just seems like there should be a better way
of doing this.

 

Thanks for your help.

 

JohnR