I have Users
which can be either TypeS
, TypeC
, or TypeA
. I have models for each of these types to store additional information. Now, in the Users
table, should I have
I'm using Django if you want to provide a more refined answer.
Django provides Generic relations as part of the contenttypes framework, which allows you to implement something similar to your option #2, just more flexible. You can establish generic relations by adding the following fields to your model:
content_type = models.ForeignKey(ContentType)
object_id = models.PositiveIntegerField()
content_object = generic.GenericForeignKey('content_type', 'object_id')
This way you can assign one of TypeS
, TypeC
, or TypeA
to each user in question. Also, should you ever have the need to add a TypeX
or a TypeY
, you're already set and don't need to extend the model.