Constraint naming standard
By Michael Bryzek
OpenACS docs are written by the named authors, and may be edited
by OpenACS documentation staff.
-
Constraint naming standard is important for one reason: The SYS_* name oracle
assigns to unnamed constraints is not very understandable. By correctly
naming all contraints, we can quickly associate a particular constraint
@@ -10,14 +10,14 @@
Why do we need a naming convention?
Oracle limits names,
in general, to 30 characters, which is hardly enough for a human readable constraint name.
-
Format of constraint name
+
Format of constraint name
<table name>_<column_name>_<constraint abbreviation>
In reality, this won't be possible because of the character limitation on
@@ -27,7 +27,7 @@
Truncate the column name until it fits.
If the constraint name is still too long, you should consider rewriting your
entire data model :)
-
Notes:
If you have to abbreviate the table name for one of the constraints, abbreviate it for all the constraints
If you are defining a multi column constraint, try to truncate the two column names evenly
+Notes:
If you have to abbreviate the table name for one of the constraints, abbreviate it for all the constraints
If you are defining a multi column constraint, try to truncate the two column names evenly
create table example_topics (
topic_id integer
constraint example_topics_topic_id_pk
@@ -51,7 +51,7 @@
constraint cne_example_id_one_line_unq unique(example_id, one_line_description)
);
-
Why it's good to name primary keys
Naming primary keys might not have any obvious advantages. However, here's an
example where naming the primary key really helps (and this is by no means
a rare case!
@@ -72,7 +72,7 @@
Isn't it nice to see "EXAMPLE_TOPICS_TOPIC_ID_PK" in the trace
and know exactly which table oracle is using at each step?
-
Naming not null constraints is optional...
People disagree on whether or not we should be naming not null
constraints. So, if you want to name them, please do so and follow
the above naming standard. But, naming not null constraints is not a