Oracle Database includes an enterprise-grade Resource Description Framework (RDF) triplestore as part of the Spatial and Graph option. RDF is a W3C-standard graph data model for representing knowledge graphs, which are increasingly used to underpin intelligent applications.
This is part 1 of a blog series that shows how to setup a fully-functioning RDF triplestore on the Oracle Public Cloud. In part 1, we will show how configure Oracle Spatial and Graph – RDF Semantic Graph on an existing Oracle Database Cloud Service (DBCS) instance. In this example, we will use Oracle Database version 18.1. For more information on how to create a DBCS instance, refer to the tutorial here or download the detailed HOW-TO document at the end of this blog. Subsequent posts in this blog series will show how to load a publicly-available RDF dataset and configure a W3C-standard SPARQL endpoint.
We will use Oracle SQL Developer for most of our interaction with the DBCS instance. Starting with version 18.1, SQL Developer includes a nice RDF Semantic Graph plugin that we will use in this blog post.
First, use SQL Developer to open a connection to your DBCS instance for the SYSTEM user. There are several ways to connect to a DBCS instance with SQL Developer. Refer to the Database Cloud Service user guide for more information on connecting with SQL Developer.
Use a SQL Worksheet for your SYSTEM connection to execute the following query to check the RDF Semantic Graph installation on your DBCS instance.
SELECT * FROM MDSYS.RDF_PARAMETER;
The query result should show a valid 18.104.22.168.0 installation of RDF Semantic Graph.
Next, we will create a Semantic Network to prepare the database for storing RDF data. As a prerequisite, we need to create a tablespace for the Semantic Network. Run the following SQL statement as SYSTEM to create a tablespace for the Semantic Network.
create bigfile tablespace rdftbs datafile '?/dbs/rdftbs.dat'
size 512M reuse autoextend on next 512M maxsize 10G
extent management local
segment space management auto;
Now we can use the RDF Semantic Graph component of SQL Developer to create the Semantic Network. Expand the system connection by clicking the plus sign next to the connection name, and then scroll down to the RDF Semantic Graph component. Right-click on RDF Semantic Graph and select Create Semantic Network.
Use the drop down menu to select the tablespace that we created earlier and click Apply.
That’s it. We have verified the RDF Semantic Graph installation and created all the necessary database objects needed to store RDF data.
Next, we will make some changes to the default index configuration for better general-purpose query performance. Expand Network Indexes under RDF Semantic Graph to see index codes for the current network indexes. Each letter in an index code corresponds to a component of an RDF quad: S – subject, P – predicate, C – canonical object, G – graph, M – model. By default, two indexes are created: a mandatory PCSGM unique index and a PSCGM index. This indexing scheme works very well when SPARQL triple patterns have constants in the predicate position, but this scheme may encounter performance problems if variables appear in the predicate position.
For a more general scheme, a three-index combination of PCSGM, SPCGM and CPSGM works well, so we will drop the PSCGM index and add SPCGM and CPSGM indexes.
Right click on RDF_LNK_PSCGM_IDX and select Drop Semantic Index.
Only the PCSGM index should appear under Network Indexes now.
Right click on Network Indexes and select Create Semantic Index.
Enter SPCGM as the Index code and click Apply.
Next, repeat this process using CSPGM as the index code.
You should now see CSPGM, PCSGM and SPCGM indexes under Network Indexes.
At this point, we have created a semantic network on our DBCS instance and setup an indexing scheme for general-purpose SPARQL queries. Our DBCS instance is now ready to load some RDF data. The next blog post in this series will show how to load and query a publicly-available RDF dataset.
A detailed HOW TO document for this blog series is available HERE.