DEV Community

danielwambo
danielwambo

Posted on

Database schema : Nodes and Edges

The Apache AGE is an extension that brings graph database capabilities to the PostgreSQL relational database. Below is a simplified example of a database schema for Apache AGE:

CREATE TABLE nodes (
    id SERIAL PRIMARY KEY,
    label VARCHAR(255)
);

CREATE TABLE edges (
    id SERIAL PRIMARY KEY,
    label VARCHAR(255),
    source_id INTEGER REFERENCES nodes(id),
    target_id INTEGER REFERENCES nodes(id)
);

Enter fullscreen mode Exit fullscreen mode

In this schema:

The nodes table stores information about the nodes in the graph. Each node has a unique identifier (id) and a label describing its type or category.
The edges table stores information about the relationships between nodes. Each edge has a unique identifier (id), a label describing its type, and references to the source and target nodes through their ids.
This schema provides a basic structure for storing and querying graph data within Apache AGE.

Top comments (0)