Implementing a hierarchical select field in advanced modules
Say you have a model 'people' and that you need to store a 'role'. Roles are of 2 different types:
1) Technician
2) Professor
and that no.2 'professor' needs to take an additional field ( a foreign key) that says to which 'course' (another model) this professor belongs to (ie 'Design' ,'Philosophy', etc)
I can imagine something like a javascript hack that would show the courses dropdown only if 'professor' was selected. The real question here is more of a general database design kind: how would you translate this structure into a table?
Pseudocode:
table people
-----
id
name
(...)
role -> ENUM : 'technician', 'professor'
course_id -> NULL (foreign key)
and populate course_id only if professor is selected?
I have the feeling this is not so very elegant... any volounteer?
Comments
If someone can tell me other downsides, please do so!
Thank you!