, Figure database Neo4j Introduction:
Http://www.neo4j.org/learn/neo4j
NEO4J is an open source map data, very easy to use, lightweight and flexible, embedded, powerful, and related information is complete.
According to the official website of neo4j, the database can support billions of nodes:
Massively scalable, up to several billion nodes/relationships/properties
and support distributed deployment, Master,slave.
Introduction to the performance and usability of neo4j: http://video.neo4j.org/player/6qUmb/native/autoplay/
NEO4J CEO has a video brief introduction to neo4j:http://player.vimeo.com/video/56040747
2, Installation:
The installation of neo4j is very easy to use. Download a stable version, unzip, run Neo4j.bat (Windows version). Http://www.neo4j.org/download, the current stable version of the more useful is 1.9.1.
You can then access the Web management interface, address: http://localhost:7474/webadmin
The 3,neo4j are used in the following ways:
1) can write programs, add, update, with java,python,php,. NET and other languages can be implemented.
2) You can use the command line, add, update, view, NEO4J provides the web-based execution interface, provides the class SQL language execution, these languages include Cypher,gremlin and so on.
Such as:
3) You can add, update nodes and relationships based on the Web UI interface provided by NEO4J, as follows:
4) You can import data using additional tools (ETL). You can also import data from a relational database.
Http://www.neo4j.org/develop/import
4, use Java to access neo4j:
Learning Material: Http://www.neo4j.org/develop/java
Http://docs.neo4j.org/chunked/stable/tutorials-java-embedded.html
NEO4J nodes, edges, can be arbitrarily added attributes, edge (relationship) can be customized, is an enumeration value, for example:
Firstnode = Graphdb.createnode ();
Firstnode.setproperty ("message", "Hello, [Node A],");
Secondnode = Graphdb.createnode ();
Secondnode.setproperty ("message", "The Graph DB world! [Node B] " );
Relationship = Firstnode.createrelationshipto (Secondnode, reltypes.knows);
Relationship.setproperty ("Reason", "Use neo4j for testing [Edge],");
It is also important that neo4j can support custom node classes, that is, you can design the class as you need to do nodes, that is, you can add any method to each node, to achieve any function, this feature is very extensible.
And NEO4J provides the ability of the embedded program, you can use it as a lib, you can keep other applications open mode, provide the power of the graph database.
The example socnet can be found on NEO4J's website.
5,cypher Introduction:
Cypher is an efficient class SQL language provided by NEO4J for graph data and relational queries. The relationship query adopts a pattern matching method, which is more intuitive.
Very good study material: Http://www.neo4j.org/learn/cypher
This video speaks very clearly: http://player.vimeo.com/video/50389825
Create nodes: (Each node will automatically create a unique ID that cannot be modified.) The following ID is the attribute of node. )
Create N={name: ' Motion ', ID: ' M001 '} return n;
To create a relationship:
Start N=node (+), M=node () create M-[r:knows]-n return R;
Inquire:
Query by ID (the ID here is automatically created by the system):
Start N=node () return m;
Query all nodes:
Start N=node (*) return n;
Query properties, Relationships:
Start N=node (9) return n,n.name,n.id,n.level; View the specified node and return the required properties
Start N=node (*) match (n)-[r:subclassof]->m return m,n,n.name,n.id,r; Find specified relationship
Querying multiple nodes by relationship:
Start a = node (+) match b-[r]<->a return r,b;
Start a = node (0) match c-[:knows]->b-[:knows]->a return a,b,c; Finding nodes for two-tier knows relationships
Start a = node (+) match b-[*]->a return A, a, b; Find all nodes that are related to a node
Query with the WHERE condition: (You can use it without creating an index)
Start N=node (*) where n.name= "Activity" return n;
And you can use specific symbols:
Start N=node (*) where n.id?= "A *" return n;
Start N=node (*) where has (N.type) return n,n.name,n.id,n.type; If a property type exists and starts with a, the node is output.
The configuration file is automatically indexed:
Modify the contents of the Neo4j.properties file in the Conf directory as follows, restart the neo4j and take effect on the new node after the reboot.
# Enable auto-indexing for nodes, default is False
Node_auto_indexing=true
# The Node property keys to be auto-indexed, if enabled
Node_keys_indexable=name,id
# Enable auto-indexing for relationships, default is False
Relationship_auto_indexing=true
# The Relationship property keys to be auto-indexed, if enabled
Relationship_keys_indexable=knows,subclassof
After indexing, you can query by attribute value with Node_auto_index:
Start N=node:node_auto_index (name= "C") return n,n.name;
To modify a property value:
Start a = node (*) where a.name= "a" set A.name= "a" return a,a.name;
Start N=node (0) Set n.name= "Root", n.id= "001"; Add the Name,id property to the default root node for easy querying.
Delete:
Delete all nodes and relationships:
START N=node (*)
Match n-[r]-()
Delete n,r;
6, graphical display of data:
NEO4J itself provides graphical data visualization tools for Web interface, very cool. This video speaks of specific: https://player.vimeo.com/video/58016492
In the Web Management http://localhost:7474/webadmin "Data Browser" graphical display area point style,newprofile, edit your profile, note that the add filter nodes to be placed in front, Otherwise, the rules are executed sequentially, displaying multiple attributes that can be used to make line breaks.
Look at one of the user model Ontology relationship models I made:
The ontology relationship between the User Model and the data source, the left circle is Usermodel, and the right square is the data source:
On the Data browser directly enter the node number, such as 10, point graphical display, you can graphically see the node and related nodes, point to each node, you can gradually display all nodes and relationships, very convenient:
7. Back up the NEO4J data:
1) Shut down the database.
2) Back up all content in the Graph.db directory under the D:\Neo4J\neo4j-enterprise-1.9.1\data directory.
3) Copy the contents of the Graph.db directory on the server to the same directory of the new server and start.
8, why use the graph database?
This question, you are welcome to communicate with me. Graph database extensibility, flexibility is very good for complex relationship management and relational query inference, social relationship application is an optional application scenario. And I choose Graph database, the cause is to study Semantic Web and ontology application, Semantic Web and ontology data structure (ternary group) is the graph structure, and the semantic web based on RDF is too complex and inefficient, in fact, it is not so easy to build based on graph database, and neo4j supports extensions such as RDF,SPARQL. In addition, I think owl, the practical value of the small, owl almost is to use XML to describe an object-oriented programming language, and this programming language if the ability to express too strong (owl full), simply can not be achieved, if the ability to express too weak (owl Lite), in fact, there is little practical significance. Moreover, I think that Tim Berners-lee Semantic Web, that is, based on RDF semantics, this idea of using RDF to describe semantics goes to the previous rule-based NLP approach, although with human computation crowdsourcing mode, it is still difficult to walk through. I am more concerned about the ontology relationship, knowledge base construction, and the knowledge ontology is mainly Meta data, do not need a lot of data, try not to save instance data, get instance data can be associated with other databases of the source to query (this Data key-value or table save).
Simple relational reasoning, attribute transfer, in fact, is the query, neo4j Cypher can also be completed. So, I tend to use the graph database to build the Knowledge Base Knowledge Base ("KB"), or Knowledge graph ("KG"). The knowledge base is valuable for related search or association recommendation of knowledge Correlation query. Furthermore, the rules can be inferred from the Knowledge Ontology relational library, for example, If place was meeting the and Date is Workday and Than Activity are meeting. Such rules can be obtained from the ontology relationship, and the rules can largely compensate for the many shortcomings of statistical-based computational learning. A bigger role, I think the graph database is a "reasonable way of knowledge preservation and description", which is conducive to the continuous accumulation of knowledge and continuous evolution. In addition, in the future, the knowledge ontology, and the model algorithm to establish a relationship, if the appropriate relationship conditions, using the correct algorithm model, it will play a real huge role, it is very close to "intelligence".
With the full text of the picture, see here http://blog.csdn.net/ub1010/article/details/9263325
Go: Introduction to graph Database neo4j