Title: Corporate PPT Template
1This presentation is for informational purposes
only and may not be incorporated into a contract
or agreement.
2RDF Support in Oracle RDBMS
Oracle New England Development Center
3Talk Outline
- Introduction
- Resource Description Framework (RDF)
- Querying RDF data
- RDF Support in Oracle 10g Release 2
- Overview
- Querying
- Inference
- Operations (loading, DDL, DML, Security)
4Resource Description Framework (RDF)
5RDF Graph
- Types of elements URIs, Blank Nodes, and
Literals - URIs http//www.oracle.com/peopleJohn
- Blank Nodes _r1
- Plain Literals John, color_at_en-us
- Typed Literals 16xsdint, Johnxsdstring
- RDF Triples ltsubject predicate objectgt
- Subject URIs or Blank Nodes
- Predicate URIs
- Objects URIs, Blank Nodes, or Literals
- A set of RDF triples constitute an RDF graph
6Family Schema
Male
fatherOf
brotherOf
siblingOf
Person
parentOf
motherOf
sisterOf
Female
rdfssubClassOf
rdfsrange
rdfsdomain
rdfssubPropertyOf
7RDF Graph Example
- Family Classes and Properties
- (Male rdfssubClassOf Person)
- (Female rdfssubClassOf Person)
- (fatherOf rdfssubPropertyOf parentOf)
- (motherOf rdfssubPropertyOf parentOf)
- (brotherOf rdfssubPropertyOf siblingOf)
- (sisterOf rdfssubPropertyOf siblingOf)
8RDF Graph Example
- Family Domains and Ranges of Properties
- (fatherOf rdfsdomain Male)
- (fatherOf rdfsrange
Person) - (motherOf rdfsdomain Female)
- (motherOf rdfsrange Person)
- (brotherOf rdfsdomain Male)
- (brotherOf rdfsrange Person)
- (sisterOf rdfsdomain Female)
- (sisterOf rdfsrange
Person)
9Family Data
Janice
John
Martha
Matt
Suzie
Sammy
Cindy
Tom
Jack
Cathy
Female
Male
fatherOf
motherOf
rdftype
sisterOf
10RDF Graph Example
- Family Data
- (John fatherOf Suzie)
- (John fatherOf Matt)
- (Janice motherOf Suzie)
- (Janice motherOf Matt)
- (Sammy fatherOf Cathy)
- (Sammy fatherOf Jack)
- (Suzie motherOf Cathy)
- (Suzie motherOf Jack)
Family Data (Matt fatherOf
Tom) (Matt fatherOf Cindy) (Martha
motherOf Tom) (Martha motherOf
Cindy) (Jack rdftype Male) (Tom
rdftype Male) (Cindy rdftype
Female)
11Querying RDF data
12RDF Querying Problem
- Given
- An RDF dataset (graphs) to be searched
- A graph-pattern containing a set of variables
- Find
- Subgraphs that match the graph-pattern
- Return
- Sets of variable bindings
- each set corresponds to a matching subgraph
(substitution in graph-pattern produces subgraph)
13RDF Query Example
- Graph-pattern Find
- ltgrandpa, parent, grandchildgt
- (?x fatherOf ?y)
- (?y parentOf ?z)
- Bindings
- x John y Suzie z Cathy
- x John y Suzie z Jack
- x John y Matt z Tom
- x John y Matt z Cindy
Matching subgraphs (John fatherOf
Suzie) (Suzie parentOf
Cathy) (John fatherOf
Suzie) (Suzie parentOf Jack) (John
fatherOf Matt) (Matt
parentOf Tom) (John fatherOf
Matt) (Matt parentOf Cindy)
14RDF Support in Oracle 10g R2
15Overview
- RDF Storage and Inference
- Model ? RDF graph consisting of a set of triples
- Rulebase ? Set of (user-defined) rules
- Rules Index ? Inferred triples
- RDF Query
- SDO_RDF_MATCH Table Function
16Components
Appl. Tables
Rulebase 1
Rulebase 2
Rulebase m
A1
Model 1
RDF Query
DDL Load DML
Rules Index 1
Rules Index 2
Model 2
A2
Rules Index p
An
Model n
17RDF Query
18RDF Querying Approach
- New language approach
- Create new (declarative, SQL-like) languages
e.g., RQL, SeRQL, TRIPLE, Versa, SPARQL, RDQL,
RDFQL, SquishQL - SQL-based approach
- Introduces a SQL table function SDO_RDF_MATCH
that accepts RDF queries - Benefits
- Leverage powerful constructs of SQL to process
RDF Query results - Combine with SQL queries without staging
19Embedding RDF Query in SQL
- SELECT
- FROM , TABLE (
- ) t,
- WHERE
RDF Query (expressed via SDO_RDF_MATCH invocation)
20SDO_RDF_MATCH Table Func
- Input Parameters
- SDO_RDF_MATCH (
- Query, ? graph-pattern (with variables)
- Models, ? set of RDF models
- Rulebases, ? set of rulebases (e.g., RDFS)
- Aliases, ? aliases for namespaces
- Filter ? additional selection criteria
- )
- Return type in definition is AnyDataSet
- Actual return type is determined at compile time
based on the arguments for each specific
invocation
21RDF Query Example
- select from TABLE(SDO_RDF_MATCH(
- '(?f rdftype Female)', -- find all
the females in the family - SDO_RDF_Models('family'),
- null,
- SDO_RDF_Aliases(
- SDO_RDF_Alias('', 'http//www.example.org/f
amily/')), - null))
- Table Function returns a two-column table
f varchar2
frdfVTYP varchar2
22SDO_RDF_MATCH Table Func
- Each returned row contains one (or more) of the
following - cols (of type VARCHAR2) for each variable ?x in
graph-pattern
23Query Projection Optimization
- select m from TABLE(SDO_RDF_MATCH(
- '(?m rdftype Male)',
- SDO_RDF_Models('family'),
- null,
- SDO_RDF_Aliases(
- SDO_RDF_Alias('', 'http//www.example.org/f
amily/')), - null))
- M
- --------------------------------------------------
------------------------------ - http//www.example.org/family/Jack
- http//www.example.org/family/Tom
- Table function returns a single-column table M
24Matching multiple representations of a value
- The same point in value space may have multiple
representations - 10xsdInteger
- 10xsdPositiveInteger
- 010xsdInteger
- 10.00xsddecimal
- SDO_RDF_MATCH automatically resolves these
25Join with SQL tables Example
- Find salary and hiredate of Matts grandfather(s)
- SELECT emp.name, emp.salary, emp.hiredateFROM
emp, TABLE(SDO_RDF_MATCH(
(?x fatherOf ?y)
(?y parentOf Matt)
(?x name ?name),
SDO_RDF_Models(family'),
)) tWHERE emp.namet.name
26Join Example 2
- Find pairs of persons residing at the same
address where the first person rents a truck and
the second person buys a fertilizer - SELECT t3.x name1, t3.y name2FROM AddrTable t1,
AddrTable t2, TABLE(SDO_RDF_MATCH(
'(?x rents ?a) (?a
rdftype Truck) (?y
buys ?b) (?b rdftype Fertilizer)',
SDO_RDF_Models('Activities,
Vehicles_ont, Chemicals_ont),
)) t3WHERE t1.namet3.x and t2.namet3.y
and t1.addrt2.addr
27Inference
28Components
Appl. Tables
Rulebase 1
Rulebase 2
Rulebase m
A1
Model 1
RDF Query
DDL Load DML
Rules Index 1
Rules Index 2
Model 2
A2
Rules Index p
An
Model n
29Rulebases
30Rulebase Overview
- Each rulebase consists of a set of rules
- Each rule consists of
- antecedent graph-pattern
- filter condition (optional)
- consequent graph-pattern
- One or more rulebases may be used with relevant
RDF models (graphs) to infer new data
31Rulebase Example
- Oracle supplied, pre-loaded rulebases e.g., RDFS
- rdfssubClassOf is transitive and reflexive
- Antecedent (?x rdftype ?y) (?y
rdfssubClassOf ?c) - Consequent (?x rdftype ?c)
- Antecedent (?x ?p ?y) (?p rdfsdomain ?c)
- Consequent (?x rdftype ?c)
- Rules in a rulebase family_rb
- Antecedent (?x parentOf ?y) (?y parentOf
?z) - Consequent (?x grandParentOf ?z)
32Rules Indexes
33Rules Index Overview
- A rules index is created on an RDF dataset
(consisting of a set of RDF models and a set of
RDF rulebases) - A rules index contains RDF triples inferred from
the model-rulebase combination
34Rules Index Example
- A rules index may be created on a dataset
consisting of - family RDF data, and
- family_rb rulebase (shown earlier)
- The rules index will contain inferred triples
showing grandParentOf relationship
35RDF Query with Inference
36SDO_RDF_MATCH with Rulebases
- Arguments
- Graph Pattern
- RDF Data set
- A set of RDF models
- A set of Rulebases
- Filters
- Aliases
- Example
- SDO_RDF_Rulebases (RDFS, Family_RB)
37Query w/ RDFSFamily Inference
- select x, y from TABLE(SDO_RDF_MATCH(
- '(?x grandParentOf ?y) (?x rdftype
Male)', - SDO_RDF_Models('family'),
- SDO_RDF_Rulebases('RDFS', 'family_rb'),
- SDO_RDF_Aliases(
- SDO_RDF_Alias('','http//www.example.org/fa
mily/')), - null))
- X Y
- --------------------------------------------------
---- ---------------------------------------------
-------- - http//www.example.org/family/John http//www.exam
ple.org/family/Cindy - http//www.example.org/family/John http//www.exam
ple.org/family/Tom - http//www.example.org/family/John http//www.exam
ple.org/family/Jack - http//www.example.org/family/John http//www.exam
ple.org/family/Cathy
38Operations
39Components
Appl. Tables
Rulebase 1
Rulebase 2
Rulebase m
A1
Model 1
RDF Query
DDL Load DML
Rules Index 1
Rules Index 2
Model 2
A2
Rules Index p
An
Model n
40RDF Model operations
41Model DDL
- Procedures provided as part of the API to
- Create a model
- Drop a model
- When a user creates a model, a database view gets
created automatically - RDFM_family
- A model corresponds to a column of type
SDO_RDF_TRIPLE_S in an application table - Each model has exactly one application table
column associated with it
42Model DDL ? Creating a Model
- Create an Application Table
- CREATE TABLE family_table (, family_triple
SDO_RDF_TRIPLE_S, ) - Create a Model
- exec SDO_RDF.CREATE_RDF_MODEL('family',
'family_table', 'family_triple') - Automatically creates a database view
- RDFM_family ()
43Loading RDF Data into Oracle
- Java API provided to load RDF data in NTriple
format
44Model DML
- SQL DML commands may be used to do DML operations
on a application table to effect DML (i.e.,
triple insert, delete, and update) on the
corresponding model - Insert Triples
- INSERT INTO family_table VALUES (1,
- SDO_RDF_TRIPLE_S(family',
- 'lthttp//example.org/family/Johngt',
- 'lthttp//example.org/family/fatherOfgt',
- lthttp//example.org/family/Suziegt'))
45Model Security
- The creator of the application table
corresponding to a model can grant privileges to
other users - To perform DML to a model, a user must have DML
privileges for the corresponding application
table - The creator of a model can grant SELECT
privileges on the corresponding database view to
other users - A user can query only those models for which s/he
has SELECT privileges (via corresponding DB
views) - Only the creator of a model can drop the model
46Model Views
- RDFM_ltmode-namegt
- Contains list of triples for an RDF model
47Rulebase operations
48Rulebase DDL
- Procedures provided as part of the API may be
used to - Create a rulebasecreate_rulebase('family_rb')
- Drop a rulebase
- drop_rulebase('family_rb')
- When a user creates a rulebase, a database view
gets created automatically - RDFR_family_rb (rule_name, antecedents,
filter, consequents, aliases)
49Rulebase DML
- SQL DML commands may be used on the database view
corresponding to a target rulebase to insert,
delete, and update rules - insert into mdsys.RDFR_family_rb values(
grandParent_rule', (?x parentOf ?y) (?y
parentOf ?z), NULL, '(?x grandParentOf
?z)', SDO_RDF_Aliases())
50Rulebase Security
- Creator of a rulebase can grant privileges on the
corresponding database view to other users - Performing DML operations requires invoker to
have appropriate privileges on the database view - Only the creator of a rulebase can drop the
rulebase
51Rulebase Views
- RDF_RULEBASE_INFO
- Contains the list of rulebases
- For each rulebase, contains additional
information (such as, creator, view name, etc) - RDFR_ltrulebase-namegt
- Shows content of each rulebase consisting of its
list of rules and for each rule, its name,
antecedents, filter, consequents, and aliases
52Rules Index operations
53Rules Index DDL
- Procedures provided as part of the API to
- Create a rules indexcreate_rules_index
('family_rb_rix_family, SDO_RDF_Models
('family'), SDO_RDF_Rulebases
(rdfs','family_rb')) - Drop a rules indexdrop_rules_index
('family_rb_rix_family') - When a user creates a rules index, a database
view gets created automatically - RDFI_family_rb_rix_family ()
54Rules Index Dependencies
- Content of a rules index depends upon the content
of each element of its dataset - Any modification to the models or rulebases in
its dataset invalidates the rules index - Insertion VALID ? INCOMPLETE
- Deletion/Update VALID ? INVALID
- Dropping a model or rulebase will drop dependent
rules indexes automatically.
55Rules Index Security
- To create a rules index on an RDF dataset (models
and rulebases), user needs to have SELECT
privileges on those models and rulebases - Creator of a rules index holds SELECT privilege
on the rules index and may grant this privilege
to other users - Only the creator of a rules index can drop it
56Rule Index Views
- RDFI_ltrules-index-namegt
- Contains the list of inferred triples
- RDF_RULESINDEX_INFO
- Contains the list of rules indexes
- For each rules index, contains additional
information (such as, creator, status, etc) - RDF_RULESINDEX_DATASETS
- For every rules index, contains the names of its
models and rulebases
57Summary
- Comprehensive, fully integrated into SQL RDF
support in Oracle 10g Release 2 - Models (Graphs)
- Rulebases
- Rules Indexes
- Query using SDO_RDF_MATCH table function
- Documentation and White Papers
- http//www.oracle.com/technology/tech/semantic_tec
hnologies/index.html
58A
59Query w/ RDFS Inference
- select m from TABLE(SDO_RDF_MATCH(
- '(?m rdftype Male)',
- SDO_RDF_Models('family'),
- SDO_RDF_Rulebases('RDFS'),
- SDO_RDF_Aliases(
- SDO_RDF_Alias('', 'http//www.example.org/f
amily/')), - null))
- M
- --------------------------------------------------
------------------------------ - http//www.example.org/family/Jack
- http//www.example.org/family/Tom
- http//www.example.org/family/John
- http//www.example.org/family/Matt
- http//www.example.org/family/Sammy
60Join w/ Inference Example
- Find salary and hiredate of Matts grandfathers
- SELECT emp.name, emp.salary, emp.hiredateFROM
emp, TABLE(SDO_RDF_MATCH(
'(?x grandParentOf Matt)
(?x rdftype Male)
(?x name ?name)',
SDO_RDF_Models('family'),
SDO_RDF_Rulebases(RDFS',
'family_rb'), )) tWHERE
emp.namet.name
61Join w/ Inference Example 2
- Find pairs of persons residing at the same
address where the first person rents a truck and
the second person buys a fertilizer - SELECT t3.x name1, t3.y name2FROM AddrTable t1,
AddrTable t2, TABLE(SDO_RDF_MATCH(
'(?x rents ?a) (?a
rdftype Truck) (?y
buys ?b) (?b rdftype Fertilizer)',
SDO_RDF_Models('Activities'),
SDO_RDF_Rulebases(RDFS')
, )) t3WHERE t1.namet3.x and
t2.namet3.y and t1.addrt2.addr
62(No Transcript)