当前位置:编程学习 > 网站相关 >>

图形数据库之---neo4j(非关系型数据库)

Neo4j是一个高性能的,NOSQL图形数据库,它将结构化数据存储在网络上而不是表中。Neo4j也可以被看作是一个高性能的图引擎,该引擎具有成熟数据库的所有特性。程序员工作在一个面向对象的、灵活的网络结构下而不是严格、静态的表中——但是他们可以享受到具备完全的事务特性、企业级的数据库的所有好处。
Neo4j因其嵌入式、高性能、轻量级等优势,越来越受到关注。
图形数据结构
在一个图中包含两种基本的数据类型:Nodes(节点) 和 Relationships(关系)。Nodes 和 Relationships 包含key/value形式的属性。Nodes通过Relationships所定义的关系相连起来,形成关系型网络结构。
 
     neo4j是一种图数据库,同时它也是一种嵌入式数据库。它对图数据是以节点和边(关系)模式进行存储。每个节点可以包含一系列信息,通过Node类里面的setProperty()方法对节点信息进行存储,Node也可以使用createRelationshipTo()方法实现个节点和其他节点的联系,并且该方法返回的是一个Relationship对象,我们也可以对Relationship设置属性,也就是节点和节点之间的关系属性。什么叫关系属性?例如:person1àperson2,person1和person2的关系可以是朋友也可以是同学还可以是亲人,这里的朋友、同学、亲人就是这里的Relationship的属性。那么关系属性就是描叙两个节点之间的关系类型。这就方便在对节点进行查找的时候对节点进行过滤。
 
 
neo4j数据库中的节点类似关系型数据库中的表。neo4j节点之间的关系类似关系型数据库中的2表之间的第三张表,neo4j数据库的节点之间的关系上也可以保存一些2者之间关系的属性键值对。同样,可以为每种关系创建一个名字,把关系归类管理。图形数据库比关系型性能好很多,操作性很好,可以灵活的控制,根据neo4j中Node的不同,我们可以赋予不同的属性
如有转载,请标明来自此出处http://blog.csdn.net/qxs965266509,必须注意!
下面我给大家提供一些neo4j数据库查询的语法:
http://docs.neo4j.org/refcard/2.0/
START
 
START
 
n=node(*)
Start from all nodes.
 
START
 
n=node({ids})
Start from one or more nodes specified by id.
 
START
 
n=node({id1}),
 m=node({id2})
Multiple starting points.
 
START
 
n=node:nodeIndexName(key={value})
Query the index with an exact query. Use node_auto_indexfor the automatic index.
MATCH
 
MATCH
 
(n:Person)-[:KNOWS]->(m:Person)
 
WHERE
 
n.name="Alice"
Node patterns can contain labels. No START clause is required then.
 
MATCH
 
(n)-->(m)
Any pattern can be used in MATCH except the ones containing property maps.
 
MATCH
 
p = (n)-->(m)
Assign a path to p.
WHERE
 
WHERE
 
n.property <> {value}
Use a predicate to filter.
Predicates
 
n.property
 <> {value}
Use comparison operators.
 
has(n.property)
Use functions.
 
n.number
 >= 1 AND
 
n.number <= 10
Use boolean operators to combine predicates.
 
n:Person
Check for node labels.
 
identifier
IS
 
NULL
Check if something is NULL.
 
NOT
 
has(n.property)
OR
 
n.property = {value}
Either property does not exist or predicate is TRUE.
 
n.property
 = {value}
Non-existing property returns NULL, which is only equal to NULL.
 
n.property
 =~ "Tob.*"
Regular expression.
 
(n)-[:KNOWS]->(m)
Make sure the pattern has at least one match.
 
NOT
 
(n)-[:KNOWS]->(m)
Exclude matches to (n)-[:KNOWS]->(m) from the result.
 
n.property
IN
 
[{value1}, {value2}]
Check if an element exists in a collection.
Predicate Functions
 
all(x
IN
 
collection WHERE
 
has(x.property))
Returns true if the predicate is TRUE for all elements of the collection.
 
any(x
IN
 
collection WHERE
 
has(x.property))
Returns true if the predicate is TRUE for at least one element of the collection.
 
none(x
IN
 
collection WHERE
 
has(x.property))
Returns TRUE if the predicate is FALSE for all elements of the collection.
 
single(x
IN
 
collection WHERE
 
has(x.property))
Returns TRUE if the predicate is TRUE for exactly one element in the collection.
Scalar Functions
 
length(collection)
Length of the collection.
 
type(a_relationship)
String representation of the relationship type.
 
startNode(a_relationship)
Start node of the relationship.
 
endNode(a_relationship)
End node of the relationship.
 
coalesce(n.property,
 {defaultValue})
The first non-NULL expression.
 
head(collection)
The first element of the collection.
 
last(collection)
The last element of the collection.
 
timestamp()
Milliseconds since midnight, January 1, 1970 UTC.
 
id(node_or_relationship)
The internal id of the relationship or node.
String Functions
 
str({expression})
String representation of the expression.
 
replace({original},
 {search}, {replacement})
Replace all occurrences of search with replacement. All arguments are be expressions.
 
substring({original},
 {begin}, {sub_length})
Get part of a string. The sub_length argument is optional.
 
left({original},
 {sub_length}),
 
  right({original},
 {sub_length})
The first part of a string. The last part of the string.
 
trim({original}),
ltrim({original}),
 
  rtrim({original})
Trim all whitespace, or on left or right side.
 
upper({original}),
lower({original})
UPPERCASE and lowercase.
 
 
RETURN
 
RETURN
 
*
Return the value of all identifiers.
 
RETURN
 
n AS
 
columnName
Use alias for result column name.
 
RETURN
 
DISTINCT 
n
Return unique rows.
 
ORDER
 
BY 
n.property
Sort the result.
<
补充:综合编程 , 其他综合 ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,