Domains to a PDM

Previous  Index  Next  How To Use

If the type of DBMS associated with your PDM supports "domains", the conversion of a logical Domain will be direct. That is, for each logical domain, a physical domain object will be created and re-used in one or more Tables.

 

If Domains are not supported by the DBMS, a table column will use the "raw datatype", optional "check constraint" and optional "not null" constraint will be used.

 

Below is an example of objects created.

 

CREATE DOMAIN SEX_TYPE AS CHAR(1) NOT NULL CHECK VALUE IN ('M', 'F');

 

CREATE DOMAIN SALARYCHANGEPERCENTAGE AS SMALLINT NOT NULL CHECK (value between 1 and 5);

 

CREATE TABLE PERSON

(

PERSONID INTEGER NOT NULL PRIMARY KEY,

FIRST_NAME VARCHAR(50) NOT NULL,

LAST_NAME VARCHAR(50) NOT NULL,

SEX SEX_TYPE,

LAST_SALARY_CHANGE SALARYCHANGEPERCENTAGE

);

Table SQL statement for the InterBase DBMS, which supports Domains

 

In the above example, the domain "SEX_TYPE" can be re-used by multiple table columns without having to repeat it's definition.

 

CREATE TABLE PERSON 

(

PersonID  Integer NOT NULL PRIMARY KEY,

First_Name VarChar(50) NOT NULL,

Last_Name  VarChar(50) NOT NULL,

Sex       Enum('F', 'M') NOT NULL,

Last_Salary_Change SmallInt NOT NULL

) TYPE=MyISAM;

Table SQL statement for the MySQL DBMS, which does not support Domains or Check Constraints (but uses a special ENUM datatype)

 

In the above example, the SEX_TYPE domain definition is copied into each table column that uses this domain.

 

Next: Entities to a PDM