ORM constraints

L

Lenka

Hello,
I am trying to use ORM for the modeling databases. Even I decide to
write my final thesis concernig to that. However I have a lot of
unclearnesses, I have one basic question about constraints.
I mean the external constraints of uniquenesse, mandtatory roles,
constraints of value, derived rules, subset, exclusion, subtype...

Do they have any significance in the logical model done by MS Visio EA
2002?
I mean I can not see any signs on that logical model, and after also
on the generated database. So it's mean I don't use them later. Just
for that ORM conceptual model. So why they are necessary?

You know I am quite beginner, I don't have any teacher of that ORM.
But anyway I am interested in that.

Thank for your help. Lenka
 
S

Scot Becker

Hi Lenka,
I am trying to use ORM for the modeling databases. Even I decide to
write my final thesis concernig to that. However I have a lot of
unclearnesses, I have one basic question about constraints.
I mean the external constraints of uniquenesse, mandtatory roles,
constraints of value, derived rules, subset, exclusion, subtype...

Do they have any significance in the logical model done by MS Visio EA
2002?

The short answer is: Many of these constraints do show up in the logical
model (and are implemented in the resulting DDL), some don't show up in the
model (but are implemented in the resulting DDL) and some are left for the
designer/coder/whoever to implement.

Uniqueness is generally implemented as alternative/primary keys on the ERD
and in the DDL. I'd have to check, but cross table unique constraints
(although rare) might get implemented as a stored procedure that you would
have to wire up to a trigger. Non-Unique index "constraints" (e.g. the I
symbol) map directly to table indices.

Mandatory constraints end up as not null clauses for single-role constraints
and check clauses/SP for disjunctive mandatory constraints.

Value constraints end up as check clauses (but not on the ERD).

Subset, equality, and exclusion constraints often end up as check clauses
and sometimes SPs (but not on the ERD). Same goes for frequency constraints.

Subtyping gets implemented depending on the mapping choices (all in one
table, children as separate tables, etc.) and that will show up on the
diagram and in the DDL. However, the subtype declaration rule is not
implemented because there is no formal language support and as such code
cannot be generated for any random text string entered by the modeler.

Derivation is partially implemented: if you select "derive and store" it
will create a column. However, it will not code the derivation rule for the
same reason as above.
I mean I can not see any signs on that logical model, and after also
on the generated database. So it's mean I don't use them later. Just

ER (and UML, for that matter) is less expressive than ORM when it comes to
constraints and as such, many constraints are not expressible using ER and
thus don't show up.
for that ORM conceptual model. So why they are necessary?

Since many of them still get coded in the DDL, it is still valuable to
create those ORM constraints As for the ones that aren't automatically
generated, it is still a valuable exercise because you thought about the
constraint and then documented it, better ensuring that you might remember
to code for it.

Hope that helps,
Scot.
................................................
Scot Becker

Orthogonal Software
www.orthogonalsoftware.com

ORM Blog: www.objectrolemodeling.com

To e-mail me, please use my first name at the domain listed above. All mail
sent to the reply-to address gets routed to a junk e-mail folder where it
will likely be deleted without being read.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top