Scope

This document contains the schema definition of a MaJorToM Redis database used by a Redis Topic Map Store. The schema is not strict and can be extended by additional information which is ignored by the topic map store itself, as long as it does not overlap with the key patterns used in wildcard searches.

Note
Additional information using a key pattern matching one of the schema entries of the Redis topic map store can cause side effects or errors. Such kind of information should be prefixed or postfixed with a special pattern like extension:.

Schema

The schema section describes the structure and type of a dataset dependent from the construct type or information level.

1. Id Generation

The id of any topic map construct consists of a construct type prefix and a numerical id. The numerical id is auto-generated by the Redis database using the increment command on the key id. Consequently the <id> pattern referred to in the following sections expands to <type-prefix>:<numerical-id>. To allow unambiguous wildcard searches on construct hashes, the id is postfixed by :h. The key of a construct matches the following pattern: <type-prefix>:<numerical-id>:h. The type-prefixes are explained in the corresponding section.

Note
Any modification of this id key can cause unexpected errors or side effects.

2. Topic Map Constructs

2.1. Topic Map

Currently the Redis schema only allows the definition of one topic map for a Redis database. Because of that, the database represents the virtual instance of the topic map construct.

The id of a topic map construct starts with the key pattern topicmap: followed by a numerical id and the postfix :h.

The reifier property is stored in the constructs hash in the field ~. The value of this field is the topic id of the reifier, e.g. t:123. If no reification is set, the entry is unset.

The item-identifier property of the TMDM is stored as Redis set of the string literals representing the IRI of the identifier. The key of this Redis property starts with the id of the construct followed by the postfix :ii.

Note
To speed up the access of constructs by an existing item identifier, each item-identifier relation is stored twice. The reverse binding of an item-identifier to its construct are stored as atomic key-value pair with the key ii: followed by the IRI reference. The value is the id of the construct.

The topics property of the TMDM is stored as key-value pair. The key is topics and the value is set of strings representing the topic ids.

Note
If the topic map does not contain any topic, the key is not present.

The associations property of the TMDM is stored as key-value pair. The key is associations and the value is set of strings representing the association ids.

Note
If the topic map does not contain any association, the key is not present.

Property

Redis-Key [field]

Type

Value

reifier

<id>:h [~]

string field in a hash

reified construct id

item-identifier

<id>:ii

set of string

IRI references

topics

topics

set of string

topic ids

associations

associations

set of string

association ids

scoped associations (by a scope object)

sa:<id>

set of string

association ids

scoped names (by a scope object)

sn:<id>

set of string

name ids

scoped occurrences (by a scope object)

so:<id>

set of string

occurrence ids

scoped characteristics (by a scope object)

sc:<id>

set of string

characteristic ids

scoped variants (by a scope object)

sv:<id>

set of string

variant ids

typed associations (by a topic)

ta:<id>

set of string

association ids

typed names (by a topic)

tn:<id>

set of string

name ids

typed occurrences (by a topic)

to:<id>

set of string

occurrence ids

typed characteristics (by a topic)

tc:<id>

set of string

characteristic ids

typed roles (by a topic)

tr:<id>

set of string

role ids

roles by association type

rba:<id>

set of string

role ids

scopes

s:<id>

set of string

theme ids

construct by item-identifier

ii:<string>

string

construct id

topic by subject-identifier

si:<string>

string

topic id

topic by subject-locator

sl:<string>

string

topic id

2.2. Topic

The id of a topic starts with the key pattern t: followed by a numerical id and the postfix :h.

Note
Any modification of this id key can occur unexpected errors or side effects.

The item-identifier property of the TMDM is stored as Redis set of the string literals representing the IRI of the identifier. The key of this Redis property starts with the id of the construct followed by the postfix :ii.

Note
To speed up the access of constructs by an existing item identifier, each item-identifier relation is stored twice. The reverse binding of an item-identifier to its construct are stored as atomic key-value pair with the key ii: followed by the IRI reference. The value is the id of the construct.

The subject-identifier property of the TMDM is stored as Redis set of the string literals representing the IRI of the identifier. The key of this Redis property starts with the id of the topic followed by the postfix :si.

Note
To speed up the access of topic by an existing subject-identifier, each subject-identifier relation is stored twice. The reverse binding of an subject-identifier to its topic are stored as atomic key-value pair with the key si: followed by the IRI reference. The value is the id of the topic.

The subject-locator property of the TMDM is stored as Redis set of the string literals representing the IRI of the identifier. The key of this Redis property starts with the id of the topic followed by the postfix :sl.

