Declarative Objectivity (DO) Language : Schema Clauses : CREATE CLASS Clause
CREATE CLASS Clause
A CREATE CLASS clause describes a new class to be added to the schema of a federated database.
   
Syntax 
createClassClause : CREATE CLASS className (SUPERCLASS className)? (EMBEDDABLE)? '{' attributeStructure (',' attributeStructure)* '}';
Used In 
UPDATE SCHEMA Statement  
Quick Look 
Create a new referenceable schema class with an attribute that references an existing schema class called FleetData.Vehicle:
UPDATE SCHEMA 
{
   CREATE CLASS FleetData.EfficiencyReport 
   {
     reportNumber : Integer {Encoding: signed, Storage: B8},
     vehiclesAvailable : Set {Element: Reference {Referenced: FleetData.Vehicle}, CollectionTypeName : TreeSetOfReferences},
     status : Integer {Encoding: signed, Storage: B8},
     lastUpdate : Date,
     topRating : Reference {Referenced: FleetData.Vehicle}
   }
};
Create two new referenceable schema classes that are subclasses of an existing schema class called FleetData.Vehicle:
UPDATE SCHEMA 
{
   CREATE CLASS FleetData.HybridVehicle SUPERCLASS FleetData.Vehicle
   {
     mpg : Integer {Encoding: Unsigned, Storage: B8},
     emissions : Real {Storage: B32},
     maxTripMiles : Integer {Encoding: Unsigned, Storage: B32},
     directCharge : Boolean
   }
 
   CREATE CLASS FleetData.GasVehicle SUPERCLASS FleetData.Vehicle
   {
     mpg : Integer {Encoding: Unsigned, Storage: B8},
     emissions : Real {Storage: B32},
     tankSize : Integer {Encoding: Unsigned, Storage: B8}
   }
};
 
Create a new embeddable schema class:
UPDATE SCHEMA 
{
   CREATE CLASS FleetData.Brand EMBEDDABLE 
   {
     name : String {Encoding : Byte, Storage: Optimized, FixedLength : 6},
     workMarkFileName : String {Encoding : Utf16},
     logoFileName : String {Encoding : Utf16},
     copyrightDate : Date
   }
};
 
Discussion 
A CREATE CLASS clause is an action clause of a UPDATE SCHEMA Statement. The clause:
Instructs UPDATE SCHEMA to create a new schema class.
Provides a description of the schema class to be created.
If the new class is to belong to a schema namespace, the class description must specify a class name that includes namespace qualification. An error is returned if you specify a class name that already exists in the schema namespace. New schema namespaces are created automatically if the specified class name includes namespace qualifiers that refer to nonexistent schema namespaces.
The class description may include any number of comma-separated attribute structures to describe the attributes of the new class.
Multiple CREATE CLASS clauses can be included in a single UPDATE SCHEMA statement. In fact, sometimes you must include multiple CREATE CLASS clauses; see Creating a New Class With Dependencies.
If a valid class with the specified description can be created in the federated database’s schema, it becomes available to other database operations when the enclosing UPDATE SCHEMA statement returns. No class is created if the enclosing statement returns an error.
Describing a New Referenceable Class
You describe a new referenceable schema class by including:
A class name (with namespace qualification, as appropriate).
(Optional) The SUPERCLASS keyword and a namespace qualified class name, if the new class is to inherit from another referenceable schema class.
Comma-separated attribute structures describing the new class’s attributes, enclosed in curly braces.
Describing a New Embeddable Class
You describe a new embeddable schema class by including:
A class name (with namespace qualification, as appropriate).
(Optional) The SUPERCLASS keyword and a namespace qualified class name, if the new class is to inherit from another embeddable schema class.
The EMBEDDABLE keyword.
Comma-separated attribute structures describing the new class’s attributes, enclosed in curly braces.
Creating a New Class With Dependencies
You can use a CREATE CLASS clause to create a new class that depends upon another class. For example, the new class may inherit from the other class, or define an attribute for referencing or embedding instances of the other class. If the other class does not already exist in the schema, you must create it, along with the dependent class, in the same UPDATE SCHEMA statement. The enclosing statement must therefore include a CREATE CLASS clause for each class to be created.