Relations

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).

How to Create a Relation:

  1. Open the Entity Data form and get the entity 1 into the header form from which the relation is to originate.

    Make sure the entity is not mapped as a foreign format table/view.

  2. Change into the Refine Relation sub-list (for n:m- or 1:n-relation) or into the Aggregate Relation sub-list (for n:m- or n:1-relation) and enter a new relation record.

    Field Comment Confer
    Entity Here you enter the name of entity 2 or select it in the modal window from the entity master. Entity 2 is the entity the relation is directed to. Make sure the entity is not mapped in a foreign format table or view. -
    View Here you enter the actual name of the relation. -
    Table Here you enter the name of the relation table to be created. -
    Refine List
    Aggregate List
    Here you enter the names of the default lists to be created (optional). For an n:m relation you should enter both lists, for 1:n the refine- and for n:1 the aggregate list. -
    > Ch (check value)
    < Ch (check value)
    Here you set the number of dependent child records at which parent records can still be deleted. If possible, use the default setting offered. -> Check for dependent elements
    > (Delete Flag)
    < (Delete Flag)
    Here you specify whether child records are also to be deleted when relation records are deleted. If possible, use the default setting offered. -> Automatically deleting dependent elements
    Title The object title is used in error messages and is required for selecting the main entity in the dynamic query mask.

    After saving the data of the relation object are stored in the repository, but still without the corresponding table fields.

  3. Change into the relation form via the hyperlink in the column Table. The relation record is displayed in the header form.

  4. Change into the Table Fields sub-list and enter a new field record for each desired relation attribute field.

    Please observe the following comments when entering database-relevant field attributes:

    Field Comment Confer
    Field Name Here you enter the field name using the syntax TABLENAME.COLUMNNAME. The entry is supported by automatically prompting TABLENAME. For COLUMNNAME C_NAME is recommended. -> Table Fields
    Sequence Here you specify the position number of the field. It determines the field sequence in the relation table and in the default masks. -> Sequence of Fields in Tables
    Type Here you select the field data type. When the field is left the default length is automatically added. It can be changed. -> Field Types
    Index 1-3
    Uniqueness 1-3
    Non-Zero Flag
    As a rule you will not index fields in relation tables, set no uniqueness flag and no non-zero flag unless you want to create links from and to the relation tables and need key fields to do so. -> Indexed Fields
    -> Unique Fields
    -> Non-Zero Fileds
    Multilinguality Here you select the languages for which the field in the table is to be created as multi-lingual. -> Multilingual Table Fields
    Mode Here you select the field-specific case-sensitivity for queries. -> Field-Specific Query Mode

    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:

    Field Comment Confer
    Field Title Here you can enter a field title. It appears as column title in lists and as field title in forms. -> Field Title
    Description Here you can enter a help text for the field. When the field is edited at will appear in the mask footer line. -> Description for Fields
    Check String Here you can specify a check string to be used for syntax checks of field contents. -> Check Strings for Field Entries
    Default Value Here you can assign a default value for the field. -> Assigning Default Values to Fields

    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.

  5. Change into the Relation Data header form and create the relation table via Create Table.

    From then on the relation table will exist in the database.

  6. Use Create Ref-List to create the default refine list and Create Agg-List to create the default aggregate list for an n:m relation. For a 1:n relation you only need to create the refine list, for a n:1 relation only the aggregate list.

    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.