Adding foreign key elements to a default table

A foreign key relationship is a relationship between an extended column in any application database table and the YFS_PERSON_INFO table. You can create foreign key elements to establish relationship between an extended column and the YFS_PERSON_INFO table.

About this task

Note: Currently, the YFS_PERSON_INFO is the only table that supports a relationship with foreign key extensions within the application database.

Procedure

  1. Copy the <runtime_sandbox>/repository/entity/extensions/Extensions.xml.sample file as <install_dirruntime_sandbox>/extensions/global/entities/your_custom_filename.xml file OR modify your existing extension XML file.
  2. Edit the your_custom_filename.xml file to add foreign key elements as shown in the following example for each table you want to extend. For a description of the XML attributes, see the table that follows the example.
    <!-- element exposed to create foreign key relationship --> 
    <DBSchema>
     <Entities>
        <Entity TableName="REQUIRED">
         .
         .
          <!-- element exposed to create relationship with PERSON_INFO table -->
             <ForeignKeys>
               <ForeignKey ParentTableName="YFS_PERSON_INFO" 
                 XMLName="YFSName1" >
                   <Attribute ColumnName="REQUIRED" 
                    ParentColumnName="PERSON_INFO_KEY" />
                 </ForeignKey>
               <ForeignKey ParentTableName="YFS_PERSON_INFO" 
                 XMLName="YFSName2" >
                   <Attribute ColumnName="REQUIRED" 
                    ParentColumnName="PERSON_INFO_KEY" />
               </ForeignKey>
               .
               .
             </ForeignKeys>
           .
           .
        </Entity>
       </Entities>
    </DBSchema>

    Attribute

    Description

    Entity

    TableName

    Name of the table for which the foreign key elements are added. For example, YFS_ITEM.

    Entity/ForeignKeys/ForeignKey

    ParentTableName

    The name of the parent table for this foreign key element.

    Note: This value must be YFS_PERSON_INFO, which is the only table that currently supports foreign key relationships.

    XMLName

    You can specify the XML representation of the element name. It must start with the prefix of the parent entity. For example, if ParentTableName is prefixed with YFS then the XMlName must start with YFS.

    By default the parent table name is assumed.

    Entity/ForeignKeys/ForeignKey/Attribute

    ColumnName

    Specifies the extended column name of the Entity.

    ParentColumnName

    The column name of the YFS_PERSON_INFO that has a foreign key element relationship.

  3. Create a ForeignKey tag for each foreign key relationship that you want to add.
  4. Multiple foreign key elements can be related to the same parent table.
  5. Extend the corresponding API templates to include the foreign key elements by following the instructions in Extending API Templates.
  6. Build and deploy your extensions.