Define a Modeled Entity

Modeled entities define the data definitions and default behavior for Uniface components accessing the data.

You must have created a project to contain your application definitions. For more information, see Working with Projects

Tip: If you are defining multiple entities and fields, it is useful to first define modeled properties for Entity Interfaces (if required), Field Interfaces, Field Syntax, and Field Layout properties.

  1. Create one or more modeled entities.
    1. In the Resource Browser, select an entity template, such as Modeled database entity or Modeled non-database entity, depending on the purpose of the entity.
    2. Drag and drop it onto the Project object in the Project Structure.
    3. Rename the new entity in the format EntityName.ModelName.

      If you want the entities to be a part of the same model, ensure that they have the same name Model Name. For more information, see Naming Rules for Uniface Development Objects.

  2. Open the entities for editing. Right-click the entity and choose Open.

    Each entity is opened in its own Entity Editor.

  3. Create the fields for each entity.

    In the Resource Browser, select the template for the type of field you want to create, then drag and drop it in the Structure pane.

  4. Set the properties of the entity and each of its fields in the Properties Inspector.

    For the entity itself, pay particular attention to the Data(base) I/O properties, which determine whether the data is stored in a database, and the restrictions that may apply.

  5. Define the entity's primary key, and optionally candidate and index keys in the Define Keys/Indexes worksheet. For more information, see Define the Keys of a Modeled Entity.
  6. Define any relationships between entities. Relationships must be defined in the Many entity.For more information, see Define Relationships Between Modeled Entities.
  7. Optionally, in the Write Script worksheet, you can add default ProcScript to provide default behavior when storing and retrieving data.

    Code containers are available only for entities and fields. Default ProcScript is provided for some triggers, but you can edit the code in these and any other triggers.

    ProcScript written in the model definition can be overridden by code in the component.

  8. Click Compile to analyze the entity and compile its ProcScript.

    Uniface checks that the entities and relationships are defined correctly and records the information in entity descriptors.

Once the modeled entities are defined, you can construct components that use these definitions to specify their data and default data I/O. For more information, see Construct a Component.