in

The ORM Foundation

Get the facts!

How to model contact preferences

Last post Thu, Aug 7 2008 10:30 by Brian Nalewajek. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • Sun, Aug 3 2008 22:41

    How to model contact preferences

    In the attached model, I have a preferred contact time, but I need to indicate which of the phone numbers is preferred. Should I attempt to objectify the three phone-number fact types, and then allow one to play a "preferred" fact type? Or alternatively if I add an enumeration, how do I constrain it so that the enumeration can only apply to a phone number that has been provided?

     What's your modeling preference?

     While I'm here... it seems remiss that there's no forum set aside for asking modeling questions. Any thoughts on that?

     Clifford Heath.


  • Wed, Aug 6 2008 11:08 In reply to

    Re: How to model contact preferences

    Hi Clifford,

    Last first: Yes, a forum or sub-forum for posting models for comment and review is a good idea.  The admin mentioned that the current version of the hosting app has limits for the number of forums; and that limit makes it a problem to add new forums.  He also mentioned looking into a version upgrade.  You can ask him about the status; but I'm guessing that won't be feasible to implement for at least a month or two.  If he does do the upgrade, he'll have a chance to look at restructuring the forums at that time.

    There is an ORM Experience forum that sort of covers this ground.  Perhaps, for model questions that are not tool specific, that would be a good spot for the time being.  If/when the app upgrade tales place, the enhanced features (such as direct paste from VS image copy), will make offering and commenting on model diagrams easier too.  I think more than one sub-forum for this would be useful.  I mentioned an "ORM Style" forum, earlier.  I'd see that less for how to, and more for why do something in a particular way.

    Speaking of style, I've noticed that you often fashion your models in ways that seem a bit unusual to my eyes.  That's not a bad thing; but I find I have to really look closely to understand what's going on (sort of like listening to someone with a strong accent).  Of course, part of that is that as an ORM modeler, I'd want to have a more complete understanding of the UofD, and expectations for the model.

    The first thing I noticed is that you differentiated phone numbers through semantic implication in the predicates: "has mobile-"etc....  I'd probably model that using separate Entity Object Types.  Perhaps, the generic PhoneNumber can be said to be playing the role of being for home use, or business use (so your approach could be valid).  I haven't looked at how that would play out in a generated data structure.  However, you have device types (cellular, land line), and usage (business, personal), blended together.  That makes validating the model's logic more difficult. 

    It's only by looking at the external constraints, that I think I get what you're after: an exclusive preferred path for electronic communication.  A better name than ContactDetails would help make that clearer. 

    I've included a model diagram below (at least I hope I have - I still have problems with posting images here), showing how I might approach the problem.  Without more info about the facts, and data tracking requirements, I can't be sure it covers the bases.  An advantage this approach has is that adding more related facts is straight forward.  For instance, a quaternary predicate Fact Type would allow "Contact prefers CommunicationPath for Use during TimeSlot."  That might provide more useful info to the "Caller."  More Fact Types could show which Communication paths are not allowed or available during times and/or for uses.  I think that's an advantage in establishing the Entity Object Types, rather than using predicate semantic implication.

    Note the use of ".code" reference mode for the super-type.  Phone numbers aren't really numbers; they are character strings - or concatenated character strings, as are email address.  I think "code" serves the purpose.  However, you'll have to look at issues with data-type validation if that's handled by the DBMS (a valid email address doesn't look like a valid phone number).

    You'll also note that I prefer to use full descriptive names (like CommunicationPath) and EmailAddress, in the conceptual model.  I feel these make for more expressive models; and squelch questions as to whether "Email" refers to an address, a message or something else.  I leave it to later to think about appropriate column names in the generated DB.

    Hope the alternative take is useful to you - even if you stick with the predicate based approach.  Your target is a common business requirement, and comparing ways to ORM it is interesting.  Have a SVBR for this fragment?

    I emailed you the image of the model I made, in case it does make it to this post.  I'll also try to upload it on its own later.

    BRN..

     
  • Wed, Aug 6 2008 15:04 In reply to

    Re: How to model contact preferences

    I see, on the forum issues. The top-level list of forums is very non-semantic Smile.

    I use a single valuetype wherever there is a single data type (data-type = value-type in my view, not in NORMA's). Any number I can type into a phone and hope to get an answer is a phone number, whether the other end is a mobile, a landline, or routed to a ship-to-shore radio system. If it mattered, I define a subtype - for example I might want to know that a mobile number will likely cost more to call. Usage is what matters, not the type of device.

    But for the rest, yes, I use adjectives freely and intentionally. CQL raises them to first-class identifiers within the played concept's roles, unlike ORM.

    I agree I should have named ContactDetails "ContactMethods". Person has ContactMethods, ContactMethods includes home-Phone, etc.  I also changed PhoneNumber from a value type to an entity type Phone(.Nr).

    Your model lacks a distinct datatype for email addresses, as you point out. This is completely unacceptable to me, as both datatypes will be associated with all kinds of funky validations at the application level - these matter much more than the database validations.

    I also have no need to model device type or use, or timeslots, or preferences for more than one device. All I need is a simple way to write down the various contact paths, and to capture the information in the common expression "Best if you call me at home around 8PM". Since email doesn't have a time dimension, it doesn't get used this way, so may be used e.g. if none of the phones get answered, or after trying the preferred phone. Note that a phone may be preferred without a time, or a time without a phone.

    I see three ways to model this:

    • Just add a fourth phone-number "ContactMethods includes preferred-Phone", and require that it match one of the three. I don't like this one because it duplicates the value.
    • Use a ternary instead of three fact types, with one role being the number's usage, constrained to three values. I haven't tried this, but can't imagine it maps well - I bet it makes a new table instead of denormalising.
    • Add a unary to Phone "is preferred", then use a join uniqueness constraint to ensure only one of a set of three plays it. That's not possible in NORMA at the moment, and without the constraint you get three boolean fields, one for each number. However I think it's the right answer.

    The natural way to do this for a CS guy would be to use a single enumeration and store a value, but that's not very semantic and I can't see how an ORM tool would know to create it from a semantic model. Hence my original question, which stands.

    SBVR: I don't really do that. The CQL for my revised model (without preference) follows. The disjunctive mandatory constraint wording is a little clunky, but the pattern works for many kinds of constraints. I also support the alternate "for each X, at least one of the following holds: ...". I might refine the generation or provide improved syntax, this area is quite new.

    ContactMethods is identified by mobile-Phone and home-Phone and business-Phone and Email where
            ContactMethods includes at most one mobile-Phone,
            ContactMethods includes at most one home-Phone,
            ContactMethods includes at most one business-Phone,
            ContactMethods includes at most one Email;
    each ContactMethods occurs at least one time in
            ContactMethods includes mobile-Phone,
            ContactMethods includes home-Phone,
            ContactMethods includes business-Phone,
            ContactMethods includes Email;

    Thanks,

    Clifford. 

  • Thu, Aug 7 2008 10:30 In reply to

    Re: How to model contact preferences

    Tried again to upload image of ORM model.  The C-S application doesn't seem to accept my URL.  No notice given on insert failure.  I'll check the site help section to see if I'm missing some step.  Hope a better way to include images in posts is in the works.  I did upload the .ORM file in the NORMA section of the library. 

    BRN


Page 1 of 1 (4 items)
© 2008-2024 ------- Terms of Service