Best way to model a relationship in gadget?
I have 2 fields on an Order model: StoneChoice1 and StoneChoice2, which each need to be linked to a Stone model.
The same stone record, could potentially be used for both choices (though generally they would differ), as well as on multiple Orders.
What would be the best form to model this relationship in gadget?
My intuitive feel would be two one-to-many relationships as one Stone can belong to many Orders.
I also cannot easily merge StoneChoice1 & 2 and have a many to many, as each Stone Choice has related fields like Stone finish. Although if anyone can suggest a methodolgy for this i'm open to it
2 Replies
Hello,
I immediately think many to many myself. I think that you could do hasManyThrough and then have a hasManyThrough for finish as well. Or you could do finish hasMany of the join model! Thoughts on that approach?
The issue i found with that is then matching the stone to the finish upon retrieval.
I think i may have found a way around that though, by making a third model which is a record of stonechoice and finish, and then having a many to many with stoneChoices. Slightly inelegant but seems to be functional.
Thank you for your help though, it helped me think through the real problem which was the matching aspect. In hindsight, it could only ever be many to many. It just need the matching problem fixed to allow it.