in

The ORM Foundation

Get the facts!

Collections with repeating (duplicate) items

Last post Thu, Apr 30 2009 5:33 by Martin Dvorak. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • Wed, Apr 29 2009 9:18

    • Martin Dvorak
    • Top 75 Contributor
      Male
    • Joined on Thu, Mar 5 2009
    • Prague, Czech Republic
    • Posts 5

    Collections with repeating (duplicate) items

    Hi, I still haven't received my copy of the ORM book so I apologize if this is a stupid question, but is it possible to use ORM to model collections which allow duplicate items? I can imagine list (ordered collection allowing repeating items) being modeled using ternary fact type with the third role player being the order value, but how a bag (collection allowing repeating items with no particular order) would be modeled? For example "Car(.Id) has CarPart(.Id)", where Car can have many parts and it can have more then one CarPart of the same type. What would be the best way to model this fact? Is the only solution to somehow replace the binary fact type with ternary again to satisfy the requirement for internal uniqueness constraint? Thanks, Martin
  • Wed, Apr 29 2009 21:36 In reply to

    Re: Collections with repeating (duplicate) items

     Hi Martin

      Good question.  Modeling of collection types of various kinds (sets. ordred sets, bags, sequences, and arrays) is discussed in section 10.4 of the book. But the quick answer is that for asserted fact types, ORM currently requires at least a spanning uniqueness constraint. So the populations of asserted fact types are always sets of facts (no duplicates allowed). Currently we use a ternary as you suggest for modeling lists (a.k.a. sequences or ordered bags), For example, to store a list of prize winners for lotteries use "Lottery awarded prize of Rank to Person", where a UC spans the first 2 roles, and Rank {1..} indicates the prize order (1st prize, second prize etc.).

     As discussed in section 10,4 of the book, there are some versions of fact-oriented modeling that do support modeling collections directly, but such structures must be used with great care and are awkward to popluate etc. We plan to have NORMA support a mapping choice so that you can choose to use such collection types at the implementation level, but we do not feel they are appropriate at the conceptual level.

    Cheers

    Terry

  • Thu, Apr 30 2009 5:33 In reply to

    • Martin Dvorak
    • Top 75 Contributor
      Male
    • Joined on Thu, Mar 5 2009
    • Prague, Czech Republic
    • Posts 5

    Re: Collections with repeating (duplicate) items

    Terry, thanks very much for the clarification.
    Martin
Page 1 of 1 (3 items)
© 2008-2024 ------- Terms of Service