Introduction
2024-11-22
# directed edges
<Luke> <owns> <R2D2> ,
<C3PO> .
# node types (additional edges)
<R2D2> a <robot> .
<C3PO> a <robot> .
<Luke> a <person> .
# no undirected edges!
<R2D2> <friend> <C3PO> .
robot ownership
robot friendship
# nodes
INSERT INTO robots VALUES ("R2D2");
INSERT INTO robots VALUES ("C3PO");
INSERT INTO people VALUES ("Luke");
# edges
INSERT INTO robot_ownership VALUES ("Luke", "C3PO");
INSERT INTO robot_ownership VALUES ("Luke", "R2D2");
INSERT INTO robot_friends VALUES ("R2D2", "C3PO"); # directed!
<?xml version="1.0" encoding="UTF-8"?>
<graphml xmlns="http://graphml.graphdrawing.org/xmlns">
<graph edgedefault="undirected">
<node id="C3PO"/>
<node id="Luke"/>
<node id="R2D2"/>
<edge source="Luke" target="C3PO" directed="true"/>
<edge source="Luke" target="R2D2" directed="true"/>
<edge source="C3PO" target="R2D2"/>
</graph>
</graphml>
CREATE (C3PO:robot)
CREATE (Luke:person)
CREATE (R2D2:robot)
CREATE (Luke)-[:owns]->(C3PO)
CREATE (Luke)-[:owns]->(R2D2)
CREATE (Luke)-[:friend]->(C3PO) # directed!
# nodes
R2D2 :robot
C3PO :robot
Luke :person
# edges
Luke -> C3PO :owns # directed
Luke -> R2D2 :owns # undirected
C3PO -- R2D2 :friends # undirected
pgraph
to convert formatsCreate a graph of some robots in Star Wars!
# node properties
Padmé :person gender: female
Anakin :person gender: male
Luke :person gender: male
C3PO :robot color: golden, silver # multi-value!
R2D2 :robot
# edge properties
Padmé -> R2D2 :owns episode:1
Anakin -> R2D2 :owns episode:2
Anakin -> Luke :child episode:3
Padmé -> Luke :child episode:3
Luke -> R2D2 :owns episode:4
Luke -> C3PO :owns episode:4
Special properties (name, id, visual, reserved…)
Which datatypes are supported (string, number, date…)?
Can properties have values of mixed type? Empty set? Null?
What are node/edge ids (internal, numeric, name…)?
Can nodes/edges have multiple labels/types?
flowchart LR Q28193["<u>Academy Award for Best Film Editing (Q28193)</u><br>alias: Oscar for Best Film Editing"] Q463119["<u>Marcia Lucas (Q463119)</u><br><tt>alias:</tt> Marcia Griffin"] Q463119 -- "<u>award received (P166)</u><br>for work: Star Wars<br>date: 1978" --> Q28193
A class of graph structures where
Specific features differ depending on data format and software
Useful for data modeling and schema-less data management
There are only two hard things in Computer Science: cache invalidation and naming things. — Phil Karlton
Converter NPM package pgraphs