Note
To speed up the access of topic by an existing subject-locator, each subject-locator relation is stored twice. The reverse binding of an subject-locator to its topic are stored as atomic key-value pair with the key sl: followed by the IRI reference. The value is the id of the topic.

The type property of the TMDM is stored as Redis set of the string literals representing the id of the topics acting as type. The key of this Redis property starts with the id of the topic followed by the postfix :t.

Note
To speed up the access of instances of a topic, the reverse association is also stored using the key postfix :i. The value is also a set of topic ids.

The supertype property of the TMDM is stored as Redis set of the string literals representing the id of the topics acting as supertype. The key of this Redis property starts with the id of the topic followed by the postfix :sp.

Note
To speed up the access of subtypes of a topic, the reverse association is also stored using the key postfix :sb. The value is also a set of topic ids.

The names property of the TMDM are stored as Redis set of the string literals representing the id of the names. The key of this Redis property starts with the id of the topic followed by the postfix :n.

The occurrences property of the TMDM are stored as Redis set of the string literals representing the id of the occurrences. The key of this Redis property starts with the id of the topic followed by the postfix :o.

The characteristics property are stored as Redis set of the string literals representing the id of the characteristic. The key of this Redis property starts with the id of the topic followed by the postfix :c.

If the topic is used as reifier of an other construct of the topic map, the reification to the topic is stored in the construct hash in the field ~. The value of this field is the construct id of the reified item, e.g. n:123.

Property

Redis-Key [field]

Type

Value

reifier

<id>:h [~]

string field in a hash

reified construct id

item-identifier

<id>:ii

set of string

IRI references

subject-identifier

<id>:si

set of string

IRI references

subject-locator

<id>:sl

set of string

IRI references

names

<id>:n

set of string

name ids

occurrences

<id>:o

set of string

occurrence ids

characteristics

<id>:o

set of string

characteristics ids

types

<id>:t

set of string

topic ids

instances

<id>:i

set of string

topic ids

supertypes

<id>:sp

set of string

topic ids

subtypes

<id>:sb

set of string

topic ids

played roles

<id>:pr

set of string

role ids

played associations

<id>:pa

set of string

association ids

theme in scopes

<id>:is

set of string

scope ids

2.3. Names

The id of a topic name starts with the key pattern n: followed by a numerical id and the postfix :h.

Note
Any modification of this id key can occur unexpected errors or side effects.

The properties of the name construct are stored within a hash value accessed by the name id.

The parent property is stored in the constructs hash in the field ^. The value of this field is the topic id of its parent, e.g. t:123.

The value property is stored in the constructs hash in the field v. The value of this field is the string value.

The type property is stored in the constructs hash in the field t. The value if this field is the topic id of the type, e.g. t:123.

The scope property is stored in the constructs hash in the field s. The value of this field is the scope id, e.g. s:0.

Note
The empty scope is set to default value s:0

The reifier property is stored in the constructs hash in the field ~. The value of this field is the topic id of the reifier, e.g. t:123. If no reification is set, the entry is unset.

The item-identifier property of the TMDM is stored as Redis set of the string literals representing the IRI of the identifier. The key of this Redis property starts with the id of the construct followed by the postfix :ii.

Note
To speed up the access of constructs by an existing item identifier, each item-identifier relation is stored twice. The reverse binding of an item-identifier to its construct are stored as atomic key-value pair with the key ii: followed by the IRI reference. The value is the id of the construct.

The variants property of the TMDM is stored as key-value pair. The key starts with the name id postfixed with :y. The value is set of strings representing the variant ids.

Note
If the name does not contain any variant, the key is not present.

Property

Redis-Key [field]

Type

Value

parent

<id>:h [^]

string field in a hash

topic id

type

<id>:h [t]

string field in a hash

topic id

value

<id>:h [v]

string field in a hash

string value

scope

<id>:h [s]

string field in a hash

scope id

reifier

<id>:h [~]

string field in a hash

topic id

item-identifier

<id>:ii

set of string

IRI references

variants

<id>:y

set of string

variant ids

2.4. Occurrences

The id of an occurrence starts with the key pattern o: followed by a numerical id and the postfix :h.

Note
Any modification of this id key can occur unexpected errors or side effects.

The properties of the occurrence construct are stored within a hash value accessed by the occurrence id.

The parent property is stored in the constructs hash in the field ^. The value of this field is the topic id of the parent, e.g. t:123.

The value property is stored in the constructs hash in the field v. The value of this field is the string value, e.g. Name.

The datatype property is stored in the constructs hash in the field d. The value of this field is the reference of the datatype, e.g. http://www.w3.org/2001/XMLSchema#string.

The type property is stored in the constructs hash in the field t. The value of this field is the topic id of the type, e.g. t:123.

The scope property is stored in the constructs hash in the field s. The value of this field is the scope id, e.g. s:1.

Note
The empty scope is set to default value s:0

The reifier property is stored in the constructs hash in the field ~. The value of this field is the topic id of the reifier, e.g. t:123. If no reification is set, the entry is unset.

The item-identifier property of the TMDM is stored as Redis set of the string literals representing the IRI of the identifier. The key of this Redis property starts with the id of the construct followed by the postfix :ii.

Note
To speed up the access of constructs by an existing item identifier, each item-identifier relation is stored twice. The reverse binding of an item-identifier to its construct are stored as atomic key-value pair with the key ii: followed by the IRI reference. The value is the id of the construct.

Property

Redis-Key [field]

Type

Value

parent

<id>:h [^]

string field in a hash

topic id

type

<id>:h [t]

string field in a hash

topic id

value

<id>:h [v]

string field in a hash

string value

datatype

<id>:h [d]

string field in a hash

IRI reference

scope

<id>:h [s]

string field in a hash

scope id

reifier

<id>:h [~]

string field in a hash

topic id

item-identifier

<id>:ii

set of string

IRI references

2.5. Variants

The id of a variant starts with the key pattern v: followed by a numerical id and the postfix :h.

Note
Any modification of this id key can occur unexpected errors or side effects.

The properties of the variant construct are stored within a hash value accessed by the variant id.

The parent property is stored in the constructs hash in the field ^. The value of this field is the name id of the parent, e.g. n:123.

The value property is stored in the constructs hash in the field v. The value of this field is the string value, e.g. Variant.

The datatype property is stored in the constructs hash in the field d. The value of this field is the reference of the datatype, e.g. http://www.w3.org/2001/XMLSchema#string.

The scope property is stored in the constructs hash in the field s. The value of this field is the scope id, e.g. s:0.

The reifier property is stored in the constructs hash in the field ~. The value of this field is the topic id of the reifier, e.g. t:123. If no reification is set, the entry is unset.

The item-identifier property of the TMDM is stored as Redis set of the string literals representing the IRI of the identifier. The key of this Redis property starts with the id of the construct followed by the postfix :ii.

Note
To speed up the access of constructs by an existing item identifier, each item-identifier relation is stored twice. The reverse binding of an item-identifier to its construct are stored as atomic key-value pair with the key ii: followed by the IRI reference. The value is the id of the construct.

Property

Redis-Key [field]

Type

Value

parent

<id>:h [^]

string field in a hash

name id

value

<id>:h [v]

string field in a hash

string value

datatype

<id>:h [d]

string field in a hash

IRI reference

scope

<id>:h [s]

string field in a hash

scope id

reifier

<id>:h [~]

string field in a hash

topic id

item-identifier

<id>:ii

set of string

IRI references

2.6. Associations

The id of an association starts with the key pattern a: followed by a numerical id and the postfix :h.

Note
Any modification of this id key can occur unexpected errors or side effects.

The properties of the association construct are stored within a hash value accessed by the association id.

The type property is stored in the constructs hash in the field t. The value of this field is the topic id of the type, e.g. t:123.

The scope property is stored in the constructs hash in the field s. The value of this field is the scope id, e.g. s:0.

Note
The empty scope is set to default value s:0

The reifier property is stored in the constructs hash in the field ~. The value of this field is the topic id of the reifier, e.g. t:123. If no reification is set, the entry is unset.

The item-identifier property of the TMDM is stored as Redis set of the string literals representing the IRI of the identifier. The key of this Redis property starts with the id of the construct followed by the postfix :ii.

Note
To speed up the access of constructs by an existing item identifier, each item-identifier relation is stored twice. The reverse binding of an item-identifier to its construct are stored as atomic key-value pair with the key ii: followed by the IRI reference. The value is the id of the construct.

The roles property of the TMDM is stored as key-value pair. The key starts with the association id postfixed with :r. The value is set of strings representing the role ids.

Property

Redis-Key [field]

Type

Value

type

<id>:h [t]

string field in a hash

topic id

scope

<id>:h [s]

string field in a hash

scope id

reifier

<id>:h [~]

string field in a hash

topic id

item-identifier

<id>:ii

set of string

IRI references

roles

<id>:r

set of string

role ids

role-types

<id>:t

set of string

topic ids

role-players

<id>:p

set of string

topic ids

2.7. Roles

The id of a role starts with the key pattern r: followed by a numerical id and the postfix :h.

Note
Any modification of this id key can occur unexpected errors or side effects.

The properties of the role construct are stored within a hash value accessed by the role id.

The parent property is stored in the constructs hash in the field ^. The value of this field is the association id of the parent, e.g. a:123.

The type property is stored in the constructs hash in the field t. The value of this field is the topic id of the type, e.g. t:123.

The player property is stored in the constructs hash in the field p. The value of this field is the topic id of the player, e.g. t:123.

The reifier property is stored in the constructs hash in the field ~. The value of this field is the topic id of the reifier, e.g. t:123. If no reification is set, the entry is unset.

The item-identifier property of the TMDM is stored as Redis set of the string literals representing the IRI of the identifier. The key of this Redis property starts with the id of the construct followed by the postfix :ii.

Note
To speed up the access of constructs by an existing item identifier, each item-identifier relation is stored twice. The reverse binding of an item-identifier to its construct are stored as atomic key-value pair with the key ii: followed by the IRI reference. The value is the id of the construct.

Property

Redis-Key [field]

Type

Value

parent

<id>:h [^]

string field in a hash

association id

type

<id>:h [t]

string field in a hash

topic id

player

<id>:h [p]

string field in a hash

topic id

reifier

<id>:h [~]

string field in a hash

topic id

item-identifier

<id>:ii

set of string

IRI references

3. Index and Optimization

Because of the index-less characteristics of a Redis store, some information is - additionally to the plain normalized form - stored from different perspectives to serve as indexes. This increases access speed by reduce the number of read requests.

The indexes are always updated instantly. I.e. if a key is not present, there is no construct matching the criterion. E.g. if a topic is not used as a type for any association, there is no key ta:<topic-id> in the Redis database.

3.1. Typed Indexing

3.1.1. Typed Associations

Every association of the topic map is stored as member of a set containing all association ids matching to a specific type. The set contains the associations typed by the topic used in key pattern. The key is prefixed with ta: followed by the type id.

3.1.2. Typed Names

Every name of the topic map is stored as member of a set containing all name ids matching to a specific type. The set contains the names typed by the topic used in key pattern. The key is prefixed with tn: followed by the type id.

3.1.3. Typed Occurrences

Every occurrence of the topic map is stored as member of a set containing all occurrence ids matching to a specific type. The set contains the occurrences typed by the topic used in key pattern. The key is prefixed with to: followed by the type id.

3.1.4. Typed Characteristics

Every characteristic ( name or occurrence ) of the topic map is stored as member of a set containing all characteristic ids matching to a specific type. The set contains the characteristics typed by the topic used in key pattern. The key is prefixed with tc: followed by the type id.

3.1.5. Typed Roles

Every role of the topic map is stored as member of a set containing all role ids matching to a specific type. The set contains the roles typed by the topic used in key pattern. The key is prefixed with tr: followed by the type id.

3.2. Scoped Indexing

3.2.1. Scoped Associations

Every association of the topic map is stored as member of a set containing all association ids matching to a specific scope. The set contains the associations scoped by the scope used in key pattern. The key is prefixed with sa: followed by the scope id.

3.2.2. Scoped Names

Every name of the topic map is stored as member of a set containing all name ids matching to a specific scope. The set contains the names scoped by the scope used in key pattern. The key is prefixed with sn: followed by the scope id.

3.2.3. Scoped Occurrence

Every occurrence of the topic map is stored as member of a set containing all occurrence ids matching to a specific scope. The set contains the occurrences scoped by the scope used in key pattern. The key is prefixed with so: followed by the scope id.

3.2.4. Scoped Characteristics

Every characteristic ( name or occurrence ) of the topic map is stored as member of a set containing all characteristic ids matching to a specific scope. The set contains the characteristics scoped by the scope used in key pattern. The key is prefixed with sc: followed by the scope id.

3.2.5. Scoped Variants

Every variant of the topic map is stored as member of a set containing all variant ids matching to a specific scope. The set contains the variants scoped by the scope used in key pattern. The key is prefixed with sv: followed by the scope id.

3.3. Association Indexing

3.3.1. Roles By Association Type

For more direct access, the roles are additionally stored with the type of their parent association. The key is prefixed with rba and the value is a set of strings representing the id of the roles.

3.3.2. Roles Types Of An Association

For more direct access, the type of each role are stored directly accessible from their association. The key starts with the id of the association postfixed by the pattern :t. The value is a set of strings representing the type ids of the role.

3.3.3. Players Of An Association

For more direct access from an association to the players participating in this particular association, the player topics for each association are stored. The key starts with the id of the association postfixed by the pattern :p. The value is a set of strings representing the player ids of each role.

3.3.4. Played Associations Of A Topic

For more direct access from a topic to the associations it plays in, the played associations are stored for each topic. The key starts with the id of the topic postfixed by the pattern :pa. The value is a set of strings representing the association ids.

3.3.5. Played Roles Of A Topic

For more direct access from a topic to the roles it plays, the played roles are stored for each topic. The key starts with the id of the topic postfixed by the pattern :pr. The value is a set of strings representing the role id.

4. Overview

This section contains a small overview of the reserved keys of the Redis topic map schema and their meaning. The values wildcard <id> represents the id of a construct and the <string> pattern a string literal.

4.1. Redis String Keys

The following key patterns used as Redis keys with a atomic string value.

id

The id generation auto increment value

integer

ii:<string>

The construct for the specified item-identifier

construct id as string

si:<string>

The topic for the specified subject-identifier

topic id as string

sl:<string>

The topic for the specified subject-locator

topic id as string

l:<id>

Representation of an internal item-identifier

-

4.2. Redis Hash Keys

The following key patterns used as Redis keys with a hash value.

Key-pattern

Description

Value

topicmap:[0-9]+:h

Representing the topic map construct

properties as hash

t:[0-9]+:h

A topic with this id

properties as hash

o:[0-9]+:h

The key for the property hash of an occurrence

properties as hash

n:[0-9]+:h

The key for the property hash of a topic name

properties as hash

y:[0-9]+:h

The key for the property hash of a variant

properties as hash

a:[0-9]+:h

The key for the property hash of an association

properties as hash

r:[0-9]+:h

The key for the property hash of a role

properties as hash

4.3. Redis Set Keys

The following key patterns used as Redis keys with a set value.

Key-pattern

Description

Value

associations

All associations of the topic map

association ids as set of string

topics

All topics of the topic map

topic ids as set of string

<id>:ii

All item-identifiers of the construct

references as set of string

<id>:si

All subject-identifiers of the topic

references as set of string

<id>:sl

All subject-locator of the topic

references as set of string

<id>:n

Names of a topic

name ids as set of strings

<id>:o

Occurrences of a topic

occurrence ids as set of strings

<id>:c

Characteristics of a topic

characteristic ids as set of strings

<id>:is

The scopes a theme is part of.

scope ids as set of string

<id>:t

Types of a topic

topic ids as set of strings

Role types of an association

topic ids as set of strings

<id>:i

Instances of a topic

topic ids as set of strings

<id>:sp

Supertypes of a topic

topic ids as set of strings

<id>:sb

Subtypes of a topic

topic ids as set of strings

<id>:y

Variants of a topic name

variant ids as set of string

s:<id>

The scope with the specified id

theme ids as set of string

<id>:p

All players of an association

player ids as set of strings

<id>:pa

All associations played by the player id

association ids as set of string

<id>:pr

All roles played by the player id

role ids as set of string

sa:<id>

All associations scoped by the scoping id

association ids as set of string

sn:<id>

All names scoped by the scoping id

name ids as set of string

so:<id>

All occurrences scoped by the scoping id

occurrence ids as set of string

sc:<id>

All characteristics scoped by the scoping id

characteristic ids as set of string

sv:<id>

All variants scoped by the scoping id

variant ids as set of string

ta:<id>

All associations typed by the type id

association ids as set of string

tn:<id>

All names typed by the type id

name ids as set of string

to:<id>

All occurrences typed by the type id

occurrence ids as set of string

tc:<id>

All characteristics typed by the type id

characteristic ids as set of string

tr:<id>

All roles typed by the type id

role ids as set of string

rba:<id>

All roles typed by the association type id

role ids as set of string

4.4. Redis Fields Of Construct Hashes

The following fields are used in construct hashes.

Field

Description

Value

~

The reification of a construct as key of an internal hash

construct id as string

s

The scope property of a scoped construct as key of the internal hash

scope id as string

t

The type property of a typed construct

topic id as string

p

The player property of a role

id of player as string

^

The parent property of a construct

the parent id as string

v

The value property of names, occurrences or variants

string

d

The datatype property of occurrences or variants

IRI reference as string

topicmapslab.de