I'm developing a REST API using Zend Framework 1.12.3.
I've got three different resources: classes, subjects and professors. Each class may have assigned multiple subjects, and each subject may have assigned one or multiple professors.
The schema would be something like this:
classes:
class:
id: 123
name: foo
subjects:
subject:
id: 14
name: Chemistry
professors:
professor:
id: 741
name: Jeremy Clarkson
professor:
id: 963
name: Richard Hammond
subject:
id: 16
name: Physics
professors:
professor:
id: 753
name: James May
I was wondering which is the best approach to list all the subjects and professors, both assigned and unassigned (on a page where the actual assignment is going to take place).
Should I return only the assigned subjects and professors, and then cross-reference those id to the array containing all the subjects and professors?
Or should I return an array containing all the subjects and professors, each having an "assigned" variable set to 0 or 1?
In other APIs I've seen that dealing with assigned users to certain projects is done using the first method (the API returns only the IDs of the assigned users, and then the client application cross-references those IDs with an array containing all the users). Is this the best practice regarding assignments ?