Use the OrientDb database to perform graphic databases to build molds
Use the OrientDb database to perform graphic databases to build molds
OrientDB is an open source multi -model database management system with the function of graphics database.It supports modeling data in graphics to make it more visual and intuitive.This article will introduce how to use the OrientDB database for graphics database to build molds, and provide the necessary programming code and related configuration description.
1. Installation and configuration Orientdb
1. Download Orientdb and decompress
2. Run "./bin/server.sh" or "./bin/server.bat" Start OrientdB server
3. Use the browser to access "http: // localhost: 2480", enter the management console of Orientdb
4. Create a new database in the Control Template
Basic operation
1. Create node (vertex)
Create an entity in a node to represent the entity:
Insert Into Person Set name = 'Zhang San', Age = 25
2. Create edge (edge)
Create one side connection and two nodes:
CREATE EDGE FriendOf FROM (SELECT FROM Person WHERE name = '张三') TO (SELECT FROM Person WHERE name = '李四')
3. Query nodes and edges
Query all nodes:
SELECT FROM Person
All edges of the query:
SELECT FROM FriendOf
Query node and its associated edges:
SELECT expand(out('FriendOf')) FROM Person WHERE name = '张三'
Query the shortest path between the two nodes:
SELECT expand(shortestPath((SELECT FROM Person WHERE name = '张三'), (SELECT FROM Person WHERE name = '李四'))) FROM Person
Three, advanced functions
1. Index
Create an index on the graphical database to improve the query performance:
CREATE INDEX Person.name ON Person (name) UNIQUE
2. Affairs
Use the transaction to batch and roll back the database operation:
BEGIN
INSERT INTO PERSON SET NAME = 'King 5', age = 30
INSERT INTO Person SET name = '赵六', age = 35
COMMIT
ROLLBACK
3. Graphical algorithm
Use the built -in graphic algorithm for analysis and calculation:
SELECT expand(traverse(out('FriendOf')) FROM (SELECT FROM Person WHERE name = '张三')) FROM Person
SELECT shortestPath((SELECT FROM Person WHERE name = '张三'), (SELECT FROM Person WHERE name = '李四')).size() FROM Person
Fourth, summary
This article introduces how to use the OrientDB database for graphics database to build molds.By creating nodes and edges, you can build a graphical database, and expand the database functions by querying, creating indexes and execution transactions.In addition, the graphics algorithm provided by OrientdB can be used for complex analysis and calculation.Using these functions can better understand and manage data.It is hoped that this article will help using OrientDB for graphic database to build models.
Note: The code and configuration provided above may need to be adjusted and optimized according to the actual application.