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!!!!
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
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?
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)
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.
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
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