Arrows Tool design and importing the data is done, but I can't query the data correctly. Please help!

Hello Everyone,

I am new to NEO4j and trying to practice Cypher based on my Arrows tool design (Screenshot attached). I've successfully imported my CSV files to NEO4j. However, I am having a hard time returning my target output using Cypher. How should I query the questions below? It seems to be basic but when connecting relationships on my query I get stuck and it returns no data.. Any help would be really appreciated. Thanks in advance!!!!

  1. How can I query to see how many Registration node is connected to per Event node? Registration per Event.
  2. How could I query to see the most connected RegistrationDemograph node to Event node?
  3. How many RegistrationDemograph node is connected to Registration node in total.
  4. How to find the average Registration count to RegistrationDemograph?

I have tried for few hours but the output is nowhere close to my target output.. Thank you so much for your time and support.

Respectfully,

Petra Lee

Hi Petra,

I will try to give you the correct cypher queries. However, without knowing your data and your failed queries, they might still not work. Just re-ask if there is something wrong.

MATCH (r:Registration)-[:belongs_to]->(e:Event) 
WITH count(r) AS countRegistrations, e
RETURN e.evtName, countRegistrations
  1. From your arrows sketch, there is no connection between a RegistrationDemograph node and an Event node. Should there be? Or can you elaborate on what exactly you want here?

  2. Same as 1.

MATCH (r:Registration)-[:knows]->(rd:RegistrationDemograph) 
WITH count(r) AS countRegistrations
SET rd.countRegistrations = countRegistrations
MATCH (rd:RegistrationDemograph)
WITH count(rd) AS numberRDs, sum(rd.countRegistrations) AS sumRegistrations
RETURN sumRegistrations/toFloat(numberRDs)

I hope I could help you.
Regards,
Elena

Elena,

Thank you so much for your help!! you're amazing. This helped me to understand relationship between the nodes and my design better. Thanks again.

For the question #2, the screenshot was cut off a bit. My apologies!!

RegistrationDemograph and Event node both have property "evtUid" (integer).
RegistrationDemograph > Registration > Event all have "evtUid".

with Cypher, how to find which evtUid is connected the most from RegistrationDemograph node to Event node? I wanted to see the sorted list in descending order and it's giving me hard time. For some my output is empty all the time.. Thanks in advance and thank you for your time.

Respectfully,

Petra Lee

Try this:

MATCH (rd:RegistrationDemograph)-[:belongs_to]->(r:Registration)-[:belongs_to]->(e:Event) 
WHERE re.evtUid = r.evtUid = e.evtUid
RETURN distinct rd.demName as RegistrationDemograph, count(distnct e.evtUid) as TotEvents ORDER BY TotEvents DESC

ameyasoft,

Thank you so much for your help this query helped me to understand!! Special thanks to Elena as well. Thank you guys for the support and encouraging others. I hope to connect again in near future and have a great day everyone! Go NEO4j :slight_smile: