Query All Children with Multiple Parents


#1

I’ve been trying to query all the children entities that have multiple parents, along with the parents in order to track suspicious entities.

My ontology looks as follows:

applicant sub entity
  plays parent
  has fullName;
 
phone sub entity 
  plays child 
  has PhoneNumber_home
  has PhoneNumber_mobile
  has PhoneNumber_work;

ssn sub entity 
  plays child 
  has socialSecurityNumber;

ip sub entity 
  plays child 
  has ipAddress;

email_info sub entity  
  plays child 
  has email;

address sub entity 
  plays child 
  has mailing_address;

# Roles and Relations

lives sub relation
  relates parent
  relates child;

owns sub relation
  relates parent
  relates child;

uses sub relation
  relates parent
  relates child;

parent sub role;
child sub role;

If applicant #1 and applicant #2 both used the same ip address, that ip address would have 2 parents and I’d like to query it. In general, I’d like to query all entities that play child and have multiple parents. Any help on how I can achieve this would be greatly appreciated!

I tried the following and it didn’t work:

match 
  $x isa phone has PhoneNumber_mobile != "None"; 
  $y isa applicant; $z isa applicant; 
  ($y, $x) isa owns; 
  ($z, $x) isa owns;

#2

Is that your complete ontology? I don’t see the definition for owns or how child is used. Can you maybe show that part as well?


#3

Hi @filipe ! I’ve added the relationships to the ontology in the original post


#4

What does your query actually return? It looks like it should return something.

You could try

match
   (parent: $y, child: $x) isa owns; 
   (parent: $z, child: $x) isa owns;
   $y != $z;

#5

That works! Thank you so much @filipe

Is there a way I can make this more general to x number of parents? If I follow this approach, I’ll have to check many combinations (order of x^2) to make sure the parents are all different.