-
Notifications
You must be signed in to change notification settings - Fork 0
API Logic
Introduction to Set notation (click arrow to read)
Set notation
The API logic will be described in Set notation due to its theoretical basis and compactness.
For our purposes, a set is a collection of distinct objects. Sets will be named using capital letters,
Subscripts may also be used to distinguish specific subsets,
The Union of two sets is a set containing all of the objects which are contained in either, or both, of the two sets. The
The Intersection of two sets is a set containing all of the objects which are contained in both sets. The
Two important results from Set theory are that:
If all of the members of a set,
The reverse of this notation is
A property,
We will use
Specific to this API we will work with the following sets:
Set | Description |
---|---|
The set of all archives | |
The set of all collections | |
The set of all documents | |
The set of all entities (actors, locations, events, objects) |
There is an explicit hierarchical structure in the first three entries (which we will call Hierarchical Entities when necessary). Archives contain collections which contain documents. When generalising to any hierarchical entity we will use the set
Since each of the four sets
Subsets of
For two sets of different types (e.g.)
Where the two sets are of the same type the intersection (and union) are used as normal. Two sets of the same type will use the same capital letter but with different subscripts (e.g.
Entities are a separate case as they may be related to any of Archives, Collections, Documents. For example, a document may have been written by a person, there may also be a collection of documents belonging to a person, and in exceptional cases an archive dedicated to a person.
In linked data the Entities are related to the hierarchical entities but for the purposes of the API they will be modelled as properties. Again for the sake of clean notation we will use shorthand and the Intersection symbol between Hierarchical Entities and Entities will imply that the hierarchical entity has an entity as a property.
We will use the notation
As a more concrete example, if
Since entities can be linked to any level of the hierarchy, the symbol
graph TD;
Archive-->Collection;
Collection-->Document;
Archive-->Entity;
Collection-->Entity;
Document-->Entity;
Entity-->Entity;
An API Query will be of the form:
where the subsets $A{1} ..., C_{1} ... $ etc. are optional.
A subset
For example, a Document has a Name (the title) but was also created by a person (Actor), at/during a time (Event). That person has a Name, but they in turn were born somewhere (Location), on a day (Event).
When building a query each filter applied will generally result in an Intersection operation between sets. The exception to this is when multiple filters of the same type are included, in which case a Union operation is used.
Example:
Set
Set
The final part of the API call was the filter by Entity (
For subsets
The API will return one of Archive, Collection, Document, Entity. For a query
Q1. Archives with name "X"
> $p_{1}$ is the property with name = "X"; $p_{2}$ is the property with type = "Location"; $E_{1} = E \cap p_{1} \cap p_{2}$
> The query returns $A_{1} = A \cap E_{1}$
Q2. Archives with documents created in year Y
> $p_{1}$ is the property with name = 'created' and date value = Y and type = "Event"; $E_{1} = E \cap p_{1}$
> This returns Documents, $D_{1} = D \cap E_{1}$
> The final query returns $A \cap D_{1}$ which is the set of all Archives containing the documents in $D_{1}$