This example maps a repository item to a primary table and a multi-value table with a set type 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 D</name> <author>Pat Durante</author> <description> This template maps a repository item to a primary table and a multi-value table using a set property. A one-to-many relationship. Since we are using a "set", we are not required to use a "multi-column-name" attribute. Demonstrates that D5 repositories (unlike D4.5) do not require a "seq_num" column. </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="subjects_tbl" type="multi" id-column-names="id"> <property name="favoriteSubjects" column-names="subject" data-type="set" component-data-type="string"/> </table> </item-descriptor> </gsa-template>
SQL Statements
drop table subjects_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 subjects_tbl ( id VARCHAR(32) not null references usr_tbl(id), subject VARCHAR(32) not null, primary key(id, subject) );