18

I've got my graph database, populated with nodes, relationships, properties etc. I'd like to see an overview of how the whole database is connected, each relationship to each node, properties of a node etc.

I don't mean view each individual node, but rather something like an ERD from a relational database, something like this, with the node labels. Is this possible?

enter image description here

f7n
  • 1,476
  • 3
  • 22
  • 42
  • 1
    neo4j does not require nodes and relationships to conform to a schema. Therefore, in general, it is difficult to produce a clear and concise data model diagram that displays all properties, relationship types, and node "types" (with or without labels). – cybersam Feb 08 '16 at 23:56
  • Tools like neo4j browser are provided by neo4j. See if this link helps [neo4j visualization](http://neo4j.com/developer/guide-data-visualization/) – Madhusudana Reddy Sunnapu Feb 09 '16 at 04:30

5 Answers5

28

You can use the metadata by running the command call db.schema().

Valentin Grégoire
  • 1,110
  • 2
  • 12
  • 29
Paul te Braak
  • 289
  • 3
  • 3
  • 1
    Not in my Neo4j community edition v4.0, at least not from neo4j browser. The response I get is "Neo.ClientError.Procedure.ProcedureNotFound" -- "There is no procedure with the name `db.schema` registered for this database instance. Please ensure you've spelled the procedure name correctly and that the procedure is properly deployed." – Tom Stambaugh Apr 01 '20 at 14:53
  • 8
    In the new versions of Neo4j, you can use `CALL db.schema.visualization()` instead of `CALL db.schema()`. – E. Zeytinci Nov 05 '20 at 19:59
16

In Neo4j v4 call db.schema() is deprecated, you can now use call db.schema.visualization()

Maren Gulnes
  • 161
  • 1
  • 2
4

As far as I know, there is no straight-forward way to get a nicely pictured diagram of a neo4j database structure.

There is a pre-defined query in the neo4j browser which finds all node types and their relationships. However, it traverses the complete graph and may fail due to memory errors if you have to much data.

enter image description here

Also, there is neoprofiler. It's a tool which claims to so what you ask. I never tried and it didn't get too many updates lately. Still worth a try: https://github.com/moxious/neoprofiler

Martin Preusse
  • 9,151
  • 12
  • 48
  • 80
  • 1
    At least in 3.1.2 the query mentioned in this answer (which is "CALL db.schema()") works as required by the OP. And yes, I suspect traversing the complete graph is the only way, since there is no hard schema to look at. But of course the implicit schema could be indexed somehow, I don't know. – Per Wiklander Mar 17 '17 at 15:16
1

Even though this is not a graphical representation, this query will give you an idea on what type of nodes are connected to other nodes with what type of relationship.

MATCH (n)
OPTIONAL MATCH (n)-[r]->(x)
WITH DISTINCT {l1: labels(n), r: type(r), l2: labels(x)}
AS `first degree connection`
RETURN `first degree connection`;

You could use this query to then unwind the labels to write that next cypher query dynamically (via a scripting language and using the REST API) and then paste that query back into the neo4j browser to get an example set of the data.

But this should be good enough to get an overview of your graph. Expand from here.

manonthemat
  • 6,101
  • 1
  • 24
  • 49
0
  1. CALL db.schema.visualization()
    works but I couldnt find a way to get the properties of nodes or relationships.

  2. CALL apoc.meta.schema()
    gives everything - nodes, relationships, their properties(with their types, etc) in tabular/json form. You need to install plugin APOC for the database to use it, which is not that much hassle.

Insouciant
  • 19
  • 2