Companies
代表一些PlaceTypes
(健身房,游泳池等)。PlaceTypes
有不同的Criterias
进行评估(员工,清洁度等)class Companies(models.Model):
name = models.CharField()
class PlaceTypes(models.Model):
name = models.CharField() # Gym, pool, etc.
company = models.ForeignKey(Companies)
class Criterias(models.Model):
name = models.CharField() # Staff, cleanness, etc.
place_type = models.ForeignKey(PlaceTypes)
class Ratings(models.Model):
company = models.ForeignKey(Companies)
criteria = models.ForeignKey(Criterias)
votes = models.PositiveIntegerField()
total = models.PositiveIntegerField()
因此,Companies -> PlaceTypes -> Criterias
和Companies <- Ratings -> Criterias
之间存在某种重复。可以吗?
答案 0 :(得分:0)
您在评级模型中不需要公司作为外键,该模型已经有标准,其place_type指向公司,即Companies -> PlaceTypes -> Criterias -> Ratings
。