Model Best Practices and Relational Tables

Hi guys,

I've been working with ColdBox for about two months now and am really starting to see the power that has. Amazing framework Luis, and great dialogue from the community. I've been able to understand many of the sample applications successfully and am wondering if the group can share their insigsht on best practices for designing their models given what i'm trying to acheive.

I'm running ACF9 with CB 3.0, and am trying to leverage CF's ORM functionality as much as possible. My app is structured like this.

- Profile
- Contacts
- Locations
- Groups

A user can have multiple contacts, locations and groups, and one contact can belong to multiple users as well as locations. I have a bunch of relational tables which join on the various PK's and FK's but i'm struggling to wrap my head around how to best structure the models and one-to-many, many-to-many relationships. Since I'm using ORM does it make sense to add properties to my user object for locations, contacts, and groups so I could call something like oUserLocations = userService.getUser().getLocations() or is a better approach to use something like oUserLocations = LocationService.getLocationsByUser().

I'm not set on using ORM and it would very helpful to know how others structure their models and services to incorporate relational mappings/tables.

Many thanks.

Nolan Dubeau
XM Canada

If you're looking to "leverage ORM as much as possible", then I'd ask
the object itself for its data and relationships like in
"userService.getUser().getLocations()". Once you establish the
relationships, you'll always be able to get them from the object

If you're "not set on using ORM", then "
LocationService.getLocationsByUser()" may better as it may be easier
to switch out later.

- Gabriel