Graph databases are built to store and navigate relationships between entities and are a part of Oracle’s converged database offering. Oracle provides support for both property and RDF knowledge graphs, and simplifies the process of modeling relational data as graph structures. Interactive graph queries can run directly on graph data or in a high-performance in-memory graph server. 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 complicated setup and management, making data integration seamless, and by providing step-by-step examples for getting started.
Graphs require a syntax for queries to specify the patterns in the graph. This syntax is called Property Graph Query Language (PGQL), and in this release of Oracle Graph Server and Client, we have made updates that align PGQL with the SQL/PGQ standard. With these updates, anyone familiar with SQL can easily write more intricate graph queries than ever before.
Oracle Graph Server and Client 22.4 is the first release to fully implement PGQL 1.5. You can find this specification here. These PGQL updates include the ability to use IS as an alternative for a colon, support for scalar subqueries, and support for EXISTS and NOT EXISTS subqueries. Additionally, there are new PGX features available that allow developers to gain deeper insights into the status of their graph in Graph Server, and sychronize graphs that have been published to share updates with other team members. This release also includes some packaging enhancements, which can be found at the end of this post. Oracle Graph Server and Client 22.4 is available for download for use with databases in the Cloud (OCI Marketplace image is available) and for databases on-premises. The new features described here are also available in Graph Studio.
In previous versions of Oracle Graph, a colon (:) was used to indicate label predicates. To include syntax in the SQL/PGQ standard (the draft ISO standard for SQL to query property graphs), the newest version of Oracle Graph now supports “IS” as a label predicate. However, this feature is additive, and does not remove the ability to use a colon as a label predicate.
This is an example of the label predicate options in 22.4:
//Before FROM MATCH (s:Friend) -[e:knows]-> (d:Person) //Starting 22.4 the following is supported GROM MATCH (s IS Friend) -[e IS knows]-> (d IS Person)
Oracle Graph Server and Client 22.4 allows you to use scalar subqueries in PG views. You can use them as part of an expression. A scalar query is a query that returns a scalar value, exactly one row and exactly one column. In this latest release of Oracle Graph, you can use scalar queries as part of an expression in a SELECT, WHERE, GROUP BY, HAVING or ORDER BY clause.
For example, you could write a query such as the following:
SELECT p.name AS name , ( SELECT SUM(t.amount) FROM MATCH (a) <-[t:transaction]- (:Account) ) AS sum_incoming , (SELECT SUM(t.amount) FROM MATCH (a) -[t:transaction]-> (:Account) ) AS sum_outgoing , (SELECT COUNT(DISTINCT p2) FROM MATCH (a) -[t:transaction]-> (:Account) -[:owner]-> (p2:Person) WHERE p2 <> p ) AS num_persons_transacted_with , (SELECT COUNT(DISTINCT c) FROM MATCH (a) -[t:transaction]-> (:Account) -[:owner]-> (c:Company) ) AS num_companies_transacted_with FROM MATCH (p:Person) <-[:owner]-> (a:Account) ORDER BY sum_outgoing + sum_incoming DESC
EXISTS and NOT EXISTS return true or false depending on whether the subquery produces at least one result, given the bindings obtained from the outer query.
In the following example, we can query to find friends of friends, and for each friend of friend, return the number of common friends. Assuming we have a graph that shows relationships among a group of people, we can do this simply with a NOT EXISTS subquery:
SELECT fof.name, COUNT(friend) AS num_common_friends FROM MATCH (p:Person) -[knows]-> (friend:Person) -[knows]-> (fof:Person) WHERE NOT EXISTS ( SELECT * FROM MATCH (p) -[:knows]-> (fof) )
Oracle Graph Server 22.4 includes a new API added to PgxFuture that retrieves loading progress. This feature works with PG view graphs.
This is an example of how the progress reporting API can be used:
PgxFuture<PgxGraph> future = session.readGraphByNameAsync("MYGRAPH", GraphSource.PG_VIEW) FutureProgress progress = future.getProgress() // new API Optional<GraphLoadingProgress> loadingProgress = progress.asGraphLoadingProgress() long numLoadedVertices = loadingProgress.get().getLoadedVertices()
Previously, a subgraph was given the same name as the PG view plus a number. However, the load() function now accepts a name as a parameter. Additionally, the query for the subgraph now allows for any-directed edge patterns.
This is an example of how these features can be used when creating a subgraph:
PgxGraph subgraph = session.readSubgraph() .fromPgView("MYGRAPH") .queryPgql("MATCH (s)-[e]-(d)") // NEW: any-directed pattern .load("MYSUBGRAPH") // NEW: name the resulting subgraph
Published graphs in the Graph Server (an application can ‘publish’ graphs to share with other sessions connected to the Graph Server) can now be synchronized with updates in the database. Previously only graphs within a session could be synchronized. This is enabled by using the new API to specify the graph configuration object when creating a synchronizer object.
This is an example of how the graph configuration can be included in the synchronizer call:
Synchronizer synchronizer = new Synchronizer.Builder<FlashbackSynchronizer>() .setType(FlashbackSynchronizer.class) .setGraph(graph) .setGraphConfig(graphConfig) // NEW .setConnection(connection) .build()
Oracle Linux 6 and Apache HBase support are desupported in this release.
For more information, please visit our documentation. Please try it out!
Product Manager for Oracle Spatial and Graph