Graph query Cypher 교육
* pgAdmin
쿼리 tool, 이번 교육을 위해 새로 설치해봄

* AGViewer
GDB 시각화 도구

* GDB query
GDB = 노드 + 엣지
MATCH ... RETURN ...;
MATCH문은 특정 노드를 변수명으로 선언하는 역할이고
return이 기존 select 문 같은 역할을 함
* 데이터 조회
MATCH(a:person) return distinct key(a);
person 테이블의 모든 컬럼을 조회 = SQL의 describe와 유사
MATCH(a:person)
WHERE a.name in ['Keanu Reeves', 'Tom Cruise']]
return a.born, a.name;
이름이 Keanu Reeves, Tom Cruise 중 하나인 person을 a라 하였을 때, a의 출생연도와 이름을 return
*데이터 입력/적재
데이터 입력하는 방법 1. CREATE문으로 단문처리
CREATE (Keanu:Person {name : "Keanu Reeves", born:1964})
CREATE (TheMatrixReloaded:Movie {title:'The Matrix Reloaded', released:2003, tagline:'Free your mind'})
CREATE (Keanu)-[:ACTED_IN {roles:["Neo"]}]->(TheMatrixReloaded)
데이터 입력하는 방법 2. 파일에서 load하기 (가장 일반적임)
create vlabel person ;
LOAD FROM person AS row CREATE (:person=JSONB_STRIP_NULLS(ROW_TO_JSON(row)::JSONB)) ;
* 테이블 조회
agens -U agens -d postgres
\dG
\dGv+
\dGe+
agens postgres 진입
\dG: 전체 테이블명 조회
\dGv+: 전체 vertex 테이블 조회
\dGe+:전체 edge 테이블 조회
* RDB와 GDB가 다른 점
RDB는 매핑테이블 같은 걸 만들어놓진 않지만, GDB는 모든 매핑테이블들을 만들어놓음으로써 속도가 빠른 것임
RDB는 모든 스키마를 다 지정해둬야하지만, GDB는 스키마를 구성할 필요가 없음
* 샘플 데이터셋 LDBC (Linked Data Benchmark Council)
https://ldbcouncil.org/benchmarks/snb/
LDBC Social Network Benchmark (LDBC SNB)
LDBC came out of an EU FP7 project and is now a non-profit organization sustained by its members. Contact us at info AT ldbcouncil DOT org.
ldbcouncil.org