Fourth Quarterly Update on Oracle Graph (2023)

October 27, 2023 | 4 minute read
Rahul Tasker
Senior Product Manager
Text Size 100%:

The graph features of Oracle Database enables developers to store and navigate relationships between entities. Oracle Graph Server and Client enables developers, analysts, and data scientists to use graphs within Oracle Database, while Graph Studio in Oracle Autonomous Database removes barriers to entry by automating setup and management, automating graph creation, and by providing step-by-step examples for getting started.

The last quarterly update on Oracle Graph, announced the availability of Oracle Graph Server and Client 23.3. That release focused on a new REST API, along with updates to graph visualization, PGQL, and RDF Server.

Oracle Graph Server and Client 23.4 is now available for download for use with databases in the Cloud (OCI Marketplace image is available) and for databases on-premises. In this release we introduce a PGQL function to validate the vertices and edges of a graph when primary and foreign key constraints are not present, and a PGQL function to aggregate values into a JSON array. We also introduce the ability to create a new graph from an existing one, along with some additional notable features listed at the end of this article.


PGQL Validate Function

This built-in function checks if vertex/edge keys are unique, and if the source and destination vertices exist for every edge. This is useful when you cannot, or do not want to, create primary and/or foreign key constraints. This function throws a descriptive error message if it detects a problem, such as a ‘dangling’ edge (an edge with a vertex that does not exist in the vertex table). Here is an example of how you can use this function:

pgqlStmnt.execute("CALL pg.validate('MY_GRAPH')");
pgqlStmnt.execute("CALL pg.validate('OTHER_USER', 'THEIR_GRAPH')");

PGQL validate function example

 

New JSON_ARRAYAGG Function

JSON_ARRAYAGG is a SQL function added to PGQL when it executes in the database, which aggregates values into a JSON array. This is very useful when you want group results of a pattern matching query in a JSON array. In the following example, we can use the JSON_ARRAYAGG function to group friends of each person in our graph.

JSON_ARRAYAGG Function

You can also use various JSON_ARRAYAGG options, such as using the order by clause and returning clause to specify the order of the resulting array and the datatype returned by the function.

JSON_ARRAYAGG Function returning Varchar

 

 

Create New Graph from Existing Graph

This release includes the ability to create a new graph from existing graphs (referred to as “base graphs” in the CREATE PROPERTY GRAPH syntax). This feature is especially useful to create new graphs that offer a different perspective using multiple base graphs.  As with all property graphs the source data is not duplicated, only metadata from the base graphs is copied into the metadata tables for the new graph.  Following the syntax from the example below, you can create a new graph based on existing graphs.

CREATE PROPERTY GRAPH financial_transactions
      BASE GRAPHS (
            bank_transactions,
            social_network ALL ELEMENT TABLES EXCEPT ( knows ) )
      EDGE TABLES (
            Accounts AS PersonOwner
                  SOURCE KEY( "number" ) REFERENCES Accounts ( "number" )
                  DESTINATION Persons
                  LABEL owner NO PROPERTIES,
            Accounts AS CompanyOwner
                  SOURCE KEY( "number" ) REFERENCES Accounts ( "number" )
                  DESTINATION Companies
                   LABEL owner NO PROPERTIES )
      OPTIONS ( PG_PGQL )

Create New Graph from Existing Graph

 

Other notable updates

  • The PGQL KEEP clause provides a syntactic alternative to the preexisting path pattern prefix.
    • New: MATCH <path pattern> KEEP <path pattern prefix> <where clause>
    • Old:   MATCH <path pattern prefix> <path pattern> <where clause>

PGQL Keep Clause

  • In Oracle Database 23c, the SOURCE/DESTINATION predicate can be used to test whether a vertex is a source/destination of an edge. Returns a Boolean value.
    • For older databases, the legacy is_source_of/ is_destination_of functions can be used, which return strings ‘y’/‘n’ (Boolean return value is not supported)
  • RDF Server now supports rulebase names and allows configuration of CLOB prefetch size.
  • RPM installations of Oracle Graph can be upgraded from 23.3 using rpm -U. Using this method all changes to pgx.conf files, log files and keystores will be preserved. If the upgrade adds a new config field, pgx.conf.rpmnew will be created

For more information, please visit our Property Graph documentation and RDF Graph documentation.

 

Rahul Tasker

Senior Product Manager

Product Manager for Oracle Spatial and Graph


Previous Post

Learn about Oracle Text

Roger Ford | 2 min read

Next Post


Powering Network Topology Planning and Administration with Oracle Graph

Melliyal Annamalai | 3 min read