Links to the Ontology
A semantic model links its elements to the concepts and relationships of a Semantics namespace. This page describes how the Ossie document stores these links.
A link says which business concept an element of the model stands for. For example, the dataset CUSTOMERS stands for the concept Customer, and the field CUSTOMERS.email stands for the property email of Customer. The visual editor writes the links for you when you click Link concept. You need this page when you write the YAML yourself, through the API, or with an agent.
The format follows the embedded form of the Simple Semantic Mapping 0.2.0. Entropy Data checks the links with the EmbeddedSemantics definition of its JSON schema.
Example
version: "0.3.0.dev0"
name: "crm"
nonportable_extensions:
- vendor_name: "ENTROPY_DATA"
data:
id: "crm"
owner: "sales-team"
prefixes:
crm: "https://acme.entropy-data.com/acme/semantics/crm/"
finance: "https://acme.entropy-data.com/acme/semantics/finance/"
datasets:
- name: "CUSTOMERS"
source: "crm.public.customers"
nonportable_extensions:
- vendor_name: "ENTROPY_DATA"
data:
semantics:
- concept: "crm:Customer"
fields:
- name: "email"
expression:
dialects:
- dialect: "ANSI_SQL"
expression: "LOWER(email)"
nonportable_extensions:
- vendor_name: "ENTROPY_DATA"
data:
semantics:
- relationship: "crm:Customer.email"
relationship_type: "hasProperty"
metrics:
- name: "total_revenue"
expression:
dialects:
- dialect: "ANSI_SQL"
expression: "SUM(ORDERS.amount)"
nonportable_extensions:
- vendor_name: "ENTROPY_DATA"
data:
semantics:
- concept: "finance:Revenue"
Where the Links Are
These elements can have links:
- the model itself,
- a dataset,
- a field,
- a relationship,
- a metric.
Each link of an element is in the nonportable_extensions of that element, in the entry with vendor_name: "ENTROPY_DATA". The data of this entry is an object, and its key semantics is the list of links. The list has at least one link. An element without links has no semantics key.
An element has at most one ENTROPY_DATA entry. The same data object can hold other keys of Entropy Data, for example the id and the owner of the model. Entries of other vendors stay as they are.
A Link to a Concept
A link to a concept has only the key concept:
semantics:
- concept: "crm:Customer"
Use it for an element that stands for a thing of the business, for example a dataset that has one row per customer, or a metric such as Revenue. A concept link has no role and no relationship_type.
A Link to a Relationship
A link to a relationship has the key relationship, and optionally role and relationship_type:
semantics:
- relationship: "sales:Order.placed_by"
role: "Customer"
relationship_type: "relatedTo"
A relationship of the ontology connects two concepts, for example Order and Customer, or a concept and a property, for example Customer and email. The concept before the dot plays the first role.
Use a relationship link for these elements:
- A field that holds a property of a concept, for example
CUSTOMERS.emailforcrm:Customer.email. - A field that refers to another concept, for example
ORDERS.customer_idforsales:Order.placed_by. - A relationship of the model that joins two datasets, for example
orders_to_customersforsales:Order.placed_by.
| Key | Required | Meaning |
|---|---|---|
relationship | Yes | The relationship, as a QName or a full IRI. |
role | No | The role that the element plays in the relationship. The value is the role name of the relationship, or the name or ID of the concept that plays the second role. A relationship with more than one role besides the first needs it. |
relationship_type | No | The type of the relationship in the ontology, for example hasProperty, relatedTo, partOf or uses. |
A relationship of the model stands for the whole relationship of the ontology, not for one of its roles. Thus a link on a relationship of the model must not have a role.
How to Write a Reference
A concept or relationship value is a QName or a full IRI.
A QName is a short name of the form prefix:local. In Entropy Data, the prefix is the ID of the namespace:
| Target | QName | Example |
|---|---|---|
| A concept | namespace:ConceptId | crm:Customer |
| A relationship | namespace:ConceptId.relationship | crm:Customer.email |
A full IRI is the complete identifier of the concept or relationship, for example https://schema.org/Customer. Use it for a concept that has an IRI of its own in Entropy Data, for example a concept of an imported ontology.
Entropy Data uses the rule of the Ossie validator to tell the two forms apart. A value is a full IRI in these cases:
- The part after the first colon starts with
//, for examplehttps://schema.org/Customer. - The part after the first colon has a second colon, for example
urn:isbn:0451450523. - The part before the first colon is a URI scheme:
http,https,urn,mailto,tel,file,ftp,data,did,doi,geo,ldap,news,smsortag.
All other values are QNames. Thus a namespace cannot have the ID of a URI scheme, such as urn or tag, in a QName.
Prefixes
The prefixes key in the ENTROPY_DATA data of the model declares the prefixes of the QNames. It applies to the links of all elements of the model. It has the same form as the prefixes map of an Ossie ontology: each key is a prefix, and each value is a full IRI.
nonportable_extensions:
- vendor_name: "ENTROPY_DATA"
data:
prefixes:
crm: "https://acme.entropy-data.com/acme/semantics/crm/"
A QName stands for the IRI of its prefix followed by its local part. With the declaration above, crm:Customer stands for https://acme.entropy-data.com/acme/semantics/crm/Customer.
The IRI of a namespace in Entropy Data is <host>/<organization>/semantics/<namespace>/. This is the base of the IRIs that the SPARQL endpoint gives the concepts of the namespace. The visual editor declares this IRI when you link a concept of a namespace that the model does not declare yet.
Entropy Data still finds the target of a QName by its namespace and ID. Thus a link with an undeclared prefix still resolves, but a save shows a warning. Models from before the prefixes have no declarations, so declare their prefixes when you edit them next.
Validation
Entropy Data refuses to save a model with one of these errors:
- An element has more than one
ENTROPY_DATAentry. - The
dataof anENTROPY_DATAentry is not an object. - The
semanticslist is not valid. For example, a link has bothconceptandrelationship, or a concept link has aroleor arelationship_type. - A link on a relationship of the model has a
role. prefixesis not a map, or a prefix has a value that is not a full IRI.
Entropy Data saves the model but shows a warning in these cases:
- A link does not resolve, because the concept, the relationship or the role does not exist.
- A QName has a prefix that the model does not declare.
Fix a warning later, for example after you add the missing concept to the ontology. When the ontology changes, Entropy Data resolves the links again, and the document of the model does not change.
Older Documents
Ossie 0.2.0.dev0 documents have custom_extensions in place of nonportable_extensions, and their data is a JSON string:
custom_extensions:
- vendor_name: "ENTROPY_DATA"
data: '{"semantics": [{"relationship": "crm:Customer.email"}], "relationship_type": "hasProperty"}'
Entropy Data reads these documents as 0.3.0.dev0, and the next save writes the new form.
In older documents, one relationship_type can be next to the semantics list, not in a link. It applies to each relationship link of the element that has no type of its own. When you edit the element, the visual editor moves the type into these links.
The Standalone Mapping
The links can also be read as a standalone Simple Semantic Mapping document, at /<organization>/semanticmodels/<id>/semantic_mapping.yaml. Each link becomes one mapping. The mapping names its element by the IRI of the model and a fragment such as #model:crm/field:CUSTOMERS.email. A link that resolves names its target by a full IRI: the IRI of the concept or relationship, or else the IRI that the SPARQL endpoint gives it. A link that does not resolve keeps its QName, and its prefix goes into the prefixes header of the document.
The links in the model are the source of truth. The standalone document is read-only.