We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 40385
    • 75 Posts
    Hello guys,

    this is my first try developing with MIGXdb and xpdo. What I am trying to accomplish is a simple directory that consists of three dependent tables:


    • events
    • categories
    • events_to_categories

    This is the xml schema that I came up with:

    <?xml version="1.0" encoding="UTF-8"?>
    <model package="directoryx"
       baseClass="xPDOObject"
       platform="mysql"
       defaultEngine="MyISAM"
       version="1.1">
    
    	<object class="dxEvent" table="directoryx_events" extends="xPDOSimpleObject">
    		<field key="name" dbtype="varchar" precision="100" phptype="string" null="false" default="" />
    		<field key="description" dbtype="text" phptype="string" index="fulltext" />
    		<field key="image" dbtype="varchar" precision="255" phptype="string" null="false" default="" />
    
            <field key="deleted" dbtype="tinyint" precision="1" attributes="unsigned" phptype="integer" null="false" default="0" />
            <field key="published" dbtype="tinyint" precision="1" attributes="unsigned" phptype="integer" null="false" default="0" />
    
    		<index alias="name" name="name" primary="false" unique="false" type="BTREE">
    		    <column key="name" length="" collation="A" null="false" />
    		</index>
    		<index alias="published" name="published" primary="false" unique="false" type="BTREE">
    		  <column key="published" length="" collation="A" null="false" />
    		</index>
    		<index alias="deleted" name="deleted" primary="false" unique="false" type="BTREE">
    		  <column key="deleted" length="" collation="A" null="false" />
    		</index>
    
    		<composite alias="EventsToCategories" class="dxEventToCategory" local="id" foreign="event" cardinality="many" owner="local" />
    
    	</object>
    
    	<object class="dxCategory" table="directoryx_categories" extends="xPDOSimpleObject">
    		<field key="name" dbtype="varchar" precision="100" phptype="string" null="false" default="" />
    
    		<field key="deleted" dbtype="tinyint" precision="1" attributes="unsigned" phptype="integer" null="false" default="0" />
            <field key="published" dbtype="tinyint" precision="1" attributes="unsigned" phptype="integer" null="false" default="0" />
    
    		<index alias="name" name="name" primary="false" unique="false" type="BTREE">
    		  <column key="name" length="" collation="A" null="false" />
    		</index>
    		<index alias="published" name="published" primary="false" unique="false" type="BTREE">
    		  <column key="published" length="" collation="A" null="false" />
    		</index>
    		<index alias="deleted" name="deleted" primary="false" unique="false" type="BTREE">
    		  <column key="deleted" length="" collation="A" null="false" />
    		</index>
    
    		<composite alias="EventsToCategories" class="dxEventToCategory" local="id" foreign="category" cardinality="many" owner="local" />
    
    	</object>
    
    	<object class="dxEventToCategory" table="directoryx_event_to_category" extends="xPDOSimpleObject">
    		<field key="event" dbtype="int" precision="10" attributes="unsigned" phptype="integer" null="false" default="0" />
    		<field key="category" dbtype="int" precision="10" attributes="unsigned" phptype="integer" null="false" default="0" />
    
    		<index alias="event" name="event" primary="false" unique="false" type="BTREE">
    		  <column key="event" length="" collation="A" null="false" />
    		</index>
    		<index alias="category" name="category" primary="false" unique="false" type="BTREE">
    		  <column key="category" length="" collation="A" null="false" />
    		</index>
    
    		<aggregate alias="Event" class="dxEvent" local="event" foreign="id" cardinality="one" owner="foreign" />
    		<aggregate alias="Category" class="dxCategory" local="category" foreign="id" cardinality="one" owner="foreign" />
    
    	</object>
    
    </model>


    I followed the guide in the rtfm to create the MIGXdb and connect it to a CMP. I created two CMPs for managing the events and managing the categories. The task I am struggling with is the relationship between the events and the categories. In my xml scheme you can see that I created a third table to manage the relationships between events and categories. Now my question: What is the next step in MIGXdb? Do I need to add another config for my many-to-many relationship table and provide an input field as a checkbox in the Add Event dialogue?

    Thanks in advance! [ed. note: paul_kemp last edited this post 11 years, 1 month ago.]