creapage.net

HOWTO - Sashipa development

 SchemaColumns.

In the environment part of a Sashipa code, you wish to describe a new SQL column or a new foreign key constraint.

Columns

Here is an example:

  <schemaColumn name='tblXXX_InternalName' type='text'
                   maxCharacters='20' notNull='no'>
    <physicalName>SqlName</physicalName>
    <singularName>Name to display</singularName>
    <shortName>Name to display, short version</shortName>
    <guiConfigSchemaColumn letterCount='20' sort='asc'
                           criteriaCompare='like' criteriaCaseSensitive='no' />
  </schemaColumn>

Remarks:

Now an example of column that belongs to the primary key :

  <schemaColumn name='tblTestAuto_Autoid' type='integer' notNull='yes' pk='yes'>
    <generatedByDbms />
    <physicalName>TestAutoId</physicalName>
  </schemaColumn>

Remark: the attribute pk indicates that the column is a part of the primary key.

The element generatedByDbms is optional. It means that the DBMS will compute itself new values for this column. The element 'generatedByDbms' can be empty as this example. Or it can contains a specific-to-dbms string for evaluate the last inserted value. For example, in case of PostGreSQL databases, the name of the sequence can be specified here (for non-standard sequence names).

If there is no element 'generatedByDbms', the value for the column will be defined by the generated software. If the column is displayed in a field the user will define a value, otherwise the software will compute a new value by a Select query.

Be careful: the using of a column 'generatedByDbms' isn't implemented by Sashipa-Melba for all DBMS ! Now, only softwares that works with PostGreSQL databases can use it.

Foreign keys

At first, an example:

  <schemaFk name='fk_tblPersonne_tblProject' targetSchemaTable='tblProject'
            deleteCascadeByDbms='yes'>
    <singularName>Managed project</singularName>
    <schemaColumnRef schemaColumn='tblPersonne_RefManagedProjectYear' />
    <schemaColumnRef schemaColumn='tblPersonne_RefManagedProjectNumero' />
  </schemaFk>

... then the explication:

The singularName element is optional. When it isn't specified, the singular name of the target table is used.

In this example we have a complex foreign key that references a complex primary key. The keys contain two columns. NB: the schemaColumnRef order in the schemaFk must be the same as the primary key columns order in the referenced table.

The optional attribute deleteCascadeByDbms means that the constraint "DELETE CASCADE" is managed by the DBMS. This attribute remove from the software the integrity checking when deleting, and clean the buffer. But the software do not make the delete in the dependent table. Be careful: the constraint "delete cascade" is not detected by Database2Sashipa, so the attribute has to be added manually.

User key

A user key is the set of columns used by the end-user to identify each row. Technically, it can be implemented by a UNIQUE constraint in the database. An example :

  <userKey unique='yes'>
    <userKeyColumn schemaColumn='tblContactaddress_Contactaddresslabel' />
    <userKeyFk schemaFk='tblContactaddress_fkTblContact' />
  </userKey>

Here there is a user key that contains one column and one foreign key. From the end-user point of view, the key contains the label column and the userKey of the table Contact, that is referenced by the foreign key.

The unique attribute means that the software will check the unique constraint manually, before inserting or updating, by a Select query. A pretty nice error message will be generated.

The visible attribute means that data contains in this column not has to be displayed.

© Copyright 2003 Sashipa-Melba Team. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License as much as this note clearly appears.