Home   :   Matrix Language   :   Pattern Statements   :   Traverse Unique Statement

Traverse Unique Statement

 

Statement

 

TraverseUnique

 

 

General

 

Duplicate object references can occur when traversing two or more many relationships consecutively. Often duplicates are desirable but sometimes they are not. The TraverseUnique statement automatically removes duplicate objects.

 

 

TraverseUnique Statement

 

TraverseUnique

Navigation

Hotel : Accommodates : Guest

Guest : Likes        : Food

TraverseSelection

Template

<<:>>    <<#Food.Name>>

 

The TraverseUnique statement is used in place of the Traverse statement where duplicate objects are not required.

 

 

TraverseUnique Example

 

This example shows how to list the Foods liked by Guests at a Hotel without duplication.

 

Declare Hotel entity:

 

Entity:Hotel

Attribute

Text : Name

Relationship

Accommodates -|> Guest

 

Declare Guest entity:

 

Entity:Guest

Attribute

Text : Name

Relationship

Likes -|> Food

 

Declare Food entity:

 

Entity:Food

Attribute

Text : Name

 

Using the Traverse statement:

 

Traverse

Navigation

Hotel : Accommodates : Guest

Guest : Likes        : Food

TraverseSelection

Template

<<:>>    <<#Food.Name>>

 

The Hotel has two Guests, Jack & Jill. If Jack likes Fish & Beef and Jill likes Pies & Beef then the following is displayed:

 

Fish

Beef

Pies

Beef

 

Beef is displayed twice which is not the desired result. However, if the TraverseUnique statement is used:

 

TraverseUnique

Navigation

Hotel : Accommodates : Guest

Guest : Likes        : Food

TraverseSelection

Template

<<:>>    <<#Food.Name>>

 

The following is displayed:

 

Fish

Beef

Pies

 

Beef is displayed once. The use of TraverseUnique eliminates the duplicates from the result.

Copyright © 2017 Dark Matter Systems Ltd. All Rights Reserved.