Entity and Relation Schemata
To keep the grano data model adaptable to specific use cases, the platform allows users to define so-scalled schemata for each project. They apply either to entities or to relations (never both). Each entity and relation can only be associated with a single schema.
The main task of a schema is to define a set of attributes, which describe what fields can be filled with data for an entity or relation.
All schemata automatically inherit attributes from the entity or relation base schema. For entities, this schema defines a
name property which is used to identify entities (including the option to define aliases).
Importing and exporting schemata
Schemata can be read and written via the REST API or via the command line. Imports via the command line are based on YAML files, which can contain a schema specification like this (the corresponding JSON syntax for the REST API is left as an exercise):
The above schema will apply to entities (
obj: entity) and it defines
three attributes, one of which will not be shown in listings by default
Similarly, a relation could be defined like this:
Note that, since
grano stores a directed graph, it is sometimes
desirable for listings of relations to be headed by labels which reflect
the fact that they have different semantics on both ends (
Command-line schema import
On the command line, each schema is expected to be stored in its own YAML file, which can be imported like this:
The reverse command,
schema_export expects a directory name as its
sole argument. In the directory, one YAML file will be generated for
each schema that is currently defined in