LogicalEquivalences

From RDB2RDF
Jump to: navigation, search

Logical Equivalences Between KR Forms

Following is a set of representations of a simple employee table in different KR forms: Assertions are prefixed by "a:" and a rules (views) by "r:".

Relational

 a: CREATE TABLE Employee (id INT, name STRING, manager INT)
    INSERT INTO Employee VALUES (1, "Alice", NULL)
    INSERT INTO Employee VALUES (2, "Bob", 1)
 r: CREATE VIEW SecondLine (
     SELECT emp.name AS emp, man.name AS man
       FROM Employee AS emp
 INNER JOIN Employee AS man ON man.id=emp.manager )

Datalog

 a: Employee(1, "Alice", 99999)
 r: SecondLine(EMP, MAN) :- Employee(X, MAN, _) Employee(_, EMP, X)

RDF

 a: emp:id.1 emp:name "Alice" .
    emp:id.2 emp:name "Bob" ; emp.manager emp:id.1 .

SPARQL

 r: CONSTRUCT { _:s1 SecondLine:emp ?emp ; SecondLine.man ?man }
        WHERE { ?x Employee:name ?man .
                ?y Employee:name ?emp ; Employee.manager ?x }

RIF (presentation syntax)

 r: SecondLine.emp(_:s1, ?emp) SecondLine(_:s1, ?man) := 
        Employee:name(?x, ?man)
        Employee:name(?y, ?emp) Employee:manager(?y, ?x)