"Neo4j Tutorial"의 두 판 사이의 차이
hiblue
(→Cypher, The Graph Query Language) |
|||
| 1번째 줄: | 1번째 줄: | ||
==Neo4j 소개== | ==Neo4j 소개== | ||
| − | * | + | *Neo4j is the world’s leading graph database.<br/>그래프 데이터 베이스 |
| − | * | + | *Cypher, The Graph Query Language를 이용 |
==Neo4j의 기본구조== | ==Neo4j의 기본구조== | ||
| − | * | + | *The Labeled Property Graph Model을 기본 데이터 구조로 가짐. |
[[File:Neo4j_model.JPG|800px]] | [[File:Neo4j_model.JPG|800px]] | ||
===노드<span style="color:skyblue">''Nodes''</span>=== | ===노드<span style="color:skyblue">''Nodes''</span>=== | ||
2018년 1월 18일 (목) 15:48 판
목차
Neo4j 소개
- Neo4j is the world’s leading graph database.
그래프 데이터 베이스 - Cypher, The Graph Query Language를 이용
Neo4j의 기본구조
- The Labeled Property Graph Model을 기본 데이터 구조로 가짐.
노드Nodes
- 데이터 개체
Nodes are the main data elements - 관계로 다른 노드들과 연결
Nodes are connected to other nodes via relationships - 하나 이상의 속성을 지님
Nodes can have one or more properties (i.e., attributes stored as key/value pairs) - 하나 이상의 라벨을 지님
Nodes have one or more labels that describes its role in the graph
관계Relationships
- 두 개의 노드를 연결
Relationships connect two nodes - 직접적으로 연결
Relationships are directional - 하나의 노드가 여러 개의 관계, 재귀적인 관계도 가질 수 있음
Nodes can have multiple, even recursive relationships - 관계는 하나 이상의 속성을 가진다
Relationships can have one or more properties (i.e., attributes stored as key/value pairs)
속성Properties
- 문자로 정의된 값
Properties are named values where the name (or key) is a string - 색인화되고, 제한될 수 있다.
Properties can be indexed and constrained - 다양한 속성으로 복합적인 색인을 만들 수 있다
Composite indexes can be created from multiple properties
라벨Labels
- 노드를 묶는 단위
Labels are used to group nodes into sets - 하나의 노드는 여러개의 라벨을 가질 수 있다
A node may have multiple labels - 그래프에서 노드를 더 잘 찾을 수 있도록 색인화된다
Labels are indexed to accelerate finding nodes in the graph - 기초 라벨 색인은 속도에 최적화되어 있다
Native label indexes are optimized for speed
Cypher, The Graph Query Language
- Cyper의 기본 구조
MATCH <pattern> WHERE <conditions> RETURN <expressions>
- Create
CREATE (ee:Person { name: "Emil", from: "Sweden", klout: 99 })
이름이 Emil이고 출신이 Sweden, 영향력이 99인 Person 라벨의 개체를 만들어라.
- Match : finding Nodes
MATCH (ee:Person) WHERE ee.name = "Emil" RETURN ee;
라벨이 Person인 개체 중에 이름 속성이 emil인 것의 그 개체 자체(모든 것)를 보여라.
MATCH (ee:Person) WHERE ee.name = "Emil"
CREATE (js:Person { name: "Johan", from: "Sweden", learn: "surfing" }),
(ir:Person { name: "Ian", from: "England", title: "author" }),
(rvb:Person { name: "Rik", from: "Belgium", pet: "Orval" }),
(ally:Person { name: "Allison", from: "California", hobby: "surfing" }),
(ee)-[:KNOWS {since: 2001}]->(js),(ee)-[:KNOWS {rating: 5}]->(ir),
(js)-[:KNOWS]->(ir),(js)-[:KNOWS]->(rvb),
(ir)-[:KNOWS]->(js),(ir)-[:KNOWS]->(ally),
(rvb)-[:KNOWS]->(ally)
Cypher 실습
- Neo4j 샘플:워커힐 프로젝트
- 클래스 Actor만 보여라
match (n:Actor) return n
- 클래스가 Actor인 개체의 한글이름과 한자이름을 보여라.
match (n:Actor) return n.name, n.chname