How do I go about modelling recursive optional dependency? Like a product may be comprised of other products? but can also be sold alone. I’d like to be able query a chimeric product from the top down i.e. from the parent to children as opposed to querying children who have the same parents, which is what my current design solution does.
Share
You need the bill of materials pattern for this type of requirement. The comment by Neville K points to a good blog about bill of materials.
In order to make it easier to work with the unlevel tree structure that such a design involves, you can use a physical implementation technique called visitation numbers, which I describe in some detail in my answer to this question.