Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between a Label and a Property in Neo4j?

I'm fairly new to Neo4j, but very experienced in RDBMS design and development. Trying to understand the difference between a Label and a Property in Neo4j. Nothing I've read seems to differentiate between the two, in fact, I find that the terms are often used interchangeably. I assume there must be a difference, otherwise the Wise Men and Women of Neo4j would not have created both...

Thanks for your help!

like image 354
David Avatar asked Jun 24 '15 13:06

David


People also ask

What is a label in Neo4j?

Label is a name or identifier to a Node or a Relationship in Neo4j Database. We can say this Label name to a Relationship as "Relationship Type". We can use CQL CREATE command to create a single label to a Node or a Relationship and multiple labels to a Node.

What is a property in Neo4j?

Properties are key-value pairs that are used for storing data on nodes and relationships. The value part of a property: Can hold different data types, such as number , string , or boolean .

Why labels are used in Neo4j?

Neo4j recently introduced the concept of labels and their sidekick, schema indexes. Labels are a way of attaching one or more simple types to nodes (and relationships), while schema indexes allow to automatically index labelled nodes by one or more of their properties.

What is label in graph database?

A label is a named graph construct that is used to group nodes into sets; all nodes labeled with the same label belongs to the same set. Many database queries can work with these sets instead of the whole graph, making queries easier to write and more efficient to execute.


1 Answers

A Property is a key-value pair that is part of a Relationship or a Node.

A Label is a name/tag/category you assign to one or several Nodes. Note that the nodes with similar labels do not necessarily share the same set of property keys.

Constraints and indices are defined against Labels. (Though legacy index APIs - they are pre-v2, i.e. pre-Labels - work only with Properties).

From a filesystem perspective, regular label lookups are normally faster than regular property lookups because labels are stored and normalized within their own file (i.e. "label store") vs. spread and repeated across all corresponding nodes for properties.

like image 188
fbiville Avatar answered Oct 19 '22 07:10

fbiville