Example database
We use the following example graph dataset that
consists of User
and City
nodes, Follows
relationships between users,
and LivesIn
relationships between users and cities.
The DDL statements to define the schema of this database, the csv files containing
the records of the tables in the database and the data import (COPY FROM
) commands
are shown below.
User nodes
Schema:
CREATE NODE TABLE User(name STRING, age INT64 DEFAULT 0, PRIMARY KEY (name))
user.csv:
Adam,30Karissa,40Zhang,50Noura,25
Data import (You need to give full path to user.csv. We assume ${PATH-TO-DIR} is that directory):
COPY User FROM "${PATH-TO-DIR}/user.csv"
City nodes
Schema:
CREATE NODE TABLE City(name STRING, population INT64, PRIMARY KEY (name))
city.csv
Waterloo,150000Kitchener,200000Guelph,75000
Data import:
COPY City FROM "${PATH-TO-DIR}/city.csv"
Follows relationships
Schema:
CREATE REL TABLE Follows(FROM User TO User, since INT64)
follows.csv
Adam,Karissa,2020Adam,Zhang,2020Karissa,Zhang,2021Zhang,Noura,2022
Data import:
COPY Follows FROM "${PATH-TO-DIR}/follows.csv"
LivesIn relationships
Schema:
CREATE REL TABLE LivesIn(FROM User TO City)
lives-in.csv
Adam,WaterlooKarissa,WaterlooZhang,KitchenerNoura,Guelph
Data import:
COPY LivesIn FROM "${PATH-TO-DIR}/lives-in.csv"