170 words
1 minutes
图数据库
2024-07-31

核心概念#

顶点vertex
边edge

cypher查询语言

主要选型#

apache AGE
neo4j

101#

基于apache AGE的基础测试

-- 开启
LOAD 'age';
SET search_path = ag_catalog, "$user", public;


SELECT * FROM ag_catalog.drop_graph('geae', true);

  

SELECT create_graph('geae');

  

SELECT * FROM cypher('geae', $$

CREATE (i1:Invoice {id:'123', name: '发票1', code: 'B1'}),

(i2:Invoice {name: '发票2', code:'B2'}),

(f1:Form {name: "单据1", comment: "发票:B1"}),

(f2:Form {name: "单据2", comment: "发票:B2"}),

(f3:Form {name: "单据3", comment: "发票:B3"})

$$) as (a agtype);

  

  

SELECT *

FROM cypher('geae', $$

MATCH (a:Invoice), (b:Form)

WHERE b.comment contains a.code AND b.xxx = a.ccc

CREATE (a)-[e:包含 {property:a.property + '<->' + b.property}]->(b)

RETURN e

$$) as (e agtype);

  

SELECT * from cypher('geae', $$

MATCH (V)-[R:包含]-(V2)

RETURN V,R,V2

$$) as (V agtype, R agtype, V2 agtype);

性能测试#

写数据

建关联

查数据异常

图数据库
https://fuwari.vercel.app/posts/blog/图数据库/
Author
𝕁𝕠𝕖𝕪 ℤ𝕙𝕖𝕟𝕘
Published at
2024-07-31
License
CC BY-NC-SA 4.0