Skip to main content

Creating relationships with link fields

In software architecture, defining relationships between data objects is essential for modeling the real world accurately. In the euRent system, for example, a Booking is inherently connected to a Car and a Person (the customer). We establish these relationships in Normalized Systems using a LinkField.

You may have noticed that the Booking Data Element currently lacks any reference to the Car it reserves or the Person who made the reservation. We must introduce these references now.

A LinkField allows one Data Element to reference another. When creating a LinkField, the key parameters you define are:

  • Target Element: Specifies which Data Element is being linked to (e.g., rentWork::Car).
  • Type: Defines the cardinality of the relationship (one-to-many, many-to-many, etc.). In NS, this is represented by a specific code (e.g., Ln02).

Important Relationship Logic:

  • One Booking is made by one Person.
  • One Booking is for one Car.
  • One Car can be referenced by many Bookings.
  • One Person can be referenced by many Bookings.

This results in a Many-to-One relationship from Booking to both Car and Person. The corresponding relationship type code is Ln02.

Add the following two Link Fields to the Booking Data Element:

NameAdd to infoLinkFieldTargetElementType
carrentWork::CarLn02
personrentWork::PersonLn02

To reference the linked element, we can also specify its relationship in the name of the field, such as 'rentedCar' or 'renter'.

Link Fields define the connections between your data entities directly within the model. This model is then processed by the NS Expanders to automatically generate the necessary database schemas and relationship-managing code.

Visualizing the data model

A key advantage of using the Micro Radiant is its ability to visualize complex models, helping analysts and developers understand entity relationships quickly.

  1. Click the diagram icon located on the right side of the editor screen.
  2. At the top of the diagram view, ensure you select the Data Elements option.

The Micro Radiant will now display an Entity Relationship Diagram (ERD) that clearly shows your three core elements (Car, Person, Booking) and the one-to-many relationships that flow from Booking to the other two entities.

datamodeldatamodel