I use an MVC web framework to create an application which contains a hierarchy:
Location <1-N> Devices <N-M> Services
I have a number of Locations. Each Locations can have several devices (represented by an 1-N relationship in the database). Each device runs services. The services (like http, ftp, etc) are defines in an extra table and are connected to the devices using an N-M relationship.
So far I have a model for each of the entities and one Location-controller for CRUD operations. Since the devices somehow belong to the location all the device CRUD-functions are located in the location controller as well. The services have their own controller. The url to access the data is structured like this:
/locations/ # to get an overview of the locations /locations/*id*/ # to view the details of one location /locations/*id*/edit # to edit the details of one location /locations/*id*/device/*deviceid*/ # to view details of a device /locations/*id*/device/*deviceid*/edit # to view details of a device /services/ # list of all the services /services/*id/ # view details of a service
Note: There are also urls to create and delete entries, which are omitted. But I think you get the idea.
Now to my questions: It feels wrong, and I think it is wrong to put all the functions inside the Location-controller, therefore I would like to move them so separate controllers. On the other hand, I like the URL-Structure, since it represents the hierarchy of the data pretty well. Furthermore I like when the URL structure corresponds with the Controllers.
What is the "better" solution: Separate controllers with combined URLs? Separate controllers, separate URLs? Or combined controller with combined URLs?