Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds the inverse abstract operator and the inverse-predicate attribute to triples #56

Merged
merged 6 commits into from
Feb 17, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions data-model.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ A *triple*, as in RDF, is a structure composed of three elements:

*Triples* notation is `(subject, predicate, object)`.

A triple `(a, b, c)` where `a`, `b` and `c` are *resources* is true if, and only if, the associated statement is true. For example `(Douglas Adams, instance of, human)` is true because *Douglas Adams is an instance of human* is a true statement but `(Douglas Adams, instance of, flower)` is false because Douglas Adams is definitively not a flower.

We define also a subset of *resources* called *properties* such that `b` is a *property* if, an only if, `b` may be seen as a relation between two resources (i.e. may be used as a predicate of a meaningful triple). For example `birth date` is a *property* but `Douglas Adams` is not.

We use triple formalism with some operators:

##### *full triple*
Expand All @@ -50,6 +54,13 @@ Example: a triple generated from the question “What is the birth date of Georg
#### *list* operators
There are some operators that manipulate lists. These operators do not preserve order.

##### *inverse*
The *inverse* is an operator of *property → property* such that `inverse(p)` is an *inverse property* of `p` i.e. a property such that for all `a`, `c`, `(a, p, c)` ↔ `(c, inverse(p), a)`. We generalize this operator on *list → list* (it returns an inverse property for each property in the input list).

Example: We may have `has parent = inverse(has child)`.

*inverse* operator is useful when the same statement may be written in inversed manners in the database. For example, `a` is a part of `c` may be encoded as `(a, part of, c)` or `(c, member, a)`. With *inverse*, in order to retrieve all parts of `c` we may use this single triple `(?, part of ∪ inverse(member), c) = (c, member ∪ inverse(part of), ?)`.

##### *union*
The *union* is an operator of *list⁺ → list* that returns the union of the lists. Its notation is the infix `∪` like `l1 ∪ l2 ∪ l3`.

Expand Down Expand Up @@ -257,6 +268,28 @@ Example: the serialization of the triple `(George Washington, birth date, ?)` is
}
```

There is also an optional fourth attribute, `inverse-predicate` to encode triples like `(Barack Obama, residence ∪ inverse(inhabitant), ?)`:
```
{
"type": "triple",
"subject": {"type": "resource", "value": "Barack Obama"},
"predicate": {"type": "resource", "value": "residence"},
"inverse-predicate": {"type": "resource", "value": "inhabitant"},
"object": {"type": "missing"}
}
```

Please note that the previous triple is equivalent to:
```
{
"type": "triple",
"subject": {"type": "missing"},
"predicate": {"type": "resource", "value": "inhabitant"},
"inverse-predicate": {"type": "resource", "value": "residence"},
"object": {"type": "resource", "value": "Barack Obama"}
}
```

### *union*, *intersection*, *and* and *or*
There is only one parameter, *list*, that is an array containing the operator parameters.

Expand Down