2.3.1 Getting Started with Semantic Data in Oracle Autonomous Database

This tutorial describes how you can quickly get started with RDF data in Autonomous database.

You can run the SQL statements in the steps through one of the following options:
  1. Connect to your autonomous database as a user with administrative privileges and create a network owner user.
    CREATE USER rdfuser
    IDENTIFIED BY <password-for-rdfuser>
    QUOTA 5G ON DATA;

    Note:

    If you are using Database Actions, you must REST Enable the user in order to enable the new user to access Database Actions. See Create User for more details.
  2. Grant the required privileges to the newly created network owner user.
    You must be connected as a user with administrative privileges to run the following statement:
    GRANT CONNECT, RESOURCE, CREATE VIEW TO rdfuser;

    Note:

    If you are using Database Actions to create the new user in the preceding step, the CONNECT and the RESOURCE privileges are provided by default. Hence, you must only grant the CREATE VIEW privilege to the new user.
  3. Connect as the network owner user.
    CONNECT rdfuser/<password-for-rdfuser>
  4. Create a semantic network by calling SEM_APIS.CREATE_SEM_NETWORK.

    You must create a semantic network as the intended owner of the schema-private network on the tablespace DATA.

    The following example creates a schema-private semantic network named net1 owned by network owner user rdfuser using the DATA tablespace.

    EXECUTE SEM_APIS.CREATE_SEM_NETWORK('DATA', network_owner=>'rdfuser', network_name=>'net1');
  5. Create a model by calling SEM_APIS.CREATE_SEM_MODEL.
    The following example creates a model named articles in the net1 schema-private network.
    EXECUTE SEM_APIS.CREATE_SEM_MODEL('articles', NULL, NULL, network_owner=>'rdfuser', network_name=>'net1');
    
  6. Insert triples into the model.
    You can insert triples into your model using the SQL INSERT statement. For example:
    INSERT INTO rdfuser.net1#rdft_articles(triple) VALUES (
      SDO_RDF_TRIPLE_S ('articles','<http://nature.example.com/Article1>',
        '<http://purl.org/dc/elements/1.1/title>','"All about XYZ"',
        network_owner=>'RDFUSER', network_name=>'NET1'));
    
    INSERT INTO rdfuser.net1#rdft_articles(triple) VALUES (
      SDO_RDF_TRIPLE_S ('articles','<http://nature.example.com/Article1>',
        '<http://purl.org/dc/elements/1.1/creator>','"Jane Smith"',
        network_owner=>'RDFUSER', network_name=>'NET1'));
    
    INSERT INTO rdfuser.net1#rdft_articles(triple) VALUES (
      SDO_RDF_TRIPLE_S ('articles',
        '<http://nature.example.com/Article1>',
        '<http://purl.org/dc/terms/references>',
        '<http://nature.example.com/Article2>',
        network_owner=>'RDFUSER', network_name=>'NET1'));
    
    INSERT INTO rdfuser.net1#rdft_articles(triple) VALUES (
      SDO_RDF_TRIPLE_S ('articles','<http://nature.example.com/Article2>',
        '<http://purl.org/dc/elements/1.1/title>','"A review of ABC"',
        network_owner=>'RDFUSER', network_name=>'NET1'));
    
    INSERT INTO rdfuser.net1#rdft_articles(triple) VALUES (
      SDO_RDF_TRIPLE_S ('articles','<http://nature.example.com/Article2>',
        '<http://purl.org/dc/elements/1.1/creator>','"Joe Bloggs"',
        network_owner=>'RDFUSER', network_name=>'NET1'));
    
    INSERT INTO rdfuser.net1#rdft_articles(triple) VALUES (
      SDO_RDF_TRIPLE_S ('articles',
        '<http://nature.example.com/Article2>',
        '<http://purl.org/dc/terms/references>',
        '<http://nature.example.com/Article3>',
        network_owner=>'RDFUSER', network_name=>'NET1'));
  7. Execute SPARQL queries on the inserted data using RDF Graph Server and Query UI.

    See Deploying RDF Graph Server and Query UI from Oracle Cloud Marketplace to launch the RDF Query UI application.

    You can query the inserted data by running SPARQL queries on the SPARQL query page in RDF Graph Query UI.

    Figure 2-1 Running SPARQL Query in RDF Graph Query UI

    Running SPARQL Query in RDF Query UI

    Alternatively, you can also execute SPARQL queries using SPARQL editor in SQL Developer in a dedicated Autonomous Database deployment. But if you are using Autonomous Database in a shared deployment, then the SPARQL editor is only supported in SQL Developer 21.2 or later. See Connect with Oracle SQL Developer for creating a connection to your autonomous database using Cloud Wallet.