6.1 Loading a SQL Property Graph Using the readGraphByName API
You can load a SQL property graph into the graph server (PGX) by calling the
readGraphByName
API on a PgxSession
object.
When loading a SQL property graph into the graph server (PGX), the full graph schema will be determined and mapped to a graph configuration. The graphs will be loaded as partitioned graphs where each vertex or edge table will be mapped to the respective vertex or edge provider of the same name. Labels and properties will also be loaded as defined.
However, note that only one label per vertex or edge table is supported in order to load a SQL graph into the graph server (PGX).
For example, consider the following SQL property graph:
CREATE PROPERTY GRAPH student_network
VERTEX TABLES (
persons KEY (person_id)
LABEL person
PROPERTIES (person_id, name, birthdate AS dob)
)
EDGE TABLES (
friendships AS friends
KEY (friendship_id)
SOURCE KEY (person_a) REFERENCES persons(person_id)
DESTINATION KEY (person_b) REFERENCES persons(person_id)
PROPERTIES (friendship_id, meeting_date)
);
You can load this SQL graph into memory as shown:
opg4j> var graph = session.readGraphByName ("STUDENT_NETWORK",GraphSource.PG_SQL)
graph ==> PgxGraph[name=STUDENTS_NETWORK,N=4,E=4,created=1681007796946]
PgxGraph graph = session.readGraphByName("STUDENT_NETWORK", GraphSource.PG_SQL);
>>> graph = session.read_graph_by_name("STUDENT_NETWORK", "pg_sql")
>>> graph
PgxGraph(name: STUDENTS_NETWORK, v: 4, e: 4, directed: True, memory(Mb): 0)
- Loading a SQL Property Graph from a Different Schema
You can specify the schema name when using thereadGraphByName
API for loading a SQL property graph. - Loading a SQL Property Graph Using Graph Optimization Options
You can optimize the read or update performance when loading a SQL property graph using thereadGraphByName
API.
Parent topic: Loading a SQL Property Graph into the Graph Server (PGX)