Creating a property graph as a layer on top of your data is the first step in using SQL/PGQ. In DuckPGQ, property graphs are transient, they only exist as long as the connection to the database is open.
The tables will be split into vertex tables and edge tables, having a primary key-foreign key relationship. An edge table should have a column defining the source node and a column defining the destination node.
To create a property graph the syntax is as follows:
CREATE [ OR REPLACE ] PROPERTY GRAPH (<property_graph_name>
VERTEX TABLES (
<vertex table>
[, <vertex table> ]
)
[ EDGE TABLES (
<edge table>
[, <edge table ] ) ];
At least one <vertex table>
needs to be specified to create a valid property graph. The EDGE TABLES
are optional.
<table name> [ AS <table name alias> ] [ <[properties](<https://duckpgq.notion.site/Property-graph-05c1dffe3f2547f0abfa3ea5a2b4eae1>)> ] [ LABEL <[label](<https://duckpgq.notion.site/Property-graph-05c1dffe3f2547f0abfa3ea5a2b4eae1>)> ]
For the vertex table, only the name of the table it is a reference to is required. The table name alias, properties, and label are optional.
<aside> ⚠️ Under construction
</aside>
<aside> ⚠️ Under construction
</aside>
Properties can be used to restrict the number of columns that can be used in a SQL/PGQ query.
The specifications allow several options:
PROPERTIES (column [, <column>])
: List the columns allowed from the original tablePROPERTIES [ARE] ALL COLUMNS [EXCEPT (column [, column])]
: Allow all columns from the original table except the columns listed in the EXCEPT
list.