-
☆ A M B ☆
- 2,475 Posts
Would you think that the modx users would define its id column as a primary key in the XML schema? But in core/model/schema/modx.mysql.schema.xml I don’t see a field definition for an auto_increment primary key column. Is that correct?
-
MODX Staff
- 730 Posts
It extends modPrinciple which extends xPDOSimpleObject.
xPDOSimpleObject defines the primary key.
-
MODX Staff
- 730 Posts
Hey, I was wondering where that post had gone, thanks!

I’m pretty sure that’s Jason’s xPDO model for the Evo database.
Look in core/model/schema for modx.mysql.schema.xml for Revo.
2007.. wow.
I’m talking out of my butt here, because I’ve never actually done what you’re trying to do, but take a look at modResource, modResourceGroup, and modResourceGroupResource for a fairly simple 3 table many-to-many association. Delete the word "accessible" and most (all?) of the aggregate aliases and all the composite aliases that don’t refer to one of the three objects and it should be close to what you need.
Doing the same with modChunk and modCategory would be close to what you need for a one-to-many 2 table relationship.
I know what you mean and I’m sure that your work will be really valuable to others.
For cardinality, I think it helps to ask whether the class you’re defining could be attached to more than one of the thing named in the alias. A user can only have one Profile, so in the modUser class, the cardinality of the Profile alias is one. Similarly, a given Profile can have only one user, so the cardinality of the modUser alias in the modUserProfile class is also one.
For one-to-many relationships, the category can have many chunks so the Chunk alias in the modCategory class has a cardinality of "many." The chunk, though, can belong to only one category, so the Category alias in the modChunk class has a cardinality of "one."
For many-to-many relationships, the user group can have many users and the user can belong to many groups. So the cardinality for the User alias in the modUserGroup class is "many." The same for the UserGroup alias in the modUser class. But the intersect object, modUserGroupMember, is one row in the intersect table, so it can have only one user, one role, and one user group -- so a cardinality of "one" for each of those aliases (User, Role, and UserGroup) in the modUserGroupMember class.