Complex query

If you have questions or if you want to share your opinion about Aware IM post your message on this forum
Post Reply
pixerp
Posts: 180
Joined: Sun Jan 28, 2007 7:12 pm

Complex query

Post by pixerp »

Trying to figure out if this query is possible :

BO Employee references BO Organization (owned by, no multiple) and BO Person (owned by, no multiple)

The query should find all person NOT employed in a given Organization.

What troubles me is that Person (in Mysql table) doesn't have any reference (column) to Employee although in BO Person the Employee reference attribute is defined !

Is there something wrong. (V3-build 1036)
tford
Posts: 4238
Joined: Sat Mar 10, 2007 6:44 pm

Post by tford »

pixerp,

Can you clarify which BOs are the owners of other BOs.

Thanks,
Tom
pixerp
Posts: 180
Joined: Sun Jan 28, 2007 7:12 pm

Post by pixerp »

Hi Tom,

BO Organization owns Employee, multiple allowed
BO Person owns Employee, multiple allowed
BO Employee is owned by Organization, no multiple
and is owned by Person, no multiple.

The query should find all the persons that are not employees of a given organization.

I tried:
FIND Person WHERE (NOT( EXISTS Employee WHERE (Person IN Employee.Person AND Employee.Organization=ThisOrganization)))
but obviously this is not correct (no record found).

Thanks for your help,
Ernest
tford
Posts: 4238
Joined: Sat Mar 10, 2007 6:44 pm

Post by tford »

Ernest,

Now I'm really confused:
BO Organization owns Employee, multiple allowed
BO Person owns Employee, multiple allowed
BO Employee is owned by Organization, no multiple
and is owned by Person, no multiple.
You have that Employee is owned by both Organization and Person BOs.

How can that be? Once a BO like Employee is indicated to be owned by another BO, AwareIM will only allow you to make it a Peer to another BO.

Tom
pixerp
Posts: 180
Joined: Sun Jan 28, 2007 7:12 pm

Post by pixerp »

Well, it doesn't seem to be controlled in the Config tool. And I have several other BO's that have multiple BO owners.

I don't know if it is only a semantic problem or if it does really pose a problem as far as DB integrity or AwareIM functions are concerned.

Considering an employee is owned by an organization, would mean if that gets "deleted" the employee instance will be deleted as well.

Whereas, the person owning the employee would not get deleted. The more so as, that person can be employed by another organization.

Does it make sense ?
pixerp
Posts: 180
Joined: Sun Jan 28, 2007 7:12 pm

Post by pixerp »

Just after posting, I should have said:

Whereas, if a person employed with an organization gets "deleted" (sorry for her) the employee instance(s) of that person should bbe deleted but not the organization ...

Hope it is clearer.
tford
Posts: 4238
Joined: Sat Mar 10, 2007 6:44 pm

Post by tford »

Ernest,

I wonder if this limitation from Appendix B applies to your situation (#16 in the 3.0 User Guide and #14 in the 4.0 User Guide)
16. Negated IN expression is not supported in queries. For example, the following expression is not supported:
FIND Event WHERE NOT(LoggedInMember IN Event.Participants)

In many cases the negated IN expression can be replaced by using the equivalent COUNT or EXISTS expression, for example:
FIND Event WHERE COUNT Member WHERE(Member IN Event.Participants AND Member=LoggedInMember) = 0
Tom
tford
Posts: 4238
Joined: Sat Mar 10, 2007 6:44 pm

Post by tford »

Ernest,

I'm still confused about:
BO Organization owns Employee, multiple allowed
BO Person owns Employee, multiple allowed
BO Employee is owned by Organization, no multiple
and is owned by Person, no multiple.
If a Person creates and owns an instance of Employee, do you have an attribute in that Employee instance that would tell you the Organization of the Employee?

Tom
pixerp
Posts: 180
Joined: Sun Jan 28, 2007 7:12 pm

Post by pixerp »

Hi Tom,

As quoted, BO Employee is owned by Organization, no multiple, so there is an attribute.

The process to create an Employee from a Person would require that you select an Organization. But at the moment, I have a process to create an Employee as Operation invoked from Organization form.

Precisely in that process, a rule asks 'Do you want tro create a new Person ?'
- NO should present the results of a query with all persons NOT employed within ThisOrganization...

Ernest
greg
Posts: 124
Joined: Sat Apr 23, 2005 12:46 am

Post by greg »

Ernest,

Have you tried this:

Code: Select all

FIND Person WHERE EXISTS Employee WHERE (Employee IN Person.Employee AND NOT(Employee.OrganizationName CONTAINS ?'Organization'))
In this example Employee.OrganizationName is a shortcut to Organization.Name

greg
Post Reply