Reputation: 584
Where are the properties of the vertices and edges stored in the Apache AGE and what data structures are used for the purpose?
I know that the vertex and edges are stored in their respective tables _ag_label_vertex
and _ag_label_edge
. These tables have a column named property
that shows the properties of the individual entities. Are the properties stored in another database and referenced in the the mentioned database as a foreign key or is it simply stored in as a string (or json). And how are these values accessed or processed during a query processing.
Upvotes: 1
Views: 308
Reputation: 650
You can see the properties stored in JSON format (but as agtype) at 'graph_name'._ag_label_vertex
and 'graph_name'._ag_label_edge
. Here's an example:
You can use 'graph_name'.'label'
to get all vertices or edges under a specific label.
Upvotes: 0
Reputation: 31
The data for separate graphs are kept in separate namespaces or schemas. So to get the vertices data:
SELECT * FROM <graph_name>._ag_label_vertex;
For edges data:
SELECT * FROM <graph_name>._ag_label_edge;
The data about vertex or edges are stored in normal PostgreSQL tables.
Upvotes: 0
Reputation: 211
AGE uses its on custom schema based on YOUR created graph. Based on how you will define your node/vertex relationships, you may get different schemas.
Take for example the following visualisation (Using AGE Viewer):
The relationship was formed based on the following query:
SELECT * FROM cypher('metro', $$
CREATE (cavite:Metro {name: 'Cavite Island'}),
(stGermain:Metro {name: 'St Germain'}),
(pigalle:Metro {name: 'Pigalle'}),
(montreal:Metro {name: 'Montreal'}),
(quebec:Metro {name: 'Quebec'}),
(fortTilden:Metro {name: 'Fort Tilden'}),
(intramuros:Metro {name: 'Intramuros'}),
(chinaTown:Metro {name: 'China Town'}),
(stDomingo:Metro {name: 'St Domingo'}),
(coneyIsland:Metro {name: 'Coney Island'}),
(brooklyn:Metro {name: 'Brooklyn'}),
(uptown:Metro {name: 'Uptown'}),
(cardShark:Metro {name: 'Card Shark'}),
(divisoria:Metro {name: 'Divisoria'}),
(ermita:Metro {name: 'Ermita'}),
(nyc:Metro {name: 'NYC'}),
(staIsabel:Metro {name: 'Sta Isabel'}),
(theRuins:Metro {name: 'The Ruins'}),
(phoenix:Metro {name: 'Phoenix'}),
(bastille:Metro {name: 'Bastille'}),
(puertoDelPostigo:Metro {name: 'Puerto del Postigo'}),
(redLight:Metro {name: 'Red Light'}),
(hotelStPaul:Metro {name: 'Hotel St Paul'})
CREATE (cavite)-[:HAS_ROUTE {travelTime: 2.5}]->(intramuros),
(cavite)-[:HAS_ROUTE {travelTime: 3}]->(fortTilden),
(stGermain)-[:HAS_ROUTE {travelTime: 9}]->(intramuros),
(stGermain)-[:HAS_ROUTE {travelTime: 5.6}]->(chinaTown),
(pigalle)-[:HAS_ROUTE {travelTime: 6}]->(chinaTown),
(pigalle)-[:HAS_ROUTE {travelTime: 4}]->(montreal),
(pigalle)-[:HAS_ROUTE {travelTime: 8.5}]->(nyc),
(montreal)-[:HAS_ROUTE {travelTime: 3}]->(quebec),
(fortTilden)-[:HAS_ROUTE {travelTime: 13}]->(brooklyn),
(coneyIsland)-[:HAS_ROUTE {travelTime: 1.5}]->(brooklyn),
(brooklyn)-[:HAS_ROUTE {travelTime: 2.5}]->(uptown),
(brooklyn)-[:HAS_ROUTE {travelTime: 5}]->(theRuins),
(uptown)-[:HAS_ROUTE {travelTime: 5}]->(intramuros),
(intramuros)-[:HAS_ROUTE {travelTime: 11}]->(chinaTown),
(intramuros)-[:HAS_ROUTE {travelTime: 16.5}]->(bastille),
(chinaTown)-[:HAS_ROUTE {travelTime: 7.5}]->(divisoria),
(chinaTown)-[:HAS_ROUTE {travelTime: 4.5}]->(ermita),
(chinaTown)-[:HAS_ROUTE {travelTime: 12.5}]->(nyc),
(theRuins)-[:HAS_ROUTE {travelTime: 4}]->(cardShark),
(theRuins)-[:HAS_ROUTE {travelTime: 5.5}]->(phoenix),
(theRuins)-[:HAS_ROUTE {travelTime: 2.5}]->(redLight),
(cardShark)-[:HAS_ROUTE {travelTime: 4.5}]->(phoenix),
(divisoria)-[:HAS_ROUTE {travelTime: 6.5}]->(bastille),
(ermita)-[:HAS_ROUTE {travelTime: 9}]->(puertoDelPostigo),
(nyc)-[:HAS_ROUTE {travelTime: 10.5}]->(puertoDelPostigo),
(nyc)-[:HAS_ROUTE {travelTime: 5}]->(stDomingo),
(nyc)-[:HAS_ROUTE {travelTime: 2}]->(staIsabel),
(phoenix)-[:HAS_ROUTE {travelTime: 3.5}]->(redLight),
(phoenix)-[:HAS_ROUTE {travelTime: 10}]->(bastille),
(bastille)-[:HAS_ROUTE {travelTime: 6.5}]->(hotelStPaul),
(bastille)-[:HAS_ROUTE {travelTime: 6}]->(puertoDelPostigo),
(puertoDelPostigo)-[:HAS_ROUTE {travelTime: 3}]->(staIsabel)
$$) as (c agtype);
For practical understanding of how these graph queries are referenced, it is best to use visualisation tools like AGE Viewer.
You can further use commands like \d
, \dt
& \dt+
to solidify your understanding through Postgres command line.
PS: Data query adopted from here
Upvotes: 0
Reputation: 675
The data type of the properties column in the _ag_label_vertex and _ag_label_edge is agtype
. The primary key for these tables is the id
column which is the unique not null value given to each vertex, edge. Moreover, the properties are not stored in any other database and there is no foreign key constraint on the table as you can confirm by
\d "<enter_graph_name_here>"._ag_label_edge;
or
\d "<enter_graph_name_here>"._ag_label_vertex;
These won't output any foreign key constraints but only b-tree index made on the PRIMARY KEY id
Upvotes: 1