This example maps a repository item to a primary table and a multi-value table with a map property.
<?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 Example Version E</name> <author>Pat Durante</author> <description> This template maps a repository item to a primary table and a multi-value table using a map property. A one-to-many relationship. When using a "map" property, the "multi" table requires a "multi-column-name" (e.g., card_key). This column will contain keys that uniquely identify each of the multi-values (For example, each user has many credit cards...the keys are strings that identify each of the user's cards (like business card, frequent flyer card, personal card.) </description> </header> <item-descriptor name="user" default="true"> <table name="usr_tbl" type="primary" id-column-names="id"> <property name="id" data-type="string"/> <property name="name" column-names="nam_col" data-type="string"/> <property name="age" column-names="age_col" data-type="int"/> </table> <table name="credit_card_tbl" type="multi" id-column-names="id" multi-column-name="card_key"> <property name="card_num" column-names="card_num" data-type="map" component-data-type="string"/> </table> </item-descriptor> </gsa-template>
SQL Statements
drop table credit_card_tbl; drop table usr_tbl; CREATE TABLE usr_tbl ( id VARCHAR(32) not null, nam_col VARCHAR(32) null, age_col INTEGER null, primary key(id) ); CREATE TABLE credit_card_tbl ( id VARCHAR(32) not null references usr_tbl(id), card_key VARCHAR(32) not null, card_num VARCHAR(32) null, primary key(id, card_key) ); CREATE INDEX credit_card_tbl_idx ON credit_card_tbl(id);