Enumeration¶
Enumeration is a specialized data type consisting of a fixed list of values. Enumeration can be used as a data type for a specific attribute in an entity. Using enumeration instead of another data type, such as Text or Alpha, makes the definition of the allowed content more specific. The frameworks for server, middle tier and clients can make use of this knowledge and make proper validations and selection lists for users to choose from. An enumeration is represented by a database package. A complete different template is used for enumeration than for an entity. No automatic business logic is added to an enumeration.
Enumeration can be layered, meaning that they can be extended.
Modeling¶
Enumerations are easy to model in Developer Studio and there are not many choices to be made when creating an enumeration.
Follow these steps to model an enumeration:
- Create the enumeration model.
- Add the values that should be included in the model.
- If you need different subsets of values, add them in the model.
- If you need to change the behavior of the code generation, add code generation properties.
The code generation properties can be added on the top level and on the value section of the model. - Generate the code.
In most cases you are ready with the enumeration after you have modeled it. In some rare occasion you will add or change the database package.
Code generation¶
After code generation, you will get the following:
Database objects¶
- One database package, used to create enumeration specific business rules.
Files¶
- The plsql file is used for overtaking, overriding methods and creation of own written methods.
Example¶
If you create an enumeration called CarBrand that have the values Audi, BMW, Chevrolet and so on, then this enumeration can be used as data type for an attribute on an entity Car. No other brands than the ones listed in the enumeration can be used on the entity Car.
If you want a smaller list of car brands to be used in certain enumeration instead of the full list, you can add subsets of values. In this example there are GermanCars with values BMW, Audi and Volkswagen; SwedishCars with values SAAB and Volvo; AmericanCars with values Chevrolet and Ford.