-
Notifications
You must be signed in to change notification settings - Fork 15
Instance
An instance is a way to populate a schema with data. For each entity, it describes which are its possible values.
An instance is described providing some generators and some equations, like in the following example
instance MyInstance = literal : MySchema {
generators
a b c : Employee
m s : Department
equations
first(a) = Al
first(b) = Bob last(b) = Bo
first(c) = Carl
name(m) = Math name(s) = CS
age(a) = age(c)
manager(a) = a manager(b) = c manager(c) = c
worksIn(a) = m worksIn(b) = s worksIn(c) = s
secretary(s) = c secretary(m) = a
secretary(worksIn(a)) = manager(a)
worksIn(a) = worksIn(manager(a))
age(a) = "1"
age(b) = "5"
where each generator correspond to a "row" of its entity "table" and the equations define the attributes and the forreign keys of the entities, in such a way that the path_equations
of the schema are satisfied.
An instance is a functor from the category presented by the schema to the category Set
. This means that for every entity
we need to associate a set of elements, which can be tought as the rows of the table. Moreover, for every foreign_key
of the schema, which is nothing else than a morphism in our starting category, we need to associate a function in the Set
category. Specifically, if we have a foreign key worksIn : Employee -> Department
, we need to define a function from the set of Employee
s to the set of Department
. In other terms, we need to say, for every employee, to which department he belongs to.