Language and development rules: Difference between revisions

m
Line 151: Line 151:


== DDL file format ==
== DDL file format ==
Files that contain definition of the database structure (DDL files) must be 2 per tables:
Files containing definition of the database object/structure (DDL files) must be 2 per tables:
* Each table is defined by its own file whose name is <tt>llx_''mytable''.sql</tt>
* Each table is defined by its own file whose name is <tt>llx_''mytable''.sql</tt>
A comment will be added on each field to explain its usage.
A comment will be added for each field to explain its usage.
* All foreign keys, performance indexes or other constraints will be defined into another file called <tt>llx_''mytable''.key.sql</tt>
* All foreign keys, performance indexes or other constraints will be defined in another file called <tt>llx_''mytable''.key.sql</tt>


Those files must be stored into directory '''install/mysql/tables''' for all standard files or '''mymodule/tables''' for tables provided by an external module.
These files must be stored in the directory '''install/mysql/tables''' for all standard files or '''mymodule/tables''' for tables provided by an external module.


Example '''file of table llx_mytable.sql''':
Example '''file for table llx_mytable.sql''':


<source lang="sql">
<source lang="sql">
Line 196: Line 196:
</source>
</source>


Example '''file for keys/indexs on llx_mytable.key.sql''':
Example '''file for keys/indexes will be llx_mytable.key.sql''':


<source lang="sql">
<source lang="sql">
Line 216: Line 216:
-- ===========================================================================
-- ===========================================================================


ALTER TABLE llx_matable ADD UNIQUE uk_matable_field(field_one, field_two);
ALTER TABLE llx_mytable ADD UNIQUE uk_mytable_field (field_one, field_two);


ALTER TABLE llx_matable ADD CONSTRAINT fk_matable_fk_field FOREIGN KEY (fk_field) REFERENCES llx_matablepere (rowid);
ALTER TABLE llx_mytable ADD CONSTRAINT fk_mytable_fk_field FOREIGN KEY (fk_field) REFERENCES llx_matablepere (rowid);
</source>
</source>


304

edits