This example maps out a one-to-many relationship between user items and address items. It demonstrates the use of the component-item-type attribute, which allows one repository item to contain other repository items. Each user item can contain many address items, such as home address, shipping address, business address.

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE gsa-template
PUBLIC "-//Art Technology Group, Inc.//DTD Dynamo Security//EN"
"http://www.atg.com/dtds/gsa/gsa_1.0.dtd">
<gsa-template>
  <header>
    <name>Repository Mapping Example Version F</name>
    <author>Ben Erwin</author>
    <description>
This template maps out a one-to-many relationship
between user items and address items. It
demonstrates the use of the component-item-type
attribute (which allows one repository item
to contain other repository items.) Each user
item will contain many address items (home address,
business address, etc.)
    </description>
  </header>
  <item-descriptor name="address">
    <table name="addr_tbl" type="primary" id-column-name="addr_id">
        <property name="user" column-name="user_id" item-type="user"/>
        <property name="street" data-type="string"/>
        <property name="city" data-type="string"/>
    </table>
  </item-descriptor>
  <item-descriptor name="user" default="true">
    <table name="usr_tbl" type="primary" id-column-name="id">
        <property name="id" data-type="string"/>
        <property name="name" column-name="nam_col" data-type="string"/>
        <property name="age" column-name="age_col" data-type="string"/>
    </table>
    <table name="addr_tbl" type="multi" id-column-name="user_id">
        <property name="addresses" column-name="addr_id" data-type="set"
                  component-item-type="address"/>
    </table>
  </item-descriptor>
</gsa-template>
SQL Statements
CREATE TABLE usr_tbl (
  id VARCHAR(32) not null,
  nam_col VARCHAR(32) null,
  age_col VARCHAR(32) null,
  primary key(id)
);

CREATE TABLE addr_tbl (
  addr_id VARCHAR(32) not null,
  user_id VARCHAR(32) null references usr_tbl(id),
  street VARCHAR(32) null,
  city VARCHAR(32) null,
  primary key(addr_id)
);

Copyright © 1997, 2013 Oracle and/or its affiliates. All rights reserved. Legal Notices