# A Graph DB-Based Solution for Semantic Technologies in the Future Internet
## 3 GraphBRAIN Framework
### Summary of the GraphBRAIN Schema Formalism  
The GraphBRAIN framework allows us to specify ontologies by providing an LPG-based structure and an associated formalism. The LPG-based structure allows a more intuitive description of the ontological components with a clear distinction among entities (or classes), relationships, and their attributes. Various options can be specified for the different components. It is formally specified as an XML file with the extension GBS (GraphBRAIN schema). In the following text, we provide brief descriptions of the latest version of this structure and the formalism. The root tag of the XML file, enclosing all of the ontology elements, is **domain**, where the ontology name and attributes, such as creator and date, can be specified. This tag encloses four sections, each specifying a different ontological element. The first schema fragment is identified by the tag **imports** and allows us to include other existing ontologies in the current ontology, in this way supporting reuse and interoperability. Each imported ontology is specified in an **import** tag. Imported ontologies must be compliant with each other and with the ontology being defined in the file, meaning that the hierarchical structure of the entities and relationships and the type of attributes must be consistent (e.g., if class \(C^{\prime}\) is a subclass of class \(C^{\prime\prime}\) in one ontology, \(C^{\prime\prime}\) cannot be a subclass of \(C^{\prime}\) in the other). The same entities, relationships, and attributes of different ontologies are identified by the same name. The next fragment, identified by tag **types**, encloses user-defined datatypes, each of which can be a list of values (datatype Select) or a hierarchical organization of values (datatype Tree). The third fragment, identified by the tag **entities,** defines the entities (whose instances will be the nodes in the graph), each enclosed in a tag **entity** with a _name_ XML attribute (which will be the node label in the graph). The last fragment, identified by the tag **relationships** defines the relationships (whose instances will be the arcs in the graph), each enclosed in the tag **relationship** with _name_ and _inverse_ XML attributes, defining the name of the relationship (which will be the arc label in the graph, associated with the arc direction) and of its inverse (implicitly associated with the opposite arc direction in the graph). Additional Boolean XML attributes allow us to specify the relationship properties (e.g., if it is transitive). The relationship is implicitly assumed to be symmetric if its name is the same as the inverse name. Each **entity** or **relationship** tag may enclose an **attributes** tag (mandatory for entities), where the various attributes of the entity or relationship can be defined (note that the RDF graph model used in the standard SW does not natively allow for relationship attributes) and, optionally, a **taxonomy** tag, where subclasses or subrelationships can be specified using nested occurrences of the **entity** tag. The tag **taxonomy** is recursive to allow the definition of hierarchies of classes or relationships, for which the inheritance of properties is supported. So, each subclass/relationship must only specify the additional attributes it introduces with respect to all of its ancestors (if any). **relationship** tags also include a **references** tag to specify the possible Subject-Object pairs for the relationship, each specified by a **reference** tag with XML attributes _subject_ (a possible entity for the arc source) and _object_ (a possible entity for the arc sink). Each entity or relationship attribute is introduced by an **attribute** tag with the XML attributes **name** and **datatype**. The datatype can be a predefined one (GraphBRAIN provides Boolean, Integer, Real, String, Text, Select, Tree, Date, or Entity) or a user-defined one (defined in the **types** section of the XML file).