OCI Graph Studio is a managed property graph environment inside Oracle Autonomous Database. It converts relational tables into a graph model, executes PGQL traversal queries and graph algorithms, and visualizes results in a browser-based notebook. No separate graph database to provision and operate. This post covers creating a financial transaction graph, writing PGQL queries for fraud ring detection, and running centrality algorithms.
Step 1: ADB with Graph Studio
resource "oci_database_autonomous_database" "graph_adb" {
compartment_id = var.compartment_id
db_name = "GRAPHDB"
display_name = "graph-analytics-database"
db_workload = "OLTP"
db_version = "23ai"
compute_model = "ECPU"
compute_count = 8
data_storage_size_in_tbs = 2
is_auto_scaling_enabled = true
is_access_control_enabled = true
whitelisted_ips = [var.app_subnet_cidr]
subnet_id = var.private_subnet_id
is_mtls_connection_required = true
admin_password = var.adb_admin_password
defined_tags = { "Operations.Environment" = "production", "Operations.ManagedBy" = "terraform" }
}
output "graph_studio_url" {
value = oci_database_autonomous_database.graph_adb.connection_urls[0].graph_studio_url
}
Graph Model and PGQL Queries
Graph Studio converts relational tables into a property graph by declaring which tables are vertices and which are edges. The schema definition runs inside the database and creates a graph representation that PGQL queries and algorithms operate against. Creating the graph with OPTIONS (PG_VIEW) creates a logical view over the relational tables without copying data, so queries always read current table rows.
A common fraud detection pattern is finding transaction cycles: money that moves from account A to B to C and returns to A within a short time window. In SQL this requires multiple self-joins of the transactions table with complex date conditions. In PGQL it is a path traversal expressed as a pattern: (a1) -[t1]-> (a2) -[t2]-> (a3) -[t3]-> (a1). The database evaluates the traversal using the graph index, which is significantly faster than repeated self-joins for deep traversals.
Graph algorithms built into Graph Studio include PageRank for identifying high-influence nodes, Louvain community detection for finding clusters of tightly connected accounts, Betweenness Centrality for identifying bridge accounts that channel many transactions, triangle counting for measuring local network density, and Shortest Path for tracing the minimum-hop route between any two accounts. These algorithms run as in-database operations without data leaving Autonomous Database.
Step 2: Performance Alarm
resource "oci_monitoring_alarm" "graph_adb_cpu" {
compartment_id = var.compartment_id
display_name = "graph-adb-cpu-high"
is_enabled = true
metric_compartment_id = var.compartment_id
namespace = "oci_autonomous_database"
query = "CpuUtilization[5m]{databaseId = 'GRAPH_ADB_OCID'}.mean() > 85"
severity = "WARNING"
pending_duration = "PT10M"
destinations = [var.ops_notification_topic_id]
body = "Graph analytics ADB CPU above 85%. Graph algorithm jobs may be consuming excess resources. Review active PGX sessions."
}
Operational Notes
Graph Studio is accessible from the ADB Tools URL in the console or via the graph_studio_url output. Access requires a database user with the GRAPH_DEVELOPER or GRAPH_ADMINISTRATOR role. The interface provides a visual query builder for PGQL, a notebook for running queries and algorithms, and visualization tools for rendering interactive node-link diagrams where you can explore connected clusters visually.
In-memory graph algorithms (PageRank, community detection) operate on a snapshot loaded into PGX memory at graph load time. The in-memory graph does not automatically reflect changes to the underlying relational tables after loading. For analytics that need fresh data, reload the graph from the relational source before running the algorithm. PG_VIEW graphs always read live data but are slower for complex traversals than in-memory representations.
Regards,
Osama
#OCI #OracleCloud #GraphStudio #PropertyGraph #PGQL #TechBlog #Oracle #DataScience #GraphAnalytics #FraudDetection #OracleCloudInfrastructure #AutonomousDatabase #NetworkAnalysis #GraphAlgorithm #PageRank #CommunityDetection #DataEngineering #23ai #Analytics #Cyberfraud
Leave a comment