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.
-
Create one or more modeled entities.
-
In the Resource Browser, select an
entity template, such as
Modeled database entity
orModeled non-database entity
, depending on the purpose of the entity. - Drag and drop it onto the Project object in the Project Structure.
-
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.
-
In the Resource Browser, select an
entity template, such as
-
Open the entities for editing. Right-click
the entity and choose Open.
Each entity is opened in its own Entity Editor.
-
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.
-
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.
- 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.
- Define any relationships between entities. Relationships must be defined in the Many entity.For more information, see Define Relationships Between Modeled Entities.
-
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.
-
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.