Graph Databases: Unlock the magic
Show me your data structures, and I won’t usually need your code; it’ll be obvious — Fred Brooks.
That is how important your data structures are. How we lay down the data could make it easy to write and/or read. It also works in the other direction; you can make writing and reading very difficult if your data structures are not a great fit for your scenario.
I’ve been working on financial services, where I discovered how vital fraud detection was. And how difficult it is to do it if you use just SQL and a relational database. I was a victim of Maslow’s hammer bias: if all you have is a hammer, everything looks like a nail.
Let’s do it the right way. Property Graph Query Language is a nice tool for the job. It is an open-source language for Graphs. Instead of joining tables to resolve relationships, in PGQL, the relationship is the king. You can declare the relationships you want to follow filtering by labels; you also can declare the graph reachability (transitive closure) and get the shortest and cheapest path findings. I am done with the “theory”!
Try it out
You can try it out in just a few minutes — no need to install or configure anything on your computer. Create an Oracle Autonomous Database for free on Oracle Cloud.
Do you have an Oracle Cloud Account? If not, you can create one here:
Remember, Oracle Cloud does not charge you anything unless you explicitly request the upgrade to pay as you go. No problem.
Create the free Autonomous Database as I do in the video; also, you can get familiar with SQL Developer Web, but we are not going to use it in the article:
The next step is to provision a virtual machine with Graph Client and Server. Oracle Graph is a two-tier deployment. However, you can have a three-tier deployment the client connect to the server and the server to PGX (In-Memory graph and nice API for languages like Python or Java). The client-side, in any case, allows you to run queries and have a powerful visualization of the results.
Go to your Cloud Console. Navigate to the Marketplace tab and enter “Graph Server and Client” in the search bar. Click on the Oracle Graph Server and Client stack.
On the creation process, you will need the JDBC URL. Something like this:
My Autonomous Database is called graph, so the connection string should be graph_low, as you can see on the line above. Check tnsnames.ora file on your wallet if you have doubts.
Make sure you download your Autonomous Database Wallet with:
scp -i SSH_KEY_PATH PATH_TO_YOUR_WALLET_ZIP opc@PUBLIC_IP:/home/opc
Don’t forget to unzip it with:
unzip Wallet_graph.zip -d wallet
Then move it to the final destination
Time to enjoy it!
Think about use-cases you might be interested in:
- Identifying influencers in a social network
- Predicting trends and customer behaviour
- Discovering relationships based on pattern matching
- Identifying clusters to customize campaigns
I invite you to learn more about In-Memory Graph Server, also know as PGX. PGX is the in-memory graph layer that enables you to analyze property graphs using parallel in-memory execution. More speed, more complex queries = more fun!
Want to learn more?
If you like what you’re reading and interested in taking on some of these challenges with our team, do check out our free training sessions on many topics like Spatial and Graph, Document database, APEX, Digital Assitant, etc. The next event is
There are periodic free training sessions, around 1 hour long, done by experts and Oracle Cloud Advocates. These are instructor-led training. You can follow along with our team to solve your questions on the spot.
Join me on Oracle Cloud Infrastructure Discord Channel for any question.
And keep tuned for more articles about the amazing things you can build with Oracle Cloud.
I am Victor Martin, a Software Developer. I deploy on Oracle Cloud Infrastructure.
Feel free to get connected with me on LinkedIn.
I am also interested in Scuba diving and space engineering. Happy to help, everything is easier than rocket science!