Skip to content

Instantly share code, notes, and snippets.

@namedgraph
Last active May 9, 2023 08:32
Show Gist options
  • Save namedgraph/64ef07b0a3a66092cfdcbf65eefbf00f to your computer and use it in GitHub Desktop.
Save namedgraph/64ef07b0a3a66092cfdcbf65eefbf00f to your computer and use it in GitHub Desktop.
A denotational semantics for CRUD operations on RDF datasets

RDF quads

S = I ∪ B

P = I

O = I ∪ B ∪ L

G = I ∪ B

Global RDF dataset function/set

d : S × P × G → O

D = graph(d) = { (x, d(x)) : x ∈ S × P × G } = S × P × G × O

empty : D - empty dataset

Partial RDF dataset

R ⊆ D

Graph store functions

get : R × I → R

get(r, i) = (s, p, g, o) ∈ r : g = i

delete : R × I → R

delete(r, i) = r \ get(r, i)

post : R × R → R

post(r, rrequest) = r ∪ rrequest

put : R × R × I → R

put(r, rrequest, i) = post(delete(r, i), rrequest)

Quad store functions

get : R → R

get(r) = r

delete : R → R

delete(r) = r \ get(r) = empty

post : R × R → R

post(r, rrequest) = r ∪ rrequest

put : R × R × I → R

put(r, rrequest) = post(delete(r), rrequest)

Examples

Dataset

r ∈ R =

<s1> <p1> <o1> <g1>
<s1> <p2> <o2> <g1>
<s2> <p1> <o1> <g1>
<s2> <p2> <o2> <g1>
<s1> <p1> <o1> <g2>
<s1> <p2> <o2> <g2>
<s2> <p1> <o1> <g2>
<s2> <p2> <o2> <g2>

rrequest ∈ R =

<s3> <p3> <o3> <g3>

Graph Store

get(r, g1) =

<s1> <p1> <o1> <g1>
<s1> <p2> <o2> <g1>
<s2> <p1> <o1> <g1>
<s2> <p2> <o2> <g1>

get(r, s1) = empty

delete(r, g1) =

<s1> <p1> <o1> <g2>
<s1> <p2> <o2> <g2>
<s2> <p1> <o1> <g2>
<s2> <p2> <o2> <g2>

post(r, rrequest) =

<s1> <p1> <o1> <g1>
<s1> <p2> <o2> <g1>
<s2> <p1> <o1> <g1>
<s2> <p2> <o2> <g1>
<s1> <p1> <o1> <g2>
<s1> <p2> <o2> <g2>
<s2> <p1> <o1> <g2>
<s2> <p2> <o2> <g2>
<s3> <p3> <o3> <g3>

put(r, rrequest, g1) =

<s1> <p1> <o1> <g2>
<s1> <p2> <o2> <g2>
<s2> <p1> <o1> <g2>
<s2> <p2> <o2> <g2>
<s3> <p3> <o3> <g3>

Quad Store

get(r) =

<s1> <p1> <o1> <g1>
<s1> <p2> <o2> <g1>
<s2> <p1> <o1> <g1>
<s2> <p2> <o2> <g1>
<s1> <p1> <o1> <g2>
<s1> <p2> <o2> <g2>
<s2> <p1> <o1> <g2>
<s2> <p2> <o2> <g2>

delete(r) = empty

post(r, rrequest) =

<s1> <p1> <o1> <g1>
<s1> <p2> <o2> <g1>
<s2> <p1> <o1> <g1>
<s2> <p2> <o2> <g1>
<s1> <p1> <o1> <g2>
<s1> <p2> <o2> <g2>
<s2> <p1> <o1> <g2>
<s2> <p2> <o2> <g2>
<s3> <p3> <o3> <g3>

put(r, rrequest) =

<s3> <p3> <o3> <g3>
@namedgraph
Copy link
Author

For an extended SPARQL-based specification see Linked Data Templates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment