4.1 Types
A hierarchy of types is constructed as follows. We assume the existence of some (elementary) types \(\mathtt{S}_{1}\),...,\(\mathtt{S}_{k}\) (\(k\ge 1\)). They constitute a base B. More complex types are constructed in the following way.
If
\(\mathtt{S, R}_{1},\ldots , \mathtt{R}_{\mathrm{n}}\) (
\(n\ge 1\)) are types, then
(i)
(\(\mathtt{S:R}_{1}\),...,\(\mathtt{R}_{\mathrm{n}})\) is a (functional) type,
(ii)
(\(\mathtt{R}_{1}\),...,\(\mathtt{R}_{\mathrm{n}})\) is a (tuple) type.
The set of
types T over B is the least set containing types from
B and those given by (i)-(ii). When
\(\mathtt{S}_{\mathrm{i}}\) in
B are interpreted as non-empty sets, then
\((\mathtt{S:R}_{1},\ldots ,\mathtt{R}_{\mathrm{n}})\) denotes the set of all (total or partial) functions from
\(\mathtt{R}_{1}\times \cdots \times \mathtt{R}_{\mathrm{n}}\) into S,
\(\mathtt{(R}_{1},\ldots ,\mathtt{R}_{\mathrm{n}})\) denotes the Cartesian product
\(\mathtt{R}_{1}\times \cdots \times \mathtt{R}_{\mathrm{n}}\).
In the conceptual modelling, each base B consists of descriptive and entity types. Descriptive types (String, Number,
etc.) serve for domains of properties. Their elements are constants like ‘Prague‘, ‘John‘, ‘201400‘, etc. The elementary type Bool
= {TRUE, FALSE} is also in B. The type Bool
allows to type some objects as sets and relations. They are modelled as unary and n-ary characteristic functions, respectively. The concept of the set then becomes redundant.
The fact that X is an object of type R
\(\in \) T can be written as \(X\mathtt{R}\), or “X is the R
-object”. For each typed object o the function type
returns type
(\(o) \quad \in \) T of o. Logical connectives, quantifiers and predicates are also typed functions: e.g., and/(Bool:Bool,Bool
), R-identity \(=_{\mathrm{R}}\) is (Bool:R,R
)-object, universal R-quantifier \(\Pi _{\mathrm{R}}\), and existential R-quantifiers \(\Sigma _{\mathrm{R}}\) are (Bool:(Bool:R
))-objects. R-singularizer \(I_{\mathrm{R}}\)/(R:(Bool:R)
) denotes the function whose value is the only member of an R-singleton and in all other cases the application of \(I_{\mathrm{R}}\) is undefined. Arithmetic operations +, -, *, / are examples of (Number:Number,Number
)-objects. We can also type functions of functions etc.
4.2 Attributes
Object structures usable in building a database can be described by some expressions of a natural language. For example, “the language thought by a teacher at a school” (abbr. LTS) is a (
Language:Teacher, School
)-object, i.e., a (partial) function
f
:Teacher
\(\times \) School
\(\rightarrow \) Language
, where
Teacher, School, and Language
are appropriate elementary types. Such functions are called
attributes in [
7].
More formally, attributes are functions of type ((S:T):W
), where W
is the logical space (possible worlds), T
contains time moments, and S \(\upepsilon \) T. \(M_{\mathrm{w}}\) denotes the application of the attribute M to \(w.\mathtt{W}\), \(M_{\mathrm{wt}}\) denotes the application of \(M_{\mathrm{w}}\) to the time moment t. In our approach to conceptual modelling, we can omit parameters w and t in type
(M). In the case of LTS attribute, we suppose only possible worlds, where teachers teach at most on language in each school. However, this may not be true for other possible worlds. For GDBs we can elementary entity types conceive as sets of node ID
s. For a better readability, John, Prague, Frank
can be simply such IDs.
Attributes can be constructed according to their type in a more complicated way. For example, “the classes in a school” could be considered as an attribute CS of type ((Bool:(Bool:Student)):School)
, i.e., the classes contain sets of students and the CS returns a set of classes (of students) for a given school. Obviously, Student
is an elementary type.
We can also consider other functions that need no possible world. For example, aggregate functions like
\(\hbox {COUNT}_{\mathrm{S}}\)/(
(Number:(Bool:S)
), SUM/
(Number:(Bool:Number))
9 and arithmetic operations provide such functions. These functions have the same behaviour in all possible worlds and time moments. Consequently, we can distinguish between two categories of functions:
empirical (e.g. attributes) and
analytical. The former are conceived as partial functions from the logical space. Range of these functions are again functions. Analytical functions are of type
S
, where
S
does not depend on
W
and
T
.
The notion of attribute applied in GDBs could be restricted on attributes of types(R:S), ((Bool:R):S),
or (Bool:R,S)
, where R
and S
are entity types. This strategy simply covers binary functional types, binary multivalued functional types, and binary relationships described as binary characteristic functions. The last option corresponds to m : n relationship types. For modelling directed graphs the first two types are sufficient, because m : n relationships types can be expressed by two ,,inverse“ binary multivalued functional types. Here we will consider always one of them (see, e.g., Teaches below). Thus, a graph database schema can reflect a reality only partially, similarly to non-functional graph data modelling.
Now we add properties. Properties describing entity types can be of types (\(\mathtt{S}_{1}\),...,\(\mathtt{S}_{\mathrm{m}}\):R
), where \(\hbox {S}_{\mathrm{i} }\) are descriptive elementary types and R is an entity type. So we deal with functional properties. Similarly, we can express properties of edges. They are of types (\(\mathtt{S}_{1}\),...,\(\mathtt{S}_{\mathrm{m}},\mathtt{R}_{1}:\mathtt{R}_{2})\) and \(((\mathtt{Bool:S}_{1}\),...,\(\mathtt{S}_{\mathrm{m}},\mathtt{R}_{1}):\mathtt{R}_{2})\) for binary functional and binary multivalued functional types, respectively.
Then a functional database schema describing GDB in Fig.
1 can look as:
La/((Name, Textbook):Language)
Te/((T_ID, T_Name, Birth_year):Teacher)
Tw/((Town_name, Population):Town)
Teaches/((Bool:Day, Hour, Room,
Language):Teacher)
Is_Born_in/((Date, Town):Teacher)
Lives_in/
((From,Town):Teacher)
where La, Te, Tw, Teaches, Is_Born_in and Lives_in are typed variables. The use of variables correspond to a “database view” of the modelled world. Since we do not consider temporal functional databases here, it is not necessary to use time explicitly.
We remark, however, that our functional GDBs with such schemas can contain isolated nodes with at least one property. IDs
of edges are not necessary, because edges are not explicitly considered.
Thus, a functional graph database schema is a set of variables of types from T restricted to attribute types. A functional graph database is any evaluation of these variables. Thus, certain variables serve for referencing the associated database. For convenience, we denote the variables from the functional graph database schema by names remaining entity and relationship types in the associated traditional GDB schema or at least their abbreviations.