Below is my data model
entities: the person, the job
Relationships: the person-> the job (the person's job) 1 to M (reverse: the person's job's person)
the person ->the job (the person's favorite job) M to M (inferred)
Now, the job entity has below attributes: (only important ones are listed)
1. the job's id
2. the job's end date
3 the job's person id
the person entity has below attributes:(only important ones are listed)
1. the person's id
2. the person's most recent job id
Using the "member of" operator I am assigning the entity instances to "the person's favourite job". Upto this things are working fine.
Now the problem is I want to determine -"the person's most recent job id" by comparing the entity instance's attribute "the job's end date" and then getting the job Id of the same entity instance.
Can someone help me in this..?
I got my answer myself!
the person's most recent favourite job date = InstanceMaximum(the person's favourite job, the job's end date)
the person's most recent favourite job = InstanceValueIf(the person's favourite job, the job name, the job's end date = the person's most recent favourite job date)
Let me know if any other way exists to achieve the same result.
Just be aware that if you had two jobs ending at the same time, then InstanceValueIf would return uncertain (perhaps they had two jobs at the same company...?) so just make sure you handle that.
consider renaming the relationship to the plural... "the person's favourite jobs".
I am assuming that your system only handles jobs that have ended, as things would be much more complicated if they could have multiple jobs (which could overlap) or jobs with start dates that haven't ended yet.