All product information in wiki.bizagi.com is only valid for Bizagi BPM Suite 9.1.X.
For newer Bizagi BPM Suite versions (10.X and up) please visit the User Guide.
 

Relationships and Collections

From Business Process Management, BPM and Workflow Automation Wiki | BizAgi BPMS

(Redirected from Relationships)
Jump to: navigation, search

<keywords content="keywords"> relation, relationship, single-single, single_single, multiple-multiple, multiple_multiple, single_multiple, single-multiple, bidirectional, relationships, related attribute, 1-1, 1-n, n-m </keywords>

Contents

Relationships and Collections

1-1 (One-to-One) or Single to Single Relationships

1–1 relationships, are established when there is a single correspondence between the records of two entities. That is, each record from entity A is associated with a single record from entity B and vice versa.

This type of relationship has to be created in Bizagi when the information must be accessed in both directions. That is, when from entity A the information in B is needed and, from entity B information in A is needed.


Example: there are two entities, EMPLOYEE and COMPUTER, in an organization. There is a 1-1 relationship between the two entities, because each employee is associated with just one computer and, therefore, no employee has assigned more than one computer, and no computer has been assigned to more than one employee.



IMPORTANT: You can only define one Single-Single Relationship in a table.


How to Create a Single to Single Relationship

In the Bizagi Diagram Editor, the relationships between entities displayed in the diagram can be created.

1. First, create the entities, for this example Vehicle and Motor.



2. From the Diagram menu select Relationship.



3. The Relationship Wizard window will pop up. Click Next to select the entities and configure the relationship.



4. In the next window select the entities to relate.



5. Then select the Single to single relationship. Click Finish to create it.



When this type of relationship is created, Bizagi will automatically create the attributes (foreign key) that relate the entities to each other (to be able to see it, save the diagram, close and open it again).


How to Edit/Delete a 1-1 Relationship

The only type of relationships that can be edited from the diagram are the 1-N (One-to-Many). To modify Single to Single, first delete the relationship and then create it again.


To delete a 1-1 Relationship follow the next steps:

1. In the Diagram editor, right click on the relationship and select Delete Relationship and Save the diagram.



Note: Bear in mind that relationships can only be removed if they have no dependencies (are not associated with any forms or sub-processes).

1-N (One-to-Many) Relationships

The one-to-many relationship is established when an entry in entity A can have more than one matching entry in entity B, but each entry in entity B has only one matching entry in table A. In Bizagi, this type of relationship can be created in two different forms depending on the used it would have.

Related Attribute

This is the type of relationship usually used with Parameter entities, and often are used in forms with a drop-down list (or combo). It may also be used between Master entities


Example: A Purchase Order would be associated with just one delivery City but one City may be the destination of multiple Purchase Orders.


Difference between 1-1 (Single to Single) Relationships and Related Attributes

When you create a Single-Single Relationship, both of your entities will have each an attribute to reference the other entity.

Let´s remember the computer example of the 1.1 section where there are two entities, EMPLOYEE and COMPUTER, in an organization. There is a 1-1 relationship between the two entities, because each employee is associated with just one computer and, therefore, no employee has assigned more than one computer, and no computer has been assigned to more than one employee.


When creating a Related Attribute, the order does matter in the relationship; mainly because this creates an attribute in one of your entity to reference the other (not both ways). In the computer example now suppose the computer brand is selected from a list of brands. A related attribute is defined to the COMPUTER entity, a computer has no more than one brand but a brand can belong to many computers. You cannot reference to a particular computer from a brand.


How to Create a Related Attribute Relationship

1. Edit the attribute list of the entity which would have the "related attribute" to the other entity.



2. Add a new attribute, write the Display Name, and select for type an Entity and select one of the existent entities. If the entity is not created it can be created by selecting New Entity of the Entity element. Click Next and Finish to close the Attribute list.



Collection

A Collection Relationship can have the following functionalities:

Image:Bulletazul.gif To create tables (grids) on a form that display one to many entities.

Image:Bulletazul.gif To use the Multiple Sub-process shape, creating the relationship between the application entity and the entity for which the multiple sub-process is created.


Example: In a loan process, a Client can have many Loans, but a Loan can belong to only one Client.


How to configure a multiple subprocess

How to Create a Collection Relationship

1. In order to establish the relationship, edit the attribute list of the "one" entity.


Example: In a loan process, a request can have many products, but a product can only belong to one request. The many entity is "ProductsRequest" and the one entity is "Request".



2. Add a new attribute, write the Display Name, and select for type a Collection of the "many" entity, ProductsRequest. If the entity is not created it can be created by selecting New Entity of the Collection element. Click Next and Finish to close the Attribute list.



3. The new relationship will be created and in the "many" entity a new attribute, which corresponds to the "one" foreign key, will be created by Bizagi.



4. Click on the Apply button.

How to Edit/Delete a 1-N Relationship

The only type of relationships that can be edited from the diagram are the 1-N (One-to-Many). To modify Single to Single and Multiple to Multiple, first delete the relationship and then create it again.

1. In the work area of the Diagram window, right click on the "one" entity and select the Edit Attribute List option.



2. Make the necessary modifications in the Attribute list window.



3. Click on Next and then Finish to save changes.

Image:Bulletrojo.gif Alternatively in the Bizagi menu, click the Entities component. Select the "one" entity and select the Attributes elements to display all the attributes. The relationships are displayed in this list of attributes with a different icon. Right click on the relationship to be edited and select the Properties option.




N-N (Many-to-Many) or Multiple to Multiple Relationships

The many-to-many relationship is established when one entry in entity A can have more than one matching entry in entity B, and an entry in entity B can also match more than one entry in entity A.

Many-to-many relationships are necessary in Bizagi in order to display in an entity's form, the related entries of the other entity in a table.


Example: In the Loan Request process, a request has many associated guarantees and many associated products. There is a many to many relationship between guarantees and products. A product can be covered by several guarantees of the request, and a guarantee can cover several products of the request.



Note: When a many-to-many relationship is created, a table is automatically created in the database under the name “Entity1 + _ + Entity2”, with two columns corresponding to the foreign keys of the tables that are being related. Since it is not a Bizagi entity, the table that is created is not displayed in the data diagram.


How to Create a Multiple to Multiple Relationship

The entities to be related must have been created previously. The relationship will be created between "ProductsRequest" and "GuaranteesRequest".

1. In the Diagram Editor select Relationship.



2. In the Relationship Wizard window click Next to select the entities and configure the relationship.



3. In the next window select the entities to relate.



4. Then select the Multiple to multiple relationship. If the N-N relationship is bidirectional, type the names of the relationship from both sides and click Finish to create it.



This type of relationship is drawn in the diagram as follows:



Related Articles: For further information about how to associate values of N to the N entity on the web, please go to Association

How to Edit/Delete a N-N Relationship

The only type of relationships that can be edited from the diagram are the 1-N (One-to-Many). To modify Single to Single, first delete the relationship and then create it again.

In order to Delete N-N Relationships follow the next steps:

1. In the Diagram editor, right click on the relationship and select Delete Relationship and Save the diagram.



Note: Bear in mind that relationships can only be removed if they have no dependencies (are not associated with any forms or sub-processes).


Considerations

Image:Bulletazul.gif If the intermediate table does not have additional attributes, other than the foreign keys of the entities that it is relating: The many-to-many relationship is created in the entity where the table must be displayed, and Bizagi creates the intermediate table automatically in the Database. The table that is created does not correspond to an entity in Bizagi.

Image:Bulletazul.gif If the intermediate table has additional attributes, other than the foreign keys of the entities it is relating, in Bizagi this must be handled in a different form than an N-N relationship. An intermediate entity must be created with the two foreign keys or attributes related to the two entities, and after that, create the required 1-N relationships for the additional attributes.

For the example mentioned here, if the percentage of participation of the guarantee in each product to which it is related is required, the ProductGuarantee master entity will be created with the attributes GuaranteeRequest, ProductRequest and PercentageParticipation and two 1-N relationships, the first from ProductRequest to ProductGuarantee, using the attribute ProductRequest as a key and the second from GuaranteeRequest to ProductGuarantee using the attribute GuaranteeRequest as the key.


<comments />