ActiveFacts Example Models

Copyright (c) 2007 Clifford Heath.

This page introduces my example models in both ORM2 and CQL. The CQL files are exactly as generated from the ORM2 versions, but you could have written them by hand. Either type of file can be converted to SQL or Ruby, using the relational and object-oriented mapping algorithms implemented in the ActiveFacts generator afgen. The output files from these conversions are available here, as are the PNG images of the ORM2 versions.

The example models presented here were created as Object Role Models using NORMA. A selection of the basic models is discussed below, and a full table below that.

To make a start learning Object Role Modeling, read the Introduction to ORM2 or check the Resources page for other sites.

The CQL code here is formatted and laid out is exactly as it was generated. It's interesting how cleverly the semantic clustering algorithm works!

If you're looking at a Subversion checkout of the project on Windows, and have Visual Studio (pro) with NORMA installed, you can open the solution here. Otherwise, you won't be able to edit the ORM2 files, but never fear, you can do all the same things by editing the CQL text.

CompanyDirectorEmployee

This is my main introductory model. It shows the relationships of a person to a company of which they are a director or employee.

Blog

The Blog model supports a hierarchy of topics, Posts by Authors, each Post consisting of a series of styled Paragraphs. Comments may be made on individual Paragraphs.

SchoolActivities

This model represents students representing their school in school-sanctioned activities. It includes the ternary StudentParticipation Fact Type, which represents a student's participation in a school-sanctioned activity. The model has constraints that allow a given Student to participate only in a given Activity for a single School, only representing the School in which they're enrolled, and only if the School sanctions that activity.

Orienteering

A model for the sport of Orienteering, broken into three diagrams for administration, registration and scoring. These diagrams also reflect areas of interest to folk in different roles, an idea which could inspire the use of the division as security domains. However, for an object showing on multiple diagrams, ORM2 doesn't indicate with which diagram it has a primary affinity. In CQL, it might be better to structure this as three separate vocabularies.

The author is involved in orienteering in his local association (which publishes a program and results at street.orienteering.com.au and the Victorian Orienteering Association) and he used this model to construct a scoring system using low-power microprocessors distributed around the course.

Metamodel

The Metamodel encodes the meaning of an ORM2 or CQL model. All features of the ORM2 and CQL languages have a representation here, as well as a few CQL features that haven't yet been implemented yet. The generated Ruby code is used as the intermediate form inside the CQL language implementation.

Table of all examples

Model Name ORM2 Diagrams
Address (orm) CQL Ruby SQL Address
Blog (orm) CQL Ruby SQL Blog
CompanyDirectorEmployee (orm) CQL Ruby SQL CompanyDirectorEmployee
Death (orm) CQL Ruby SQL Death
Genealogy (orm) CQL Ruby SQL Genealogy
Insurance CQL Ruby SQL Insurance
Person
Policy
Claim
VehicleIncident
Related
JoinEquality (orm) CQL Ruby SQL JoinEquality
Marriage (orm) CQL Ruby SQL Marriage
Metamodel CQL Ruby SQL Objects
Terms
ValueTypes
Constraints
Units
Joins
Values
Populations
Context
MultiInheritance (orm) CQL Ruby SQL MultiInheritance
OilSupply (orm) CQL Ruby SQL OilSupply
Orienteering (orm) CQL Ruby SQL Administration
Registration
Scoring
OrienteeringER (orm) CQL Ruby SQL OrienteeringER
PersonPlaysGame (orm) CQL Ruby SQL PersonPlaysGame
RedundantDependency (orm) CQL Ruby SQL RedundantDependency
SchoolActivities (orm) CQL Ruby SQL SchoolActivities
SimplestUnary (orm) CQL Ruby SQL SimplestUnary
Warehousing (orm) CQL Ruby SQL Warehousing
WindowInRoomInBldg (orm) CQL Ruby SQL WindowInRoomInBldg