DEV Community

Peter + AI
Peter + AI

Posted on

Understanding Related Entities in Uniface 10.4 πŸš€

This blog post was created with the help of AI assistance. πŸ€–

When working with Uniface 10.4, one important concept is how related entities are structured inside components. If you are new to this, don’t worry β€” I will explain it step by step using simple examples.

What are Related Entities? 🀝

Two entities are considered related when they are connected in the application model. In Uniface, you need to nest these related entities correctly so that Uniface can automatically handle referential integrity. This means that Uniface will keep primary keys and foreign keys in sync without you having to write extra code.

Outer and Inner Entities πŸ“‚

  • Outer entity: An entity directly under the component (no parent entity).
  • Inner entity: An entity nested inside another entity.

Think of it like folders on your computer: the outer entity is the main folder, and the inner entities are subfolders inside it.

Down Entity and Up Entity ⬇️⬆️

The multiplicity of the relationship (one-to-many or many-to-one) defines whether an entity is a down entity or an up entity.

  • Down entity: An inner entity that represents the "many" side of the relationship. For example, a Department can have many Employees. The Employee entity is a down entity.
  • Up entity: An inner entity that represents the "one" side of the relationship. For example, an Employee belongs to many Projects through an Employment entity. The Project is considered an up entity in this structure.

Example πŸ“

Let’s use a simple case:

Department
└── Employee (down entity)

In this structure, if you load a Department, you will also get all its Employees by default. You can create, update, and delete both Departments and Employees without writing extra code.

Employee
└── Employment
└── Project (up entity)

Here, if you load an Employee, you can also see which Projects they belong to through the Employment entity. You can add or delete Employees and their Employment records, but you cannot delete Projects directly, because the Project entity is on the "up" side.

Why Nests Matter 🧩

If you nest related entities incorrectly, you have to write extra ProcScript code to:

  • Retrieve related data from the database
  • Pass foreign keys manually
  • Enforce referential integrity

By structuring entities correctly, Uniface does this for you automatically β€” less code, fewer bugs! βœ…

Final Thoughts πŸ’‘

Understanding related entities in Uniface 10.4 is key to building reliable applications. By nesting entities properly, you save time and reduce complexity. Always remember: down entities are the many side of a relationship, up entities are the one side.

Keywords: Uniface entities components database

Top comments (0)