Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-15745

Add the previous linked node in the graph query

    XMLWordPrintable

Details

    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.

      Attachments

        Activity

          People

            Unassigned Unassigned
            mreiche Mike Reiche
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.