I see, on the forum issues. The top-level list of forums is very non-semantic .
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.