# RSP Query Semantics

The idea of this section is to define the semantics of RDF stream queries. Because we are planning to build from the SPARQL semantics, we can use them as a basis for this part, and define the semantics of the extensions or additional operators.

## Stream Model

A graph G defined as a set of triples:

- G = {( subj, pred, obj)}

Original suggestion for a graph-based stream model

- A stream is a sequence (G, τ ) where τ ∈ T the set of all intervals (timestamps).

New proposal

- A stream is a sequences of quads (s, p, o, G) where G is the context/graph of the triple.
- We also have a second stream that annotates the contexts such that (G, p, τ) is a triple on the metadata stream such that p is a predicate that relates the timestamp τ to the graph G

Open question, how can we allow τ in the annotated stream be a value in the graph G? (This is needed for supply chain use case)

Another new proposal (Roland)

- A stream is a sequences of quads (s, p, o, G) where G is the context/graph of the triple.
- G is the unique event ID and information resource for all triples in one event
- the graph G contains triples with event ID as the subject, adding '#event' to distinguish the thing-resource from the information resource
- this would lead to some exemplary triples like (pseudo TriG):

<eventId> { <eventId#event> :endTime "..." . <eventId#event> :source "..." . }

## Windows

#### Time Windows

Given a graph G defined as a set of triples:

G = {( subj, pred, obj)}

#### point-based time label

Let's first consider a stream S with point-in-time timestamps:

S = {(G, τ ) | τ ∈ T)}

Then a window ω can be defined as:

ω(S, t_i,t_f) = {G | (G,τ) in S and t_i < τ ≤ t_f }

##### Intervals

Consider a stream S with intervals timestamps:

S = {(G, τ_1, t_2 ) | τ_1,τ_2 ∈ T)}

Then a window ω can be defined as:

ω(S, t_i,t_f) = {G | (G,τ_1,τ_2) in S and [t_i,t_f] *is not disjoint* with [τ_1,τ_2] }

If the graphs have interval timestamps, then the question arises of how to define the window: