USMeta.Relationships

Previous Next

At runtime, gets metadata information about relationships from the model developed in USoft Definer. This information includes (a) attribute settings of the relationship itself, and (b) a list of parent table column - child table column pairs that identifies how records in the child table refer to the corresponding parent record.

Returns an XML document of the form demonstrated in Example 1 below.

Syntax

SELECT USMeta.Relationships(

       parent-table-name-pattern

,      child-table-name-pattern

,      role-name-pattern

)

 

All parameters are optional. Parameter values passed (if any) are mapped to parameters by position from left to right.

Parent-table-name-pattern is a regular expression that matches zero, one or more parent tables in the model. The information retrieved is restricted to relationships that have a parent table matching the pattern.

If parent-table-name-pattern is omitted, that is, if no parameters are passed at all, then information on ALL relationships is retrieved.

You can pass the empty string as the value of parent-table-name-pattern if you only want to specify a child-table-name-pattern, as demonstrated in Example 1.

Child-table-name-pattern is a regular expression that matches zero, one or more child tables in the model. The information retrieved is restricted to relationships that have a child table matching the pattern.

If child-table-name-pattern is omitted, then the information retrieved is not restricted by child table names (but it may still be restricted by parent table names if the value of parent-table-name-pattern is a non-empty string).

You can pass the empty string as the value of child-table-name-pattern if you want to restrict the retrieved information by role-name-pattern but not by child-table-name-pattern.

Role-name-pattern is a regular expression that matches zero, one or more role names in the model. The information retrieved is restricted to relationships that have a role name (the value of the ROLE relationship attribute) matching the pattern.

If role-name-pattern is omitted, then the information retrieved is not restricted by role name (but it may still be restricted by parent table name or child table name or both.

Example 1

This example returns relationship information on all relationships in the model that have the SCHEDTOUR table als their child table:

SELECT USMeta.Relationships( '', 'SCHEDTOUR' )

 

The return value of this statement could be:

<?xml version="1.0" encoding="UTF-16"?>

<Meta>

  <Relationships>

    <Relationship PARENT_TABLE="GUIDE" CHILD_TABLE="SCHEDTOUR" ROLE="GUIDES" CO_ROLE="are guided by" 

        ALIAS_PARENT="" MENU_LINE="Scheduled Tours guided by this Guide" REV_MENU_LINE="Guides guiding Scheduled Tours" 

        LOOKUP_METHOD="WINDOW_PAGE" DELETE_RULE="RESTRICTED" UPDATE_RULE="RESTRICTED" CHILD_MANDATORY="N" 

        MIN_NO_OF_CHILDREN="0" MAX_NO_OF_CHILDREN="0" FK_MANDATORY="N" LOCK_ON_FK_CHECK="Y" FK_CHECK_PARTIAL="Y" FK_UPDATABLE="Y">

      <Relationship_Columns>

        <Column PARENT="PERSON_ID" CHILD="GUIDE"/>

      </Relationship_Columns>

    </Relationship>

    <Relationship PARENT_TABLE="TOUR" CHILD_TABLE="SCHEDTOUR" ROLE="IS SCHEDULED AS" CO_ROLE="are described by this" 

      ALIAS_PARENT="" MENU_LINE="Scheduled Tours described by this Tour" REV_MENU_LINE="Tours scheduled as Scheduled Tours" 

      LOOKUP_METHOD="WINDOW_PAGE" DELETE_RULE="RESTRICTED" UPDATE_RULE="CASCADING" CHILD_MANDATORY="N"

      MIN_NO_OF_CHILDREN="0" MAX_NO_OF_CHILDREN="0" FK_MANDATORY="Y" LOCK_ON_FK_CHECK="Y" FK_CHECK_PARTIAL="Y" FK_UPDATABLE="Y">

        <Relationship_Columns>

          <Column PARENT="DESTINATION" CHILD="DESTINATION"/>

          <Column PARENT="TOUR_TYPE" CHILD="TOUR_TYPE"/>

        </Relationship_Columns>

    </Relationship>

  </Relationships>

</Meta>

 

Example 2

This example returns relationship information about all relationships in the model that have as their child table name an alphanumeric uppercase string that contains 'SCHEDTOUR':

SELECT USMeta.Relationships( '', '^[A-Z]*SCHEDTOUR[A-Z]*$', '' )

 

 

See Also

USMeta.Tables

USMeta.Columns