CIMTool can generate a database schema based on a CIM profile. Potential uses of this feature might include:

Caveat Emptor

You could use a generated schema in a production application or product. However, there is a catch: a new CIM version is released each year.

The use of a profile provides some protection against CIM changes. In some cases the profile can remain the same even though the underlying CIM changes.

Even so, it may be difficult to prevent the churn in CIM versions from impacting the schema and the impact of that on the application as a whole may be unsustainable.

Getting Started

To generate SQL statements for a profile, select the "SQL" checkbox on the summary page in the profile editor. When the profile is saved, a file with the same name as the profile and extension ".sql" will be generated in the Profile folder of the project.

What is in the Schema

The generated schema closely follows the structure of the profile as seen the Outline view.

Guidelines for Profiles

There are a few guidelines that should be observed when constructing profiles for database schemas. They concern:

Choice of Identifiers

Database systems generally place a length limit on table and column names and these names are normally case-insensitive.
CIM class, attribute and association role names are sometimes longer than the limit and are case sensitive.

The identifiers in the profile are by default copied from the CIM, but can be changed on the detail page of the profile editor. In most cases only one or two names need to be changed in the profile to comply with the database restrictions.

Profile Structure

It is possible to create a profile with a property referencing a class outside the profile. A profile may also contain local (or nested) class definitions. In either case, the generated schema will contain an invalid foreign key constraint because the referenced table will not exist in the schema.

The rule is that the type of each object property and each enumeration property must be a global class. Global classes are the named classes and appear at the first level of the profile outline display.

The Reorganize and Repair tool can be used to enforce this rule. This tool is activated from the summary page of the profile editor. The "Reorganize profile per RDFS rules" option will introduce any global classes needed.

(Note that this option makes other changes as well. It merges classes based on the same schema class into a single profile class. It also merges all restrictions of the same schema property into a single restriction. The merged restriction is moved to the common base class of the individual restrictions. If necessary that class is added to the profile.)