SQL/PGQ is a graph query language built on top of SQL, bringing graph pattern matching capabilities to existing SQL users as well as to new users who are interested in graph technology but who do not have an SQL background.
SQL/PGQ is standardized by the International Organization for Standardization (ISO). It provides a declarative language for querying property graphs, which are a type of graph data model that stores nodes, edges, and properties on both nodes and edges.
SQL/PGQ queries use a visual graph syntax that is similar to that of Cypher, another popular graph query language. However, SQL/PGQ also supports traditional SQL syntax, which makes it easy for SQL users to get started with graph querying.
SQL/PGQ can be used to query property graphs for a variety of purposes, including:
See here for a list of resources related to SQL/PGQ.
If you have followed the installation instructions and executed ./build/release/duckdb
, you will be able to load the LDBC SNB dataset at scale factor 0.003 using the following command:
import database 'duckdb-pgq/data/SNB0.003';
The next step is to create a property graph based on the data. This property graph functions similarly to a VIEW
, serving as a layer on top of the data. Each property graph is associated with a single connection. For a more in-depth explanation of property graphs in DuckPGQ, see
Execute the following command to create a property graph:
CREATE PROPERTY GRAPH snb
VERTEX TABLES (
Person LABEL Person
)
EDGE TABLES (
person_knows_person SOURCE KEY ( person1id ) REFERENCES Person ( id )
DESTINATION KEY ( person2id ) REFERENCES Person ( id )
LABEL Knows
);
If everything goes well, the following will be returned. In that case, you can execute queries containing SQL/PGQ syntax on this property graph.
┌─────────┐
│ Success │
│ boolean │
├─────────┤
│ 0 rows │
└─────────┘