AnsweredAssumed Answered

Clarification of Associations, some questions about modeling

Question asked by alexeyg on Dec 28, 2006
Hello,

I am having problems coming up with the best content model, probably due to some confusion about the concept of associations.  Any help is greatly appreciated.

Description of application

Our application does searches.  Users submit one or more search parameters (key/value pairs) and get search results.  Depending on their search parameters they also get an appropriate paragraph of text called Search Description.  These Search Descriptions are to be stored in Alfresco along with search parameters they apply to.  A unique conbination of search parameters is called a Search Map.  A Search Description may be applicable to one or more Search Maps.  A Search Map may only have one associated Search Description.

Proposed Data Types:

search_description - derived from cm:content to store description text
search_map - represents a collection of search_parameter
search_parameter - a key/value pair of strings

Summary of requirements
Search Description may have zero or more associated Search Maps
Each Search Map may or may not have one associated Search Description
Search Map must have one or more Search Parameters (a unique combination)
Each Search Parameter may belong to zero or more Search Maps.

Questions:

1) Is following the proper way to code quoted requirements?  I am especially concerned about my understanding of usage of <source> and <target> elements… please point out any statements that reflect incorrect understanding of them.


    <type name="my:search_description"> 
       <title>Search Description</title>
       <parent>cm:content</parent>
       <associations>
            <association name="my:search_maps">
               <source>
                  <mandatory>false</mandatory>
                  <many>false</many>
               </source>
               <target>
                  <class>my:search_map</class>
                  <mandatory>false</mandatory>
                  <many>true</many>
               </target>
            </association>
       </associations>
    </type>

    <type name="my:search_map"> 
        <title>Search Map</title>
        <parent>sys:base</parent>
        <associations>
            <association name="my:search_parameters">
               <source>
                  <mandatory>false</mandatory>
                  <many>true</many>
               </source>
               <target>
                  <class>my:search_parameter</class>
                  <mandatory>true</mandatory>
                  <many>true</many>
               </target>
            </association>
       </associations>
    </type>

    <type name="my:search_parameter"> 
        <title>Search Map</title>
        <parent>sys:base</parent>
        <properties>
                <property name="my:search_parameter_name">
                        <type>d:text</type>
                </property>
                <property name="my:search_parameter_value">
                        <type>d:text</type>
                </property>            
        </properties>
      </type>

In Search Description type…
<mandatory> is false in <source> because a Search Map does not have to have a Search Description.

<many> is false in <source> because a Search Map may not have more than one Search Description.

<mandatory> is false in <target> because a Search Description does not have to have a Search Map.

<many> is true in <target> because a Search Description may have multiple Search Maps.
In Search Map type…
<mandatory> is false in <source> because a Search Parameter does not have to belong to any Search Map.

<many> is true in <source> because a Search Parameter may belong to many Search Maps.

<mandatory> is true in <target> because a Search Map must have one or more Search Parameter.

<many> is true in <target> because a Search Description may have multiple Search Parameters.

In Search Paraqmeter type…
No association needs to be specified because it is already written in Search Map type

Does XML properly reflect what I'm trying to do, and are quoted statements correct? 


2) Does my approach seem best for achieving the goal?  Does my thinking reflect proper understanding of concepts involved?

3) Search Description will derive from cm:content.  What about Search Map and Search Parameter?  One is just a container and the other is a key/value pair of strings.  Do they need to have a sys:base as parent?  Do they make sense as Types or Aspects?

4) Are there any differences between types and aspects when it comes to associations?

5)  It seems having multiple child associations to a type is similar to applying the same aspect multiple times.  By specifying Search Parameters as Types and using regular associations instead of child-associations I give myself the option to re-use same Search Types for different Search Maps.  Do those statements make any sense? 

6) Is there any connection between <parent> element of Type and <child-association> element?  I thought they were completely different until I saw Gavin's post here: http://forums.alfresco.com/viewtopic.php?t=2994

Thank You

Outcomes