cancel
Showing results for 
Search instead for 
Did you mean: 
skaparate
Visitor

Hi!

I've just started learning Neo4j (using the desktop application on Linux, Arch Linux), and I have problem understanding why there are less nodes than rows when switching between the node/table views in the app.

Using the code from this gist (unmodified from the tutorial), the following query shows different node/row count:

MATCH (tom:Person {name:"Tom Hanks"})-[:ACTED_IN]->(m)<-[:ACTED_IN]-(coActors) RETURN coActors

When on the node view, there are 34 nodes, whereas on the table view there are 39 rows, could someone explain it (or tell me if this is explained later on the tutorial).

By the way, the tutorial query is this (which shows 39 rows):

MATCH (tom:Person {name:"Tom Hanks"})-[:ACTED_IN]->(m)<-[:ACTED_IN]-(coActors) RETURN coActors.name

Thanks in advance!

Comments

Sure, each table row is the ones returned in the query,
but similarly to joins in RDBMS you get duplicates.

In the node view those are deduplicated, each node and relationship is only shown once.

As noted, some of the same nodes may be involved, such as Tom having the same coactor across several movies (so the same coactor appears on multiple rows, one per each movie involved in the pattern), or having different coactors for the same movie (so the same movie shows up on multiple rows, for each coactor).

That should explain the discrepancies you're seeing. If you need counts of distinct nodes, make sure you include DISTINCT when performing your aggregations.

Version history
Last update:
‎09-02-2019 02:27 PM
Updated by:
Contributors