QQ and Reverse Relationships

The power of QCubed ORM is the ability not just to code generate the code to handle foreign key relationships, but also the ability to have that code handle the "reverse" foreign key relationships. So in the Examples Site data model, we're talking about not just a Project and its ManagerPerson property... but we're also talking about a Person and methods like getProjectAsManagerArray().

QCubed Query also has this built-in capability, which works very similar to the way QQ handles Associations. And this should make sense -- from Person's point of view, it has a "-to-Many" relationship with Project as a Manager (via the reverse relationship), and it has a "-to-Many" relationship with Project as a Team Member (via the association table). Therefore QQ has the ability to perform the full set of QQ functionality (including conditions, expansions, ordering, grouping, etc.) on tables related via these reverse relationships just as it would on tables related via a direct foreign key or association table.

The naming standards for the relationship as well as the differences between expand() vs. expandAsArray() are all the exact same as the case with association tables.

Get All People, Specifying the Project They Manage (if any), for Projects that have 'ACME' or 'HR' in it

Notice how some people may be listed twice, if they manage more than one project.

Same as above, but this time, use expandAsArray()

Notice how each person is only listed once... but each person has an internal/virtual _ProjectAsManagerArray which may list more than one project.

  • Mike Ho via: State College HR Systzzzz
  • Karen Wolfe via: ACME Website Redesign, ACME Payment System