1.6 RDF Data Types, Constructors, and Methods
The SDO_RDF_TRIPLE_S object type is used for representing the edges (that is, triples and quads) of RDF graphs.
The SDO_RDF_TRIPLE_S object type (the _S for storage) stores persistent RDF data in the database.
The SDO_RDF_TRIPLE_S type has references to the data, because the actual RDF data is stored only in the central RDF schema. This type has methods to retrieve the entire triple or part of the triple.
Note:
Blank nodes are always reused within an RDF graph and cannot be reused across graphs.The SDO_RDF_TRIPLE_S type is used to store the triples in database tables.
The SDO_RDF_TRIPLE_S object type has the following attributes:
SDO_RDF_TRIPLE_S ( RDF_C_ID NUMBER, -- Canonical object value ID RDF_M_ID NUMBER, -- Model (or Model-Graph) ID RDF_S_ID NUMBER, -- Subject value ID RDF_P_ID NUMBER, -- Property value ID RDF_O_ID NUMBER) -- Object value ID
The SDO_RDF_TRIPLE_S type has the following methods that retrieve the name of the RDF graph (or model-graph), or a part (subject, property, or object) of a triple:
GET_MODEL( NETWORK_OWNER VARCHAR2 DEFAULT NULL, NETWORK_NAME VARCHAR2 DEFAULT NULL) RETURNS VARCHAR2 GET_SUBJECT( NETWORK_OWNER VARCHAR2 DEFAULT NULL, NETWORK_NAME VARCHAR2 DEFAULT NULL) RETURNS VARCHAR2 GET_PROPERTY( NETWORK_OWNER VARCHAR2 DEFAULT NULL, NETWORK_NAME VARCHAR2 DEFAULT NULL) RETURNS VARCHAR2 GET_OBJECT( NETWORK_OWNER VARCHAR2 DEFAULT NULL, NETWORK_NAME VARCHAR2 DEFAULT NULL) RETURNS CLOB GET_OBJ_VALUE( NETWORK_OWNER VARCHAR2 DEFAULT NULL, NETWORK_NAME VARCHAR2 DEFAULT NULL) RETURNS VARCHAR2
Example 1-9 shows some of the SDO_RDF_TRIPLE_S methods.
Example 1-9 SDO_RDF_TRIPLE_S Methods
-- Find all articles that reference Article2. SELECT a.triple.GET_SUBJECT('RDFUSER','NET1') AS subject FROM RDFUSER.NET1#RDFT_ARTICLES a WHERE a.triple.GET_PROPERTY('RDFUSER','NET1') = '<http://purl.org/dc/terms/references>' AND a.triple.GET_OBJ_VALUE('RDFUSER','NET1') = '<http://nature.example.com/Article2>'; SUBJECT -------------------------------------------------------------------------------- <http://nature.example.com/Article1> -- Find all triples with Article1 as subject. SELECT a.triple.GET_SUBJECT('RDFUSER','NET1') AS subject, a.triple.GET_PROPERTY('RDFUSER','NET1') AS property, a.triple.GET_OBJ_VALUE('RDFUSER','NET1') AS object FROM RDFUSER.NET1#RDFT_ARTICLES a WHERE a.triple.GET_SUBJECT('RDFUSER','NET1') = '<http://nature.example.com/Article1>'; SUBJECT -------------------------------------------------------------------------------- PROPERTY -------------------------------------------------------------------------------- OBJECT -------------------------------------------------------------------------------- <http://nature.example.com/Article1> <http://purl.org/dc/elements/1.1/title> "All about XYZ" <http://nature.example.com/Article1> <http://purl.org/dc/elements/1.1/creator> "Jane Smith" <http://nature.example.com/Article1> <http://purl.org/dc/terms/references> <http://nature.example.com/Article2> <http://nature.example.com/Article1> <http://purl.org/dc/terms/references> <http://nature.example.com/Article3 -- Find all objects where the subject is Article1. SELECT a.triple.GET_OBJ_VALUE('RDFUSER','NET1') AS object FROM RDFUSER.NET1#RDFT_ARTICLES a WHERE a.triple.GET_SUBJECT('RDFUSER','NET1') = '<http://nature.example.com/Article1>'; OBJECT -------------------------------------------------------------------------------- "All about XYZ" "Jane Smith" <http://nature.example.com/Article2> <http://nature.example.com/Article3> -- Find all triples where Jane Smith is the object. SELECT a.triple.GET_SUBJECT('RDFUSER','NET1') AS subject, a.triple.GET_PROPERTY('RDFUSER','NET1') AS property, a.triple.GET_OBJ_VALUE('RDFUSER','NET1') AS object FROM RDFUSER.NET1#RDFT_ARTICLES a WHERE a.triple.GET_OBJ_VALUE('RDFUSER','NET1') = '"Jane Smith"'; SUBJECT -------------------------------------------------------------------------------- PROPERTY -------------------------------------------------------------------------------- OBJECT -------------------------------------------------------------------------------- <http://nature.example.com/Article1> <http://purl.org/dc/elements/1.1/creator> "Jane Smith"
Parent topic: RDF Graph Overview
1.6.1 Constructors for Inserting Triples
The following constructor formats are available for inserting triples into a model table. The only difference is that in the second format the data type for the object is CLOB, to accommodate very long literals.
SDO_RDF_TRIPLE_S ( model_name VARCHAR2, -- Model name subject VARCHAR2, -- Subject property VARCHAR2, -- Property object VARCHAR2, -- Object network_owner VARCHAR2 DEFAULT NULL, network_name VARCHAR2 DEFAULT NULL) RETURN SELF; SDO_RDF_TRIPLE_S ( model_name VARCHAR2, -- Model name subject VARCHAR2, -- Subject property VARCHAR2, -- Property object CLOB, -- Object network_owner VARCHAR2 DEFAULT NULL, network_name VARCHAR2 DEFAULT NULL) RETURN SELF;
Example 1-10 uses the first constructor format to insert several triples.
Example 1-10 SDO_RDF_TRIPLE_S Constructor to Insert Triples
INSERT INTO RDFUSER.NET1#RDFT_ARTICLES VALUES ( SDO_RDF_TRIPLE_S ('articles','<http://nature.example.com/Article1>', '<http://purl.org/dc/elements/1.1/creator>', '"Jane Smith"', 'RDFUSER', 'NET1')); INSERT INTO RDFUSER.NET1#RDFT_ARTICLES VALUES ( SDO_RDF_TRIPLE_S ('articles:<http://examples.com/ns#Graph1>', '<http://nature.example.com/Article102>', '<http://purl.org/dc/elements/1.1/creator>', '_:b1', 'RDFUSER', 'NET1')); INSERT INTO RDFUSER.NET1#RDFT_ARTICLES VALUES ( SDO_RDF_TRIPLE_S ('articles:<http://examples.com/ns#Graph1>', '_:b2', '<http://purl.org/dc/elements/1.1/creator>', '_:b1', 'RDFUSER', 'NET1'));
Parent topic: RDF Data Types, Constructors, and Methods