I am entering notes (Prototype pNote) about various products. A set attribute, Products, lists the products that a note pertains to. For example, assume A, B, C… are products. A sample note might be named “No longer supported by supplier” with Products = “A”. (Most notes pertain to one product, but a few reference several products, hence my use of a set attribute.)
I also have an agent (prototype is pProduct) for each product that gathers notes pertaining to that product. Agent names are the product name (e.g. A) and each such agent also has its attribute, Products, set to its name.
Example: two notes -
“No longer supported by supplier” (Products set to “A”)
“Competitor lowers price” (Products set to “A;B”)
The agent, named A, also has its Products attribute set to “A” and has the query:
($Products.contains($Products(agent)) & $Prototype == “pNote”)
[Note: the above is a distillation and abstraction of my database which has nothing to do with products.]
What I’d like to add is a housekeeping agent that finds any notes whose products do not have a corresponding agent. Example: note “union strikes, no production for now”, Products = “C”.
I want to be sure that there exists an agent, C, that gathers all notes pertaining to C.
I have a query that begins with: $Prototype==“pNote”
But then I’m stuck - I want to be sure the note appears as an alias in one of the products agents. In other words I want there to exist an agent C.
In words, I’d like to code: $Prototype==“pNote” & {there exists an agent whose Product is same as note’s Products}
(here’s my problem, I’m searching for something that is related to something else that needs to be searched for.)
Any suggestions for the query?
Thanks.