Skip to main content

Data schema descriptor

Schema description

The schema must be expressed as an XML file. This file should be located at a core addon module and be named plugin-ddl.xml.

This DDL file can contain descriptions for tables, indexes and foreign keys.

Tables

A table is composed of a <table> entity containing one or more <column> entities:

Attributes for <table> entity

name

Table name

Attributes for <column> entity

name

Column name

type

It can have one of the following values, as stated at java.sql.Types class:

INTEGER

LONG

BOOLEAN / BIT

FLOAT

DOUBLE

VARCHAR

CHAR

DATE

CLOB

BLOB

length

Optional column size.

notNull

true if it cannot contain null values

primaryKey

true if it's part of the primary key.

The primary key will be composed of all attributes marked as primary key. The order of them will be the same as their appear order at XML fi

Foreign keys

A foreign key is declared using the <foreignKey> entity. It will contain one or more <column> entities. Each columns identifies a member of the foreign key. It will also contain one or more <foreignColumn> entities. Each foreignColumn entity specifies the name of the corresponding column at the foreign table.

Attributes for entity <foreignKey>

name

Foreign key name

tableName

Table name

foreignTableName

Name of master table

Attributes for <column> entity

name

Column containing the foreign key

Attributes for <foreignColumn> entity

name

Column containing the foreign key

Indexes

An index is declared using the <index> entity. It will contain one or more <column> entities. Each column identifies a member of the index.

Attributes for <index> entity

name

Index name

tableName

Table name

unique true if no duplicated keys will be allowed

Attributes for entity <column>

name

Column to be indexed


Sample plugin-ddl.xml

<?xml version="1.0" encoding="UTF-8"?>
<database>
    <table name="t1">
        <column name="id" type="LONG" notNull="true"
            autoIncrement="true" primaryKey="true"/>
        <column name="vc" type="VARCHAR" length="55"/>
        <column name="t1date" type="DATETIME" notNull="true"/>
        <column name="userid" type="LONG" />
    </table>
    <index name="i1" table="t1">
        <column name="vc"/>
    </index>
     
    <table name="t2">
        <column name="id" type="LONG" primaryKey="true"/>
    </table>
    <foreignKey name="t1_fk" table="t1" foreignTable="t2">
        <column name="userid"/>
        <foreignColumn name="id"/>
    </foreignKey>
</database>