On 2015-05-09 15:52, Tom Evans wrote: > I would simplify things, have just one type of user, who can be > associated with 1:N companies and 1:N schools. A user is an employer > if they are associated with at least one company, and a user is a > student if they are associated with at least one school. > > You could denormalise the relationship with attributes on the user > model if/when you are worried about performance. > > Eg: > > class Company(models.Model): > name = ... > contact_details = ... > > class School(models.Model): > name = .... > > class User(models.Model): > ... > company = models.ManyToManyField(Company) > school = models.ManytoManyField(School)
Since people can attend multiple schools and work for multiple employers, you can just make it a many-to-many, using the stock auth User: from django.contrib.auth.models import User class Company(models.Model): ... class School(models.Model): ... class Employee(models.Model): company = models.ForeignKey(Company) employee = models.ForeignKey(User) class Student(models.Model): school = models.ForeignKey(School) employee = models.ForeignKey(User) -tkc -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/20150509101555.4f0e8a50%40bigbox.christie.dr. For more options, visit https://groups.google.com/d/optout.