How To? Query Exclusive m:n Matching

If you have questions or if you want to share your opinion about Aware IM post your message on this forum
Post Reply
PointsWell
Posts: 1457
Joined: Tue Jan 24, 2017 5:51 am
Location: 'Stralya

How To? Query Exclusive m:n Matching

Post by PointsWell »

I have a tricky find question that I don't know how to resolve.

I have a number of BOs in relationship with each other

A Work must have one or more Author.
A Work must have one or more Owner.
These are controlled by A Contributor BO.

A Contract must have one or more Author.
A Contract must have one or more Owner.

A Contract must have one or more Work.

I need to be able to define a Contract and assign one or more authors and one or more owner.

Once these have been defined I need to be able to filter Works that have all of these Contributors.

For example, if Arthur has written 6 works owned by Peter but only one Work with Anna as author and owned Penelope and Peter, if I create a Contract and add Arthur and Anna as Authors and Peter and Penelope as Owners and the query to add Work to the Contract would be in pseudo code

FIND Work WHERE Work.Contributor = (Arthur and Anna WHERE Work.Participation = Author) and (Peter and Penelope WHERE Work.Participation = Owner)

Where I am struggling is to make the query dynamic enough that the number of Contract parties is not a limiting factor.

TL:DR How do I exclusively match on two sides of m:n relationships
Last edited by PointsWell on Mon Jul 11, 2022 10:09 am, edited 2 times in total.
hpl123
Posts: 2579
Joined: Fri Feb 01, 2013 1:13 pm
Location: Scandinavia

Re: How To? Query Exclusive m:n Matching

Post by hpl123 »

I don't have a direct solution to your use case but sounds complex. What I often do in complex scenarios is create a "placeholder" for items e.g SystemSettings.MyComplexQuery and then take multiple stabs at adding, removing, updating etc. etc. items in the list. In my query then I just do FIND Item WHERE Item IN SystemSettings.MyComplexQuery . Not groundbreaking stuff and you are maybe already doing this :) but if not, works for most if not all complex scenarios.
Henrik (V8 Developer Ed. - Windows)
customaware
Posts: 2391
Joined: Mon Jul 02, 2012 12:24 am
Location: Ulaanbaatar, Mongolia

Re: How To? Query Exclusive m:n Matching

Post by customaware »

PointsWell wrote: Thu Jul 07, 2022 11:40 pm I have a tricky find question that I don't know how to resolve.

I have a number of BOs in relationship with each other

A Work must have one or more Author.
A Work must have one or more Owner.
These are controlled by A Contributor BO.

A Contract must have one or more Author.
A Contract must have one or more Owner.

A Contract must have one or more Work.

I need to be able to define a Contract and assign one or more authors and one or more proprietors.

Once these have been defined I need to be able to filter Works that have all of these Contributors.

For example, if Arthur has written 6 works owned by Peter but only one Work with Anna as author and owned Penelope and Peter, if I create a Contract and add Arthur and Anna as Authors and Peter and Penelope as Owners and the query to add Work to the Contract would be in pseudo code

FIND Work WHERE Work.Contributor = (Arthur and Anna WHERE Work.Participation = Author) and (Peter and Penelope WHERE Work.Participation = Owner)

Where I am struggling is to make the query dynamic enough that the number of Contract parties is not a limiting factor.

TL:DR How do I exclusively match on two sides of m:n relationships
Do you mean Authors and Owners are controlled by a Contributor?
If a Contract MUST have one of more Work, does that mean the Work (in an Aware sense) is Owned by the Contract?
Is a Proprietor the same as Owner or is this something different?
Cheers,
Mark
_________________
AwareIM 6.0, 8.7, 8.8, 9.0 , MariaDB, Windows 10, Ubuntu Linux. Theme: Default, Browser: Arc
Upcloud, Obsidian....
Image
PointsWell
Posts: 1457
Joined: Tue Jan 24, 2017 5:51 am
Location: 'Stralya

Re: How To? Query Exclusive m:n Matching

Post by PointsWell »

[quote=eagles9999 post_id=57596 time=1657533049 user_id=762]
Do you mean Authors and Owners are controlled by a Contributor?
If a Contract MUST have one of more Work, does that mean the Work (in an Aware sense) is Owned by the Contract?
Is a Proprietor the same as Owner or is this something different?
[/quote]

[attachment=0]agency.tools.png[/attachment]

Thought I changed all the proprietors to owners in my description. Owners = Proprietors. Contributors are a role of Contacts.

A Contact owns Contributors which own Works which notionally own Contracts

A Contract has parties (Contacts) so if Janet and John and Sam and Sarah are parties to a contract then I need to find Works where Janet John Sam and Sarah are Contributors.

I'm trying to avoid prescribing that there are 2 or 4 parties because that doesn't reflect the reality there could be 1 or there could be 4 and if I say 4 then some edge case will come up where there's 6.
Attachments
agency.tools.png
agency.tools.png (59.83 KiB) Viewed 846 times
Post Reply