A relation is the logical connection of the data of two entities or one and the same entity (the latter one for instance when modeling parts lists or usage documents). Each relation can be characterized by a set of relation attributes and is mapped in an own relation table. A relation is always directed from an entity 1 to an entity 2. If you create several relations from or to an entity, the relations must be differentiated between with the help of the view. Thus the view is the name of the model object relation.
In the database any relation is mapped as relation table in the DataView format. It contains the relation attribute fields and the DataView internal system fields. Each relation record entered is unambiguously identified by the C_ID automatically assigned by DataView. The additional internal Ident numbers C_ID_1 and C_ID_2 create the connection between the relation record and the corresponding master records in the entities 1 and 2. This means that relations can only be created between entities that are mapped in DataView tables/views. Entities for which foreign format tables/views have been created cannot be put into a relation but only be connected using the model object -> Link.
From the point of view of the data model each relation in DataView is an n:m relation. The reduction to 1:n or n:1 relations is only done by the selection of the lists which you will later offer to the user for editing the relation on the desktop. Basically, you can create two default lists for each logically defined relation: the refine- and the aggregate list.
In both lists the user can create a relation by selecting a child element in the modal window at the master attribute field and then assigning the relation attributes. Additionally, in the default relation lists all standard functionality is available which is required for relation records to be searched, modified, to display dependent elements etc.
Example: In the meditronic application the n:m relation Item-Supplier has been created. It models the case that an item is bought from several suppliers, but one supplier can also provide several items. The relation was directed from the item entity (entity 1) to the supplier entity (entity 2) (created in Refine Relation sub-list). The relation table created contains the relation attribute price and date. if the user creates a relation between an item and a supplier, DataView will automatically enter the internal C_IDs of the participating master records into the internal C_ID fields of the relation table (C_ID_1, C_ID_2). The created default refine list shows all suppliers of a selected item (1:n part of the n:m relation, selected item is parent element). It can be used to assign new suppliers for the selected item (selection from suppliers list via modal window at the supply number field). The default aggregate list created displays all items a selected supplier can provide (n:1-part of the n:m relation, selected supplier is parent element). It can be used to assign new items to the selected supplier (selection from item list via modal window at item number field).
Make sure the entity is not mapped as a foreign format table/view.
After saving the data of the relation object are stored in the repository, but still without the corresponding table fields.
Please observe the following comments when entering database-relevant field attributes:
The following field attributes are optional. They are important if the field is used in masks. They are evaluated when the default Refine/Aggregate masks are created. When masks are designed later, these attributes can be mask-specifically overwritten:
After saving the data for the relation object are completely stored in the repository. All relation table fields created can be viewed in the Field Data form.
After that the data of the default relation lists are stored in the repository and copied into main memory. The default lists and their corresponding mask-field relations can be viewed in the Mask Data form.
Note! You can immediately open the default lists created at the selected master record in the master lists of entity 1 or 2 via -> Refine Relation or -> Aggregate Relation in the Select menu (in case of several relations from and to the entity a selection menu will automatically appear). By entering test data you check the correct creation of the relation object and the relation attribute fields. A relation between a selected master record (parent) and children is created by entering a new relation record, selecting the child record in the modal window and assigning the relation attributes.