Database design with 2 m2m relationships
I'd like some advice on how to further develop my models and tables.
This model currently allows me to save option that links to disease and
state in a m2m relationship. How would I further build this out if I
wanted to save outcome and it's associated value that links to state,
disease, AND option?
For example, outcome will have specific options associated to it. Options
will a specific state which will have a specific disease linked to it. For
every outcome linked to specific options, there will be a value assigned
to it.
I think I need an intermediate table because of the outcome value the user
will assign to it. I'm confused as how to link outcome to option,since
option is m2m.
class Option(models.Model):
disease = models.ForeignKey(Disease)
option = models.CharField(max_length=300)
class Outcome(models.Model):
disease = models.ForeignKey(Disease)
outcome = models.CharField(max_length=200)
class DiseaseState(models.Model):
state = models.CharField(max_length=300)
disease = models.ForeignKey(Disease)
option = models.ManyToManyField(Option, blank=True)
#outcome = models.ManyToManyField(Outcome, blank=True) #will adding
this solve my use case? It does not seem like outcome will link to
option.
No comments:
Post a Comment