[Answer]-Cloning Django models or add a differentiating field in the second model?

1đź‘Ť

âś…

Use model inheritance

class DataModel(model):
    time = ...
    value = ...
    label = ...

class TrainDataModel(DataModel):
    pass

class TestDataModel(DataModel):
    pass

And for optimization you can use indexes, and like Lara says visit django documentation

👤Uhsac

0đź‘Ť

I would mind to create 2 different models because you will use them for different things, even the data is almost the same. You don’t know, maybe in the future you will need new attributes for a specific reason and you will have to split the model… I think is better you do it now.

Even if you have only one model for your case, you will need to query twice, because first you have to filter by the flag “trainDataModel” and second for the flag “testDataModel”, I still think is better you split them now.

About query optimization you can take a look at this topic in Django Documentation:

https://docs.djangoproject.com/en/dev/topics/db/optimization/

Don’t forget to create indexes if necessary and in last case you could do a Stress testing…

http://en.wikipedia.org/wiki/Stress_testing_(software)

Good luck!

👤Lara

Leave a comment