The ORM Foundation

Get the facts!

Model THIS!

Last post Mon, May 10 2010 19:19 by Anonymous. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • Thu, May 6 2010 9:20

    • OrionB
    • Top 50 Contributor
    • Joined on Thu, Apr 3 2008
    • Tualatin OR
    • Posts 19

    Model THIS!

      I love modelling stuff with ORM. I often find myself visiting these forums, looking for something I can hone my modelling skills on, posting a diagram of what I think the poster described.

     The forums aren't all that lively, currently. It seems a good portion of the posts tend to follow the pattern of "I see This, Here, but think it should be Something Else" (or "I See This, Here, what does it mean?") followed by a reply by one of our resident Wise Ones telling why it is so, whether there are plans to change it, or what the thing means.

     Something I would enjoy is a section where a poster can describe a small scenario, and others can add how they might model it and ask the questions left ambiguous by the description. This would help me keep my skills sharp, and perhaps even increase them - both in writing down the scenarios with as few ambiguities as possible and in turning the stuff added by others into a diagram with questions.

    The section title could be:  "Model THIS!"  

    Its purpose would be to help ORM practitioners hone their skills, helping them be better able to support the application process with a rock-solid diagram for it to be built with.

    (will reply soon with an initial Universe of Discourse to model)


  • Thu, May 6 2010 9:43 In reply to

    • OrionB
    • Top 50 Contributor
    • Joined on Thu, Apr 3 2008
    • Tualatin OR
    • Posts 19

    Re: Model THIS!

     (This is the first in what hopefully will be a series of threads in which the poster adds a scenario to model, and others can respond with diagrams showing how they'd model it and questions on parts of the description left out or left ambiguous)


    model THIS:


    The New Hampshire Feline Appreciation club is hosting a Cat Show next October. Although this is the first cat show they have hosted, the aim is to make it an annual event. 

     The cat show will be made up of a series of events, which may change from year to year. (e.g. next year, they may add a new event)  Each event has a name, a starting time, and ending time and an day for the event to occur on. (e.g. Show Day 1, Show Day 2)  Not all of the events must involve cats, such as the Cat Show Buffet held on the evening of the first day.

     Each cat that is registered for the show is given a special identification collar. The collars come in 6 different colors. (this year) The organizers wish to reuse these collars in future shows, and each collar has a unique Collar Number inscribed on it.

     Each cat has a name, a breed, and a Fur Colour. (Several cats have more than one fur colour) They also have an owner, or owners. For the owner, the show organizers wish to record a first name, last name, and a contact phone number. It is allowable for a person to enter two cats in the show, but no more than two.

     Cats are given a score for each event they participate in.  It is not required that every cat participate in every event. (though missing an event means missing points!) The Grand Prize at the end of the show is given to the cat and owner(s) with the highest total score. Ties are allowed.







  • Mon, May 10 2010 11:07 In reply to

    Re: Model THIS!

    Alright, I gave it a go, in CQL. Note: this uses features of CQL that aren't yet released, and even a couple that aren't yet implemented Smile. I didn't produce the derivation for the grand prize, but a derivation for the first three prizes for each event is given (if there's an equal first, next will be third place).

    I can't preview this; I hope the forum doesn't make it unreadable.

    vocabulary FelineAssociationShows;

    Feline Association is identified by its Name;
    example: FelineAssociation 'New Hampshire Feline Appreciation Club';

    Year is written as Integer restricted to {2000..};
    Month is written as Integer restricted to {1..12};
    Day of Month is written as Integer restricted to {1..31};
    Hour is written as Integer restricted to {0..23};
    Minute is written as Integer restricted to {0..59};
    Time is identified by Hour and Minute where
        Time has one Hour,
        Time has one Minute;

    Show is where
        Feline Association holds show in Year;
    Show is held in at most one Month;
    Show starts on one Day of Month;
    Show Day is written as Integer restricted to {1..};

    example: /* compound fact  instance with an objectification join */

       Show (where FelineAssociation 'New Hampshire Feline Appreciation Club' holds show in Year 2010)
        is held in Month 10;

    Event is identified by its Name;
    example: Event 'Cat Show Buffet';
    example: Event 'Best Burmese';

    Show Event is where Show includes Event;
    Show Event is called at most one Name;
    Show Event starts at one Time (as StartTime);
    Show Event ends at most one ending-Time;
    Show Event is held on one Show Day;

    PhoneNr is written as String;
    Cat Owner is identified by first Name and last Name and contact Phone where
        Cat Owner is called one first-Name,
        Cat Owner has one last-Name,
        Cat Owner has one contact-PhoneNr;

    Cat is identified by its Name;
    Cat Breed is identified by its Name;
    Cat is of one Cat Breed;
    Fur Colour is written as String;
    Cat Fur Colour is where
        Cat has at least one and at most three Fur Colour;
    Cat belongs to at least one Cat Owner;
        Cat Owner owns Cat;

    Registered Cat is where
        Cat is registered for one Show;

    // External join frequency constraint - not currently supported by CQL compiler:
    for each Cat Owner, Show:
        Cat Owner owns at most 2 Cat which is registered for Show;

    Collar is identified by its Number;
    Registered Cat is assigned one Collar;

    Participation is where
        Registered Cat participates in Show Event,
        Show Event is entered by Registered Cat;

    Score is written as Integer;
    Participation is awarded at most one Score;

    Event Prize is identified by Show Event where
        Event Prize is awarded for Show Event,
        Show Event has at most 3 Event Prize;

    // Derived fact type:

    Registered Cat receives Score in Show Event where
        Participation (where Registered Cat participates in Show Event) is awarded Score;

    // If there's a tie (equal first, say), the next place will be third:
    Registered Cat receives Place for Participation in Show Event where
        Registered Cat receives Score for Participation in Show Event,
        Place = count(
            other-Participation (where other-Registered Cat participates in Show Event) is awarded other-Score,
            other-Score > Score
        ) + 1;

    Event Prize in Place is awarded to Cat Owner for Participation where
        Event Prize is awarded for Show Event (where Show includes Event),
        Registered Cat (where Cat is registered for Show) receives Place for Participation in Show Event,
        Cat belongs to Cat Owner,
        Place <= 3;

    // and similarly for grand prizes...

  • Mon, May 10 2010 12:22 In reply to

    • OrionB
    • Top 50 Contributor
    • Joined on Thu, Apr 3 2008
    • Tualatin OR
    • Posts 19

    Re: Model THIS!

     Thanks, Clifford!

     This has served as my own introduction into Constellation Query Language. (CQL) Speaking for myself, I would have found it quicker and easier to read a diagram. Still I can see that presenting something in natural language would make it easier to collaborate with someone who knows the domain but not what the little boxes and lines mean in a diagram. 

     I've often found myself writing something like this to help explain what a diagram I'm showing someone is saying, but it has usually been as a part of trying to teach the art of diagram reading. Having this generated would be a great help in getting  to the meat of the conversation. I'd just need to make sure to feed it some quality example information, and read through it to make sure the statements' phrasing still makes sense.

     So again, thanks for the introduction to what CQL can do! I'm looking forward to seeing more of it.

     Was this derived from a diagram that you built? If so, I would like to see that as well.

  • Mon, May 10 2010 19:19 In reply to

    Re: Model THIS!

    I would have found it quicker and easier to read a diagram

    Certainly - the natural language and diagrams are both necessary adjuncts. CQL is aimed at improving collaboration of the kind you note, but plain text has other advantages too. It is easy to write and ship around in email, easy to analyse two versions for differences, easy to merge, etc. CQL also contains all of the model, including the parts that ORM tools hide in property panes, like data types (though I've not added maximum lengths, etc, here). In addition, CQL contains join constraints and a fact type derivation (aka query) language which is all one piece with the model; there's no shift from diagram to text as with ORM.

    Much more material on CQL is available from my website, including a 48-minute video screencast (though none of it is yet updated to show the recent capability of using multi-word terms, as in this model). A version of the ActiveFacts generator is also available in open source.

    Was this derived from a diagram that you built?

    I wrote this one from scratch, but I've published many models that are generated from diagrams - see The ActiveFacts generator can produce CQL from a NORMA diagram. You need to be a little bit careful with fact type readings (not to use object type names, keywords like 'and', etc), but this actually improves the readings.

    I'm working on my own diagramming tool called APRIMO, which functions as a web page in any modern browser, and saves changes incrementally to a web server. It uses a different mouse interaction model which is much quicker than NORMA's. In future, it will also push changes to (and accept changes from!) any other folk watching the same diagram. I expect that the combination of universal access (nothing to install) and real-time collaboration over combined graphical and verbal (even multi-lingual!) versions of the same model will be a potent brew. Add end-user queries to the mix and you have a very plausible enterprise-level product. Or so I hope...

Page 1 of 1 (5 items)
© 2008-2022 The ORM Foundation: A UK not-for-profit organisation -------------- Terms of Service