What kind of rules can I write in RDFox?

RDFox allows the user to control semantic reasoning by adding Datalog rules to a data store.

Rules are essentially if-then statements that add data to the graph when certain conditions are met.

These rules can specify a pattern that is matched to triples, like this:

[?person, :hasNickname, “Bob”] :-
   [?person, :hasFirstName, “Robert”] .

(This rule assigns the nickname “Bob” to all people named “Robert”)

They can also use expressions borrowed from SPARQL (like BIND or FILTER) as well as SPARQL functions:

[?person, :hasFullName, ?fullName] :-
   [?person, :hasFirstName, ?firstName],
   [?person, :hasLastName, ?lastName],
   BIND(CONCAT(?firstName, “ “, ?lastName) AS ?fullName) .

(This rule concatenates a person’s first and last names to create their full name)

[?person, :hasPosition, :manager] :-
   [?person, :hasPositionDescription, ?description],
   FILTER(CONTAINS(LCASE(?description), “manager”)) .

(This rule assigns the position of manager to anyone who has “manager” in their job description)

The functions allow the user to manipulate strings, numbers, dates, and IRIs. Some of the examples include:

RDFox also extends Datalog to include negation:

[?person, a, :Unemployed] :-
   [?person, a, :Person],
   NOT EXISTS ?job IN [?person, :hasJob, ?job] .

(This rule assigns the class “unemployed” to all people without jobs)

And aggregation:

[?person, :hasChildNumber, ?count] :-
       [?child, :hasParent, ?parent]
   ON ?parent BIND COUNT(?child) AS ?count
   ) .

(This rule adds a property assigning the number of children to each person who has any)

How to query a graph database?

What is Semantic Inference?

Learn more about RDFox

Get yourself a free trial!

Contact us for more detail

Looking for more answers?

From the blog

High performance knowledge graph and semantic reasoning engine.