We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 10031
    • 69 Posts
    I am reviewing several topics about cardinality, primary key in the xml schema, and from:
    http://modxcms.com/forums/index.php/topic,11601.0.html
    I am understanding relationships. I am doing my own schema to use xpdo from MODx Evolution 1.0.2.

    would you please explain the especific kinds of relationships:
    <object class="modResource" table="site_content" extends="xPDOSimpleObject">
            <field key="type" dbtype="varchar" precision="20" phptype="string" null="false" default="document" />
            <field key="contentType" dbtype="varchar" precision="50" phptype="string" null="false" default="text/html" />
            <field key="pagetitle" dbtype="varchar" precision="255" phptype="string" null="false" default="" index="index" />
            <field key="longtitle" dbtype="varchar" precision="255" phptype="string" null="false" default="" />
            <field key="description" dbtype="varchar" precision="255" phptype="string" null="false" default="" />
            <field key="alias" dbtype="varchar" precision="255" phptype="string" null="true" default="" index="index" />
            <field key="link_attributes" dbtype="varchar" precision="255" phptype="string" null="false" default="" />
            <field key="published" dbtype="int" precision="1" phptype="boolean" null="false" default="0" />
            <field key="pub_date" dbtype="int" precision="20" phptype="timestamp" null="false" default="0" />
            <field key="unpub_date" dbtype="int" precision="20" phptype="timestamp" null="false" default="0" />
            <field key="parent" dbtype="int" precision="10" phptype="integer" null="false" default="0" index="index" />
            <field key="isfolder" dbtype="int" precision="1" phptype="integer" null="false" default="0" />
            <field key="introtext" dbtype="text" phptype="string" null="false" default="" />
            <field key="content" dbtype="mediumtext" phptype="string" null="false" default="" index="fulltext" />
            <field key="richtext" dbtype="tinyint" precision="1" phptype="integer" null="false" default="1" />
            <field key="template" dbtype="int" precision="10" phptype="integer" null="false" default="1" />
            <field key="menuindex" dbtype="int" precision="10" phptype="integer" null="false" default="0" />
            <field key="searchable" dbtype="int" precision="1" phptype="integer" null="false" default="1" />
            <field key="cacheable" dbtype="int" precision="1" phptype="integer" null="false" default="1" />
            <field key="createdby" dbtype="int" precision="10" phptype="integer" null="false" default="0" />
            <field key="createdon" dbtype="int" precision="20" phptype="timestamp" null="false" default="0" />
            <field key="editedby" dbtype="int" precision="10" phptype="integer" null="false" default="0" />
            <field key="editedon" dbtype="int" precision="20" phptype="timestamp" null="false" default="0" />
            <field key="deleted" dbtype="int" precision="1" phptype="integer" null="false" default="0" />
            <field key="deletedon" dbtype="int" precision="20" phptype="timestamp" null="false" default="0" />
            <field key="deletedby" dbtype="int" precision="10" phptype="integer" null="false" default="0" />
            <field key="publishedon" dbtype="int" precision="20" phptype="timestamp" null="false" default="0" />
            <field key="publishedby" dbtype="int" precision="10" phptype="integer" null="false" default="0" />
            <field key="menutitle" dbtype="varchar" precision="255" phptype="string" null="false" default="" />
            <field key="donthit" dbtype="tinyint" precision="1" phptype="boolean" null="false" default="0" />
            <field key="haskeywords" dbtype="tinyint" precision="1" phptype="boolean" null="false" default="0" />
            <field key="hasmetatags" dbtype="tinyint" precision="1" phptype="boolean" null="false" default="0" />
            <field key="privateweb" dbtype="tinyint" precision="1" phptype="boolean" null="false" default="0" />
            <field key="privatemgr" dbtype="tinyint" precision="1" phptype="boolean" null="false" default="0" />
            <field key="content_dispo" dbtype="tinyint" precision="1" phptype="integer" null="false" default="0" />
            <field key="hidemenu" dbtype="tinyint" precision="1" phptype="integer" null="false" default="0" />
            <field key="class_key" dbtype="varchar" precision="100" phptype="string" null="false" default="modDocument" index="index" />
            <field key="context_key" dbtype="varchar" precision="100" phptype="string" />
            <aggregate class="modResource" key="parent" local="parent" foreign="id" cardinality="one" />
            <aggregate class="modResource" key="id" local="id" foreign="parent" cardinality="many" />
            <aggregate class="modTemplate" key="id" local="template" foreign="id" cardinality="one" />
            <aggregate class="modUser" key="id" local="createdby" foreign="id" cardinality="one" />
            <aggregate class="modUser" key="id" local="editedby" foreign="id" cardinality="one" />
            <aggregate class="modUser" key="id" local="deletedby" foreign="id" cardinality="one" />
            <aggregate class="modUser" key="id" local="publishedby" foreign="id" cardinality="one" />
        </object>
        <object class="modUser" table="" extends="xPDOSimpleObject">
            <field key="username" dbtype="varchar" precision="100" phptype="string" null="false" default="" index="unique" />
            <field key="password" dbtype="varchar" precision="100" phptype="string" null="false" default="" />
            <aggregate class="modResource" key="createdby" local="id" foreign="createdby" cardinality="many" />
            <aggregate class="modResource" key="editedby" local="id" foreign="editedby" cardinality="many" />
            <aggregate class="modResource" key="deletedby" local="id" foreign="deletedby" cardinality="many" />
            <aggregate class="modResource" key="publishedby" local="id" foreign="publishedby" cardinality="many" />
    


    modeled in modx095.mysql.schema.xml that you suggest in http://modxcms.com/forums/index.php/topic,11601.0.html to learn?

    With your information I could understand very well the attributes and their application (as key, local, alias, owner and foreing). I do not have problems with cardinality and aggregate and composite

    thank you for your time
      • 28215
      • 4,149 Posts
        shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com
        • 10031
        • 69 Posts
        Yes, I was already reviewing, but I have some questions, and that is the reason for that I reviewed, also, http://modxcms.com/forums/index.php/topic,11601.0.html and its tecommendations.

        Therefore, I wish to understand with one holistic example, the application of the relationships attibutes, and for example:
        <aggregate class="modResource" key="parent" local="parent" foreign="id" cardinality="one" />
                <aggregate class="modResource" key="id" local="id" foreign="parent" cardinality="many" />
                <aggregate class="modTemplate" key="id" local="template" foreign="id" cardinality="one" />
                <aggregate class="modUser" key="id" local="createdby" foreign="id" cardinality="one" />
                <aggregate class="modUser" key="id" local="editedby" foreign="id" cardinality="one" />
                <aggregate class="modUser" key="id" local="deletedby" foreign="id" cardinality="one" />
                <aggregate class="modUser" key="id" local="publishedby" foreign="id" cardinality="one" />

        from:
        modx095.mysql.schema.xml

        note: Also, I have already knowledge as suggest:

        http://svn.modxcms.com/docs/display/XPDO10/Design+Patterns
        from: Martin Fowler’s Patterns of Enterprise Application Architecture.
        I am using xpdo 1.0 because i am going to use xpdo for MODx evolution.
        • First of all, that modx095 schema is out of date, and the attributes for relationships have changed; there is no longer a key attribute, and there is now an alias attribute.

          I’m not sure exactly what you are asking for when you say "I wish to understand with one holistic example, the application of the relationships attibutes". Can you be more concise on what information you are looking for that is not described in the documentation?
            • 10031
            • 69 Posts
            thank you for your reply,
            OpenGeek,

            Yes, I want to explain to you what is the situation:

            I am using Modx evolution 1.0.2, and I am going to use xpdo 1.0 in order to prepare my knowledge for Revolution when it is Generally Available.

            Then I want to manage my own database, and I am using the xpdo 1.0 documentation for Modx evolution. I have already defined my schema.

            ?xml version="1.0" encoding="UTF-8"?>
            <model package="ecuadormycountryta" baseClass="xPDOObject" platform="mysql" defaultEngine="MyISAM" phpdoc-package="ecuadormycountryta" phpdoc-subpackage="model">
            <object class="ecumctaSegment" table="tourismsegment" extends="xPDOSimpleObject">
               <field key="segmentid" dbtype="integer" precision="20" phptype="integer" null="false" default="" index="index" />
               <field key="segmentname" dbtype="varchar" precision="200" phptype="string" null="false" default="" index="" />
               <composite class="ecumctaTa" key="tatype" local="tatype" foreign="segmentid" cardinality="many" />
            </object>
            <object class="ecumctaTa" table="tourismattractivetype" extends="xPDOSimpleObject">
               <field key="tatype" dbtype="integer" precision="100" phptype="integer" null="false" default="" index="index" />
               <field key="taname" dbtype="varchar" precision="200" phptype="string" null="false" default="" index="" />
               <aggregate class="ecumctaSegment" local="segmentid" foreign="tatype" cardinality="one" />
               <composite class="ecumctaEnlacetp" key="tatype" local="tatype" foreign="id" cardinality="many" />
            </object>
            <object class="ecumctaEnlacetp" table="enlacetipoproducto" extends="xPDOSimpleObject">
               <field key="id" dbtype="integer" precision="1000" phptype="integer" null="false" default="" index="index" />
               <field key="tatype" dbtype="integer" precision="100" phptype="integer" null="false" default="" index="index" />
               <field key="tproduct" dbtype="integer" precision="10000" phptype="integer" null="false" default="" index="index" />
               <aggregate class="ecumctaTa" local="id" foreign="tatype" cardinality="one" />
               <aggregate class="ecumctaTproduct" local="id" foreign="tproduct" cardinality="one" />
            </object>
            <object class="ecumctaTproduct" table="tourismproduct" extends="xPDOSimpleObject">
               <field key="tproduct" dbtype="integer" precision="10000" phptype="integer" null="false" default="" index="index" />
               <field key="productname" dbtype="varchar" precision="200" phptype="string" null="false" default="" index="" />
               <field key="worldlocation" dbtype="varchar" precision="10" phptype="string" null="false" default="" index="" />
               <field key="description" dbtype="varchar" precision="200" phptype="string" null="false" default="" index="" />
               <field key="contactid" dbtype="integer" precision="10000" phptype="integer" null="false" default="" index="" />
               <composite class="ecumctaEnlacetp" key="tproduct" local="tproduct" foreign="id" cardinality="many" />
               <composite class="ecumctaPcontact" key="tproduct" local="tproduct" foreign="contactid" cardinality="many" />
            </object>
            <object class="ecumctaPcontact" table="productcontact" extends="xPDOSimpleObject">
               <field key="contactid" dbtype="integer" precision="10000" phptype="integer" null="false" default="" index="" />
               <field key="contactname" dbtype="varchar" precision="200" phptype="string" null="false" default="" index="" />
               <field key="tproduct" dbtype="integer" precision="10000" phptype="integer" null="false" default="" index="index" />
               <aggregate class="ecumctaTproduct" local="contactid" foreign="tproduct" cardinality="one" />
               <composite class="ecumctaCdetalle" key="contactid" local="contactid" foreign="iddetalle" cardinality="many" />
            </object>
            <object class="ecumctaCdetalle" table="contactdetalle" extends="xPDOSimpleObject">
               <field key="iddetalle" dbtype="integer" precision="1000" phptype="integer" null="false" default="" index="index" />
               <field key="contactname" dbtype="varchar" precision="200" phptype="string" null="false" default="" index="" />
               <field key="contactid" dbtype="integer" precision="10000" phptype="integer" null="false" default="" index="" />
               <aggregate class="ecumctaPcontact" key="contactid" local="iddetalle" foreign="contactid" cardinality="one" />
            </object>
            </model>
            

            and Now, I am working with the Generating the Model Code documentation, and I am seeing some xpdo information from Community Forums as http://modxcms.com/forums/index.php/topic,12895.20.html to try to join all. Now, I have some questions.

            From http://modxcms.com/forums/index.php/topic,12895.20.html is used 095 schema, but I download from another community forum case the 096 schema. May i use 096 schema for MODx evolutiion 1.0.2?

            Regard to "I wish to understand with one holistic example, the application of the relationships attibutes". I wish to find one integral example from schema phase until access to data phase in order to understand the complete sequence to manage data from xpdo. The situation is that from community forum there are pieces of information in different date; therefore, for example you tell me that key attribute theres is not used more and 095 schema or I do not if the example from http://modxcms.com/forums/index.php/topic,12895.20.html will work. The questions is: May I obtain on sample y complete example to implement xpdo with evolution 1.0.2 ?

            thanks