一些基本概念,从官网copy过来的,如下:
Graph Fundamentals
Basic concepts to get you going.
A graph database can store any kind of data using a few simple concepts:
- Nodes - graph data records
- Relationships - connect nodes
- Properties - named data values
A Graph Database
Neo4j stores data in a Graph, with records called Nodes.
The simplest graph has just a single node with some named values called Properties. Let’s draw a social graph of our friends on the Neo4j team:
- Start by drawing a circle for the node
- Add the name Emil
- Note that he is from Sweden
- Nodes are the name for data records in a graph
- Data is stored as Properties
- Properties are simple name/value pairs
Labels
Associate a set of nodes.
Nodes can be grouped together by applying a Label to each member. In our social graph, we’ll label each node that represents a Person.
- Apply the label “Person” to the node we created for Emil
- Color “Person” nodes red
- A node can have zero or more labels
- Labels do not have any properties
More Nodes
Schema-free, nodes can have a mix of common and unique properties.
Like any database, storing data in Neo4j can be as simple as adding more records. We’ll add a few more nodes:
- Emil has a klout score of 99
- Johan, from Sweden, who is learning to surf
- Ian, from England, who is an author
- Rik, from Belgium, has a cat named Orval
- Allison, from California, who surfs
- Similar nodes can have different properties
- Properties can be strings, numbers, or booleans
- Neo4j can store billions of nodes
Consider Relationships
Connect nodes in the graph
The real power of Neo4j is in connected data. To associate any two nodes, add a Relationship which describes how the records are related.
In our social graph, we simply say who KNOWS whom:
- Emil KNOWS Johan and Ian
- Johan KNOWS Ian and Rik
- Rik and Ian KNOWS Allison
- Relationships always have direction
- Relationships always have a type
- Relationships form patterns of data
Relationship properties
Store information shared by two nodes.
In a property graph, relationships are data records that can also contain properties. Looking more closely at Emil’s relationships, note that:
- Emil has known Johan since 2001
- Emil rates Ian 5 (out of 5)
- Everyone else can have similar relationship properties
可以使用这种方式访问neo4j数据库:1
http://localhost:7474/browser/
清空neo4j数据库
1 | match(n) |
执行上面的命令后,会删除节点及与该节点相关的关系,但是property keys删不干净
未完,待续……