Discussion:
Reference Naming
(too old to reply)
MG
2010-06-30 07:23:58 UTC
Permalink
We are facing a problem in reference naming. When we create a
reference the name is REFERENCE_% however we would like to apply a
naming convention to this. We changed in the DBMS properties in order
to change the code, however the name still is not correct. How can we
change this?

Thanks in advance.
MG
Mark Brady
2010-06-30 19:24:20 UTC
Permalink
Post by MG
We are facing a problem in reference naming. When we create a
reference the name is REFERENCE_% however we would like to apply a
naming convention to this. We changed in the DBMS properties in order
to change the code, however the name still is not correct. How can we
change this?
Thanks in advance.
MG
You mean you edited the actual DBMS Definition file?
MG
2010-07-02 11:31:41 UTC
Permalink
Post by Mark Brady
Post by MG
We are facing a problem in reference naming. When we create a
reference the name is REFERENCE_% however we would like to apply a
naming convention to this. We changed in the DBMS properties in order
to change the code, however the name still is not correct. How can we
change this?
Thanks in advance.
MG
You mean you edited the actual DBMS Definition file?
Hi Mark,

Thank for the reply.

No. You can edit the rules of the generation of the name in Database >
Edit Current DBMS and then Script > Objects > Reference > ConstName.
The problem is that those rules only apply after you add them. How to
do if we already have a big datamodel that we need to change?

Cheers
MG
rkkier
2010-07-02 13:26:15 UTC
Permalink
On the Integrity tab of the constraint, to the right of the constraint
name, there's the little "User Defined" box, which I'm guessing is
depressed. From what I can tell, that's calculated by comparing the
constraint name against the pattern defined in the dbms file and as
long as your constraint name is user defined, changing the XDB file
doesn't change the constraint name.

You can't change the 'User Defined" attribute in a script; however, if
you clear the constraint name, it will automatically apply the default
and as long as you don't manually change it again, future changes to
the XDB will continue to work.

Here's a little script which will clear them out (it won't cover
packages but you can do that with another loop or a selection).

dim ref

for each ref in ActiveModel.references
output ref.name
output ref.ForeignKeyConstraintName
ref.ForeignKeyConstraintName = ""
next
zecrado
2010-07-06 14:19:27 UTC
Permalink
A next question then:

How to make name and code equals to the constraint name?

Sebastien
rkkier
2010-07-06 18:52:00 UTC
Permalink
dim ref
for each ref in ActiveModel.references

ref.ForeignKeyConstraintName = ""
ref.name = ref.EvaluateTextFor("%.D:ForeignKeyConstraintName%")
ref.code = ref.EvaluateTextFor("%.D:ForeignKeyConstraintName%")

next
MG
2010-07-20 08:06:15 UTC
Permalink
Post by rkkier
dim ref
for each ref in ActiveModel.references
   ref.ForeignKeyConstraintName = ""
   ref.name = ref.EvaluateTextFor("%.D:ForeignKeyConstraintName%")
   ref.code = ref.EvaluateTextFor("%.D:ForeignKeyConstraintName%")
next
This helped a lot cleaning the datamodel. We had a lot of references
not properly named.
We are now almost with our model as we want it.
We defined in Model Options a list of conversion tables to shrink the
size of the and set in the DBMS to get the same name as the code..
The problem is, when we create the reference we would like to set the
name of the reference as a naming convention (example
FK_TABLE1_TABLE2). Then the Code will be generated as FK_TBL1_TBL2 and
the Contraint Name will be the same.

Any idea how to achieve this?

Thanks a lot
MG
rkkier
2010-07-20 18:15:52 UTC
Permalink
I'm not sure if you can change the default name generation
"reference_#" but you can create a custom method or a validation event
in an extended model definition file to set it. Typically, I'd create
a custom method first. That allows you to call the method from the
validation event or a custom menu using executeCustomMethod. The
validation event handler would make sure all your new references are
named correctly and the menu item would make it easy to apply
retroactively to existing models. If you can't figure out the code,
post a reply.

Loading...