Need more? Keep going!

By using a consistent data format we maximize opportunities for reusing components and extending xaps. We use an Entity-Attribute-Value (EAV) model to describe the data, and we use something called duffles to send the data from component to component. 


This article will explain what these terms mean and how they work together. After reading this article, you'll want to read the article on the Type System (part 2 of 3)




Entities, Attributes, and Values


An entity is an item, e.g. a person, place, or event. Entities have attributes, like height, location, or time. Attributes have values, like 6'4" or 8:45a.m. (If you are familiar with RDF, this is similar to the subject-predicate-object model.)


In the example below, each entity (representing a person) has the attributes user, age, and team_members, with their corresponding values.  If you're familiar with tables from Excel or SQL databases, each row is represented by the entity, a column by the attribute, and the cell at the intersection of each row and column by the value. 


Here's the syntax for representing an entity and it's attributes and values. Each entity is inside a pair of curly brackets {  }. Then there's the attribute-value pair, in that order separated by a colon, e.g. user (an attribute) and John Smith (the value). 

   


m[
{
"user": "John Smith", 
"age": 47, 
"team_members": ["Ben Thompson", "James Simpson"], 
"name": "John Smith", 
"nationality": "American"

}, 
{
"user": "James Simpson", 
"age": 33, 
"team_members": ["Ben Thompson", "John Smith"], 
"name": "James Simpson", 
"nationality": "Canadian"
}
]

 

So what are the square brackets? Keep reading...


Duffles


There are multiple entities (with their attributes and values) inside the brackets in the snippet above. They are packaged as a duffle. Duffles are the way Exaptive sends data from component to component in way they all understand. A duffle is a relation, a familiar concept in database theory. But the Duffle model departs from the usual usage of relations in database applications in two ways:



  • A duffle is expected and encouraged to be sparse. This means that many entities within the duffle may have null values for many of their attributes. This allows entities of different kinds to be stored together within a single duffle, and also allows free-form heterogeneous graph building as in RDF or EAV modeling.
  • Entities within a duffle may have multiple values for a given attribute if the value for an attribute is an array. 
     

Check out the snippet again. The duffle is denoted by the square brackets [ ]. The team_members attribute is an array with multiple values.

 

m[
{
"user": "John Smith", 
"age": 47, 
"team_members": ["Ben Thompson", "James Simpson"], 
"name": "John Smith", 
"nationality": "American"

}, 
{
"user": "James Simpson", 
"age": 33, 
"team_members": ["Ben Thompson", "John Smith"], 
"name": "James Simpson", 
"nationality": "Canadian"
}
]

 

If you're familiar with arrays of JavaScript objects or lists of Python dictionaries, you'll note that a Duffle is similar in more ways than it's different.


That "m" before the square bracket tells you what data type that duffle is. In this case it's a multiset.


Read about the Type System (part 2 of 3) to understand data types and how to pass data from component to component.