[MDEV-15745] Add the previous linked node in the graph query Created: 2018-03-31  Updated: 2018-04-16

Status: Open
Project: MariaDB Server
Component/s: Storage Engine - OQGRAPH
Fix Version/s: None

Type: Task Priority: Trivial
Reporter: Mike Reiche Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None


 Description   

As described in the example documentation: https://mariadb.com/kb/en/library/oqgraph-examples/

I find it very useful to add the previous linked node in the sequence result when querying the graph:

SELECT * FROM oq_graph g
WHERE g.latch='dijkstras' AND g.origid=1;

latch origid destid weight seq linkid previd
dijkstras 1 NULL 4 6 5 4
dijkstras 1 NULL 3 5 4 3
dijkstras 1 NULL 2 4 6 2
dijkstras 1 NULL 2 3 3 2
dijkstras 1 NULL 1 2 2 1
dijkstras 1 NULL 0 1 1 NULL

That helps to implement relationship types and restrict them in the query like:

SELECT * FROM people_graph g
JOIN people_relationships d ON d.destid = g.linkid AND d.origid = g.previd
WHERE g.latch='dijkstras'
AND g.origid=1
AND d.relationship='friendship';

Which only shows friends and friends of friends, but no family members.



 Comments   
Comment by Mike Reiche [ 2018-04-16 ]

Can anyone tell me please, if this issue is relevant or I'm missing something?

Generated at Thu Feb 08 08:23:42 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.