Modelling Data in Neo4j: Labels vs. Indexed Properties by Christophe Willemsen.
From the post:
A common question when planning and designing your Neo4j Graph Database is how to handle "flagged" entities. This could
include users that are active, blog posts that are published, news articles that have been read, etc.Introduction
In the SQL world, you would typically create a a
boolean|tinyint
column; in Neo4j, the same can be achieved in the
following two ways:
- A flagged indexed property
- A dedicated label
Having faced this design dilemma a number of times, we would like to share our experience with the two
presented possibilities and some Cypher query optimizations that will help you take a full advantage of a the graph database.Throughout the blog post, we'll use the following example scenario:
- We have
User
nodes- User
FOLLOWS
other users- Each user writes multiple blog posts stored as
BlogPost
nodes- Some of the blog posts are
drafted
, others arepublished
(active
)
This post will help you make the best use of labels in Neo4j.
Labels are semantically opaque so if your Neo4j database has “German” to label books written in German, you are SOL if you need German for nationality.
That is a weakness semantically opaque tokens. Having type properties on labels would push the semantic opaqueness to the next level.