This content has been marked as final. Show 4 replies
1 person found this helpful
941611 wrote:Scope is very useful for self referencing relationships. Its necessary when you need to use a self referencing relationship in a rule.
I have been looking through the functions examples for scope for relationships for an entity. Can scope functions be used on self-referencing relationship.
For example I have one entity the applicant and in addition the containment relationship the applicants I create a self-referencing relationship the applicants tax filer. Can I use a scope function on the relationship applicants tax filer?
Imagine a school based rulebase with an entity "the child" with a reference to "the child's classmates" (source and target = "the child")
The natural language form works as as long as you use an Alias (scoping the target child as "the other child")
The functional form uses the ForAllScope instead of ForAll
The child is top of the class if for all of the child's classmates (the other child) the child's test score > the other child's test score
The child is top of the class if ForAllScope(the child's classmates, the other child) the child's test score > the other child's test score
I believe my problem is the relationship is inferred and found documentation that attribute used cannot be a base attribute.
My entity "the applicant" has two attributes applicant-name and tax-filer-name.
Entity instance one has
applicant-name = Jane
tax-filer-name = John
Entity instance two has
applicant-name = John
tax-filer-name = John
Looking to determine that entity instance two is target for entity instance one in the the applicants tax filer relationship(self-referencing relationship "the applicant" to "the applicant").
I determine this by comparing the tax-filer-name of entity instance one to the applicant-name of all "the applicant" entities.
You can definitely use any attribute when inferring relationships, including base level attributes.
In your case, if you wanted to infer a relationship "the applicant's tax filer"
As you have described, you need to compare "tax-filer-name" with "applicant-name". I will set the text to these attributes as:
tax-filer-name: "the applicant's tax filer name"
applicant-name: "the applicant's name"
In order to use an alias. The name of the entity must be in the text of each attribute. The its just a matter of using an alias (the filer) in the membership statement.
In the statement below the alias for the target applicant "the filer" substitutes in the attribute "the applicant's name" to become "the filer's name" to disambiguate the source applicant entity from the target applicant entity in the relationship.
the applicant (the filer) is a member of the applicant's tax filers if the applicant's tax-filer-name = the filer's name
Edited by: frank.hampshire on Jan 29, 2013 9:20 AM
Thanks I knew about the alias to reference entity of the same type but didn't realize the attribute name need the entity text.
I was trying to go a step farther using a scoping function to compare an applicant being a tax filer for other applicants.