Type Context

The Purpose of Data Types

Eventful Stories associates every stored fact with a formally-defined data type without exception. The data types are similar to what many programming languages support internally for their data records and for the relationships between records.

A type context functions like a database schema. Eventful Stories provides a language to define its type systems that makes it easy to define type contexts.

The first section describes the simplifying constraints placed on type context designs to promote intuitive understanding. Domain specialists can easily write their own type systems without being database experts.

Two small examples of a type and a type context are presented in the second section, Sample Data Types..

Type Context Design Constraints: What’s Different

Three primary constraints are imposed to render type contexts simpler and more attractive for domain specialists, the main user group invited to use Eventful Stories:

  1. Super- and sub-types
  2. Type-naming rules
  3. Field value declarations and sub-types

Eventful Stories defines a language in which to define type contexts. An example of a full type context definition and a walk-through of its content is given in the technical area of this site. In this general introduction, the three constraints will be briefly covered.

Super- and Sub-types

Types are defined as a hierarchy in the form of a tree. At the bottom are a set of root types. These categorize trunks of the tree saying what everything that depends on that root “is”.

Examples of root types are Person, Event, Time, Company, Phylum, Animal, etc. Roots are broad and foundational.

Every Entity or data type that is not a root has a super-type. An example is a refinement of the root type Time which are more specific expressions of the concept of a time. As chosen by the user, these sub-types of the super-type might be Universal, Local, Century, Ephemeris, and so forth.

Universal time or UT is the time at London for any instant. A definition of the specialization of Time as universal time looks like this:

type Time :> Universal

The notation “:>” means “is the super-type of”. This says that a type is being defined which is a sub-type of Time. The new sub-type is called Universal with the full name Time.Universal. The super-type of Time.Universal is Time.

One can say that TIme.Universal “is-a” kind of Time.

Type-naming rules

Entities are analogous to data tables in a relational database. Indeed, one option for exporting the content of an Evidence Module is as a normalized relational database with meaningful table names.

In a relational database there is no constraint on the naming of tables beyond that the names must be distinct. That is not enough of a constraint to render names meaningful for a user of a system like Eventful Stories. Rather than Time.Universal, its name could be “zorch_17” which conveys no meaning.

The type naming rule that aims to communicate more expressively is that every type declaration such as that for Time.Universal can supply just a one-word refinement label of its own, such as Universal.

A type or root can have any number of immediate sub-types as long as they’re distinctly named. As suggested above, these might be Time.Local, Time.Century, Time.Ephemeris. This is like the constraints placed on directory and file naming in most file systems.

This following example fragment is illegal because there are redundant definitions of Time.Universal:

type Time :> Universal
...
type Time :> Universal
...

Sub-types can to be extended to any depth:

type Time.Universal :> Coordinated
...
type Event.Life.Birth :> Person
...

References to an entity or its sub-types

The super-type and naming rules make it very easy to identify sub-types of an entity since the sub-type must have the name of the super-type entity as the prefix of its full name.

Any type or entity has one or more super types. These are the all the entities on the path towards the root. Since each type has exactly one super-type, and the path ends at root, the set of super-types is well defined and unambiguous.

Attributes are the named record fields containing the values connected to an entity type.

The reason for the super-type structure lies in the attributes or data fields of a type. The set of attributes for an entity is the union of all of its own attributes and all of its super-types.

Here, an Event is defined to contain two attributes, a when and a where. All Events and all sub-types of Events must have these two attributes. This is what makes the super-type structure useful. You know, at a minimum, that every sub-type of Event must at least have these two values supplied.

type Event
    when :: Time
    where :: -> Location

Adding more attributes to the stack of super-type attributes specializes information. Types become more specific at each step down the sub-type tree

When it comes to assigning values to an attribute calling for a Time, any entity value that has Time as a super-type fits the slot when. An instance of any of the types Time.Universal, Time.Local.Baghdad, or Time.Century may be supplied for a Time value.

This structure enables searching and reporting functions to be very general since they can rely on finding what is expressed in the type definition. No matter how complex the sub-typing may be, as long as the data is made up of sub-type instances of Event, a list of Events can always be mapped according to their time and place.

Sample Data Types

A Date Type

A common expression for a date in the US is “YYYY/MM/DD”. The date may be recorded as a set of three integers, with limits to the range of values each may take.

How this storage is carried out requires a template or a specification to ensure understanding and consistency. Without a specification, for example, there will be ambiguity in the order of the month and day. While Groundhog Day (February 2) or Cinco de Mayo (May 5) aren’t ambiguous as to month and day ordering, “2025/3/9” is: it can be understood as either March 9th or September 3rd unless a template or type signature is defined.

The data type context applies this concept to everything, forming a hierarchical structure to impose meaning on every bit of the raw data.

Capturing a date as three integers involves assigning values to a particular record type, or entity. One way to define a date with three integers in Eventful Stories is:

type Time.Date :> Int
    <<A date expressed as three Ints>>
    year :: Int <<The year>>
    month :: Int <<The month of the year>>
    day :: Int <<The day of the month>>

This says that there will be a record or entity in the system whose type is Time.Date.Int, a record of a date as a set of integer values in a defined order.

A Minimal Type Context

The illustration at the top of the page shows the very simple type context used to form type hierarchy for the example of Oppenheimer.

There are three Entities:

  • Identity
  • Event
  • Association

The Identity record contains the name of someone, something or some place, like “Albert Einstein” or “Cambridge University”. The type field distinguishes between naming a Person, Place, or any other named item.

The Event record states that something happened at a certain time and place, and may or may not have had a duration worth noting. The start field gives the starting date, end gives the ending date, if any, and location points to an Identity record giving the locality of the event. What sort of event it was is given by the type field.

The Association record relates an Identity with an Event in a way indicated by the Association Type.

Next: Provenance

In-depth technical information on the type context definition language:

Type Context Definition Language