ends of the relationship arrow. That is, the relation-
ship will first be analyzed from left to right and then
from right to left, as if they were two simple rela-
tionships. Thus, a bi-directional relationship will be
represented by the next syntax (going from the Clas-
sic relationship to the Tag relationship, respectively):
entity1.attribute1 <-> entity2.attribute2
entity1 <-(TAG)-> entity2
3.2.2 Cardinalities
The cardinality defines the number of occurrences in
one entity/attribute which are associated (in a rela-
tionship) to the number of occurrences in another. It
will be necessary to verify if the value is in the in-
terval specifying the cardinality. In a unidirectional
relationship, a cardinality can be added to the desti-
nation side of the arrow (for example after entity2).
While in bi-directional relationships, cardinalities can
be added to both sides of the relationship at the same
time. It is not mandatory to specify cardinalities but
it can be interesting for consistency reasons. An ex-
ample of their syntax could be entity1.attribute1
-> entity2.attribute2[MIN..MAX]
3.2.3 Actions
Actions are defined in order to improve the consis-
tency of the datasource by enforcing the RICs. The
actions are checking the validity of a RIC, and they
will be performed when a constraint is not accom-
plished, allowing the user to adapt the content of the
database to the constraints defined. We decided to
represent them under four different cases, that will be
explained in this part. It is important to indicate that
this feature will be optional for the user, but also it is
the only way to modify the content of the datastore.
This first action is named Add Info and it
will add some information in the dataset. Its
behaviour depends on the relationship type. In
the case of a Classic relationship, an edge
is created when it does not already exist but
the constraint is declared. Being a datastore
with a classical RIC: entityRed.attributeRed ->
entityBlue.attributeBlue. With the action Add
Info, the proposal will add an edge between nodeA
(of entityRed) and nodeC (of entityBlue) only if the
value of attributeRed corresponds to the value of at-
tributeBlue of nodeC meaning that there is a reference
between nodeA and nodeC, but there is no arc on the
graph. For the case of Tag relationship (entityRed
-(TAG)-> entityBlue) a checking is made to know
if there are relationships, defined by edges, between
nodeRed nodes and nodeBlue nodes. If there is any
relationship, the identifier value (in attributeBlue)
of the nodeBlue node is added to the attributeRed
of the nodeRed node.
Summarising, the goal of this action is to keep
consistency between nodes and attributes referenced
by classical and tag relationships, by means of adding
to the nodes the required edges or attribute values, in
order to reflect the relationship defined in the RIC.
The purpose of the Delete action will be to delete
an information or a node violating a RIC. Cautions
are needed when this type of actions is used, as it is
always risky to delete data from the database. In the
case of Classic relationship as defined before, each
value of the AttributeRed are taken. We will check if
there is a nodeBlue that have this value in its Attribute-
Blue. If no match exists, the value of the AttributeRed
is removed. For Tag relationships as defined before,
a node of the source entity nodeRed should have at
least one relationship with a node of the target entity
nodeBlue. If there is no relationship, the first node
would be deleted. Another kind of deletion of infor-
mation has been found out: Deleting information in
cascade. Even though in the case of classical rela-
tionship it will not change anything, it will require
a special attention for tag relationships. If a source
node is removed, and this one has other relations with
other entities, this action will permit to delete all of its
relative nodes in cascade.
The last action is Info. The idea here is to show
information about a violated RIC. It will return all the
information about the node and entity, and its direct
relationships with other entities.
3.2.4 Condition
The concept of condition here is to act as an extra-
validation for the RIC by checking if the attribute
value in the dataset accomplishes with the written
condition to validate the RIC. Therefore, not only
the classical or tag relationship must be accom-
plished for not violating a RIC, but also the con-
dition declared in the corresponding clause. The
syntax of the condition is described as follow-
ing: entity.attribute {RelationalOperator}
value {LogicalOperator}. Although the expres-
sion declared for a condition could be very complex,
as a simple proof of concept, this work only com-
pares a property with a value using one of these five
different relational operators: equals (=), greater than
(>), lesser than (<), greater than or equals (>=), lesser
than or equals (<=). A property is the value of an
attribute of a particular entity represented like this:
entity.attribute. The compared value can be either a
String, an Integer or a Boolean. This condition can be
linked to one or a few more thanks to a logical opera-
tor, AND and OR.
Defining Referential Integrity Constraints in Graph-oriented Datastores
413