RDFox is the high-performance in-memory knowledge graph and semantic reasoner developed by Oxford Semantic Technologies. This short article will help you understand the key concepts behind RDFox and when to use them in your applications.
A knowledge graph is a database used to store data in a graph structure, and RDFox includes a reasoning layer to interpret and manipulate the data—although many don't.
Relational databases store data in structured records whereas graph databases store data points as nodes which are connected with edges if they share some form of relationship.
Data stored in a graph can be accessed with a query that will “hop” along the edges to find the requested nodes.
Reasoning is the process of materialising rules which apply to the data. Materialising a rule means adding new nodes or edges to the graph when it is satisfied. These new nodes and edges match the rule’s “pattern”.
A rule can be as simple as an “If… then…” statement.
For example: “If a city is located in Oxfordshire, then it is located in England”.
With this rule, RDFox will automatically establish a “Located In” edge between Oxford and England.
Materialised edges are useful because they will improve querying results by reducing the number of hops needed to find the correct nodes.
Read our article on the intuitions behind knowledge graphs and reasoning for a more detailed introduction to Knowledge Graphs and Reasoning.
Rules help identify patterns in your data or verify that they don’t occur. RDFox offers a complete and flexible approach to modelling and materialising simple and complex rules in your data. This section lists some common rule-based patterns.
Many relations are naturally transitive, but they are rarely explicitly described in data because they can be cumbersome to record.
Rules help materialise transitive relations effortlessly. The following rule enables RDFox to materialise all the actual “located In” relationships:
English: If ?x is located in ?y and ?y is located in ?z then ?x is located in ?z
Datalog: [?x, :locatedIn, ?z] :- [?x, :locatedIn, ?y] , [?y, :locatedIn, ?z] .
Relations are not always transitive; in which case we might wish to define a different relation that “transitively” closes the relation. This is particularly useful in social networks where we might want to identify recommendations based on a user’s existing network.
For example, in the following network, a rule will suggest Diana follows Bob and that Alice and Diana follow Charlie to “close” the relation. Domain expertise can help influence how these relations are closed to improve the quality of the recommendations.
Generating direct connections between indirectly connected objects can help reduce the number of “hops” a query has to do when navigating the graph for answers. Materialising a connection with a rule can be useful for queries you might be running frequently.
For example, creating a “country Of Birth” edge in the first example would help find the country of birth of a person born in Oxford in one hop.
Some queries can be expressed as a rule, in which case the results can be materialised and stored directly in the graph. This can help accelerate query response times because the results are materialised before the query is actually made.
For example, a query to find nodes that don’t meet a given criteria will search through the nodes and then test if they don’t meet the specified criteria.
However, a rule can automatically filter the nodes which don’t meet the criteria and the query can then be simplified to only search through that pre-filtered subset.
“Is a”, or 'subsumption relationships', can be represented in RDFox using rules. Subsumption rules are useful for identifying non-obvious relationships in your data or assigning certain properties from a class to a newly identified member.
Rules can help identify cyclic relationships in graphs in particular when they shouldn’t occur.
A cyclic relation can be materialised with one line of Datalog:
English: if ?x :partOf ?x then :partOf is a :cyclic Relation
Datalog: [ :partOf a :cyclicRelation ] :- [ ?x , :partOf, ?x ] .
Rules can be used to perform computations over the data in the graph (e.g. unit conversions, missing values).
Rules can populate the graph with aggregate values derived from the graph such as sums, counts and averages.
Rules can check for incompleteness in the data and raise a warning whenever expected data is missing.