One big model vs small models with Foreign key relation - Django
Sorry for asking a silly question but I'm not able to figure out what should I use here. Also, I'm a noob into this.
The database is a sort of profile page something like Wikipedia of a sports player in-general.
Fields type 1 like name, team, DOB, role, country, total winnings, player of the match (times), and all these basic Char and Int fields.
Fields type 2: Early Life, Career history, net worth, match history, and all these fields that requires Text-field (each one in a separate field of its own for re-usability in other places).
And there are tens of fields including char and text for 1 person. And some of these fields like Career history, etc are going to have their own separate page.
Approach 1: Keep all fields in one model (looking at admin page, it's very hard to manage and painful to even look at, performance good for a single profile page but am I wasting any resources when a page need only a set of fields in a page like name and career history. Also, on archive pages where only 10-20 people are going to display with just name and image).
Approach 2: Create small models for each TextField type like Career history in different and net worth in different model and then link them with a foreign. (Seems okay for their own separate pages but when calling them all those 15-20 models on a profile with so many queries, does it hurt the performance?)
Or there is anything else that I could or should implement for backed or UI to reduce the load (if there's any?) like react and rest framework, or something
You can use second approach you mentioned.
For reduce queries you can use select_related and specifying the foreign keys related to the model when filtering.
You can read more in Django documents: https://docs.djangoproject.com/en/4.0/ref/models/querysets/