This is a draft cheat sheet. It is a work in progress and is not finished yet.
General rules
EVERYTHING |
Give meaningful names |
If not possible |
Explain with comments |
Page-width |
120 characters per line |
Case |
lower case |
Funcs & Procs |
Everything should be in packages |
Variables
Length |
30 characters |
Global Variable |
g_<variable_name> |
Local Variable |
l_<variable_name> |
Boolean Variable |
b_<variable_name> |
Type |
t_<type_name> |
Constant |
c_<constant_name> |
Cursor |
cur_<cursor_name> |
Formal Input Parameter |
i_<parameter_name> |
Formal Output Parameter |
o_<parameter_name> |
Formal In / Out Parameter |
io_<parameter_name> |
For Loop Record |
r_<entity> |
Constraints
Primary key |
Table : WORKING_SETS |
|
Primary Key : WORKING_SETS_PK |
Foreign keys |
Relationship : DEVICES to DEVICE_CLASSES |
|
Foreign Key : DEVICES_DEVICE_CLASSES_FK |
Unique keys |
Table : WORKING_SETS |
|
Unique Key : WORKING_SETS_UK |
Check constraints |
Table.Column : DEVICES.FEC_NAME |
|
Check constraint : DEVICES_FEC_NAME_LC_CK |
Not null constraint |
Table.Column : DEVICES.FEC_NAME |
|
Not null constraint : DEVICES_FEC_NAME_NN |
|
|
Indexes
Primary keys Unique keys |
Automatically have the same name as the constraint Let it |
Single |
Table.Column : DEVICES.ALIAS |
|
Index : DEVICES_ALIAS_I |
Multiple |
Table.Column : DEVICES.CLASS, DEVICES.MEMBER |
|
Index : DEVICES_CLASS_MEMBER_I |
Synonyms
Should not have any suffix to hide the implementation |
Triggers
To avoid when possible. |
To avoid when possible. Can be necessary for technical operations (add dates/user to INSERT) or functional (less common) |
Parameter Modes
Define the mode (in, out, in out) |
Provide default when appropriate |
Sequences
Table : DEVICES |
Sequence : DEVICES_SEQ |
Views
Views |
<name>_V |
Materialized Views |
<name>_MV |
User Defined Types
Should be limited and used only where necessary. |
table_of_timestamps |
Only in one package |
table_of_number |
|
table_of_varchar |
|