An MDELite Allegory Model


We recently made a connection between UML class diagrams and allegories -- categories that have power set domains.  Here's the idea: a natural way to think about tuples in categories is by a domain of tuples.  But what we really want in a relational database interpretation is a power set of tuples -- elements of this domain are sets of tuples -- i.e., relational tables.  Arrows in this universe map tables-to-tables; this is exactly what relational algebra does.

Below is a UML class diagram that relates persons to the departments that they work in, departments to the divisions in which they reside, and persons with children (who are also persons):



An allegory (category) with power domains is shown below. Arrow traversals are rightSemiJoins. A database that encodes these relationships is shown below:

---column1---
---column2---

Given this, here are some queries (easily transformed into constraints) that one can express.  Note how compact they are.


The above program, and the hand-written Java class that implements these arrows is in MELite7/LectureExamples/allegory. The current version of the allegory program is shown below.

Please note that this source, which is in the LectureExamples directory of MDELite7, is a single file with nested classes.  Study it in detail -- the main ideas are shown below.

---catdb---
class Department extends common<Department> {
---Department---
class Person extends common<Person> {
---Person---
abstract class common<T extends common> {
---commonT---
class Division extends common<Division> {
---Division---
class childrenOf_parentsOf extends common<childrenOf_parentsOf> {
---CP---
class employs_worksin extends common<employs_worksin> {
---EW---

A Catalina (MDELite-bootstrapped) specification of this design is:



And a generated version of the above source is here.