Showing posts with label Auxiliary Table. Show all posts
Showing posts with label Auxiliary Table. Show all posts

Creating your own ATG Repository - Beginners- III

We will be covering the Multi Table, referencing other repositories and One to Many relation in between same repository.

Must read Points:
1. Multi table is used to maintain one to Many relations between Items.
2. Multi table can hold Map, List or Set of items.
3. One item-descriptor can hold N number of Multi tables.

Simple Table below explains concepts of Map, List and Set.


Type\Conditions
Data-type=
multi-column-name=
Set
“set”
Not Required
List
“list”
Seq_number of type “int”(acts as sequence)
Map
“map”
String which acts as key

4. component-item-type if multi valued property needs to be referenced, else component-data-type.
5. id-column-name should be same of primary table.

Step 1: Analyse the Table and data-type.



We will be using "set" to store the Books.

Step 2: Add the Multi column to "author" item.

<item-descriptor name="author" display-name="author" >
   
    <table name="AUTHOR_MASTER" type="primary" id-column-name="author_id">
    ........
    </table>
   
    <table name="AUTHOR_BOOKS" type="multi" id-column-names="author_id">
        <property name="books" column-names="book" display-name="books" data-type="set" component-item-type="book"/>
    </table>
</item-descriptor>

Step 3: Author has primary address, which references to Address Repository.




We will add one more column to primary table of "author" item and reference to Address Repository.

Step 4: Add column to Primary table of "author" item and reference.

<table name="AUTHOR_MASTER" type="primary" id-column-name="author_id">
    ........
    <property name="address" column-names="address" display-name="address" item-type="address" repository="/my/Address"/>
    </table>


repository will hold the referenced repository's Component Path.