Relational Model for Notation 3 Persistence

${N3}_{\mathrm{terms}}≔\left\{\mathrm{URIs},\exists \left(\mathrm{existential}\phantom{\rule{mediummathspace}{0.2em}}\mathrm{variables}\right),\mathrm{Literals},\forall \left(\mathrm{universal}\phantom{\rule{mediummathspace}{0.2em}}\mathrm{variables}\right),\mathrm{Formula}\phantom{\rule{mediummathspace}{0.2em}}\mathrm{nodes}\phantom{\rule{mediummathspace}{0.2em}}\right\}$

${N3}_{\mathrm{nonLiterals}}≔{N3}_{\mathrm{terms}}$ $-\phantom{\rule{mediummathspace}{0.2em}}{\mathrm{Literals}}_{}$

${N3}_{\mathrm{graphNames}\phantom{\rule{mediummathspace}{0.2em}}}≔\left\{\mathrm{URIs},\exists ,\mathrm{Formula}\phantom{\rule{mediummathspace}{0.2em}}\mathrm{nodes}\phantom{\rule{mediummathspace}{0.2em}}\right\}$

${N3}_{\mathrm{predicateNames}}$ $≔{N3}_{\mathrm{terms}}-\left\{\mathrm{Literals},\exists \right\}$

${N3}_{\mathrm{classNames}}$ $≔\phantom{\rule{mediummathspace}{0.2em}}{N3}_{\mathrm{nonLiterals}}-\phantom{\rule{mediummathspace}{0.2em}}\mathrm{Formula}\phantom{\rule{mediummathspace}{0.2em}}\mathrm{nodes}$

${N3}_{\mathrm{nonLiterals}}$and${\mathrm{Literals}}_{}$can be interned and persisted disjointly as two tables with primary keys (using hash functions such as SHA-1 and MD5).

The entire Knowledge Base can be partition into 3 disjoint relations:

I. (Description Logics ABox) $≔\left\{\left(M,C,G\right):\phantom{\rule{mediummathspace}{0.2em}}P\left(M,C,G\right)\phantom{\rule{mediummathspace}{0.2em}}\right\}$

$C\in {N3}_{\mathrm{classNames}},\phantom{\rule{mediummathspace}{0.2em}}M\in {N3}_{\mathrm{nonLiterals}},G\phantom{\rule{mediummathspace}{0.2em}}\in {N3}_{\mathrm{graphNames}}$

where: P is rdf:type, M is a member of the class C, and G is the name of the graph in which the class membership assertion is made.

II. (Literal Properties) $≔\left\{\left(S,P,V,D,L,G\right):\phantom{\rule{mediummathspace}{0.2em}}P\left(S,L,G\right)\right\}$

$S\in {N3}_{\mathrm{nonLiterals}},\phantom{\rule{mediummathspace}{0.2em}}P\in {N3}_{\mathrm{predicateNames}},V\in \mathrm{Literal},D\phantom{\rule{mediummathspace}{0.2em}}\in \mathrm{URIs}$

$G\phantom{\rule{mediummathspace}{0.2em}}\in {N3}_{\mathrm{graphNames}},L\phantom{\rule{mediummathspace}{0.2em}}\in \left\{l:l\phantom{\rule{mediummathspace}{0.2em}}\mathrm{is}\phantom{\rule{mediummathspace}{0.2em}}a\phantom{\rule{mediummathspace}{0.2em}}\mathrm{language}\phantom{\rule{mediummathspace}{0.2em}}\mathrm{tag}\right\}$

where: P is the named property, S is the subject of the property, V is the literal value of the property, D (optional) is the datatype associated with the literal, L is the language in which the literal is expressed, and G is the name of the graph in which the property is asserted

III. (All other relations) $≔$$\left\{\left(S,P,O,G\right):\phantom{\rule{mediummathspace}{0.2em}}P\left(S,O,G\right)\phantom{\rule{mediummathspace}{0.2em}}\right\}$

$S\in {N3}_{\mathrm{nonLiterals}},\phantom{\rule{mediummathspace}{0.2em}}P\in {N3}_{\mathrm{predicateNames}},O\in {N3}_{\mathrm{nonLiterals}},G\phantom{\rule{mediummathspace}{0.2em}}\in {N3}_{\mathrm{graphNames}}$ 

where: P is the named relationships, S is the subject of the relation, O is the object of the relation, and G is the name of the graph in which the relationship is asserted