Creating a category system with MVT in django
I am working on a project and I created a system that has cars model and some user models . I want to create another model for user's skills and give the user model a relation to skill model . But I don't know how to do this optimize?
for example , some users may can't fix the gearbox of one car But others Can , And some users may can fix some engine problems with some cars that others can't! So with this I need to have ralations to 'Car' model and also I have to save the skills with cars in the database . But there is more than 2000 cars in database!
What do you think I can do?
To optimize this system, consider creating a separate Skill model with fields like name and description. Then, create an intermediate model called UserCarSkill that links User, Car, and Skill models using foreign keys. This allows you to associate specific skills with particular users and cars.
This is just an example I can think of:
class Skill(models.Model):
name = models.CharField(max_length=100)
class UserCarSkill(models.Model):
user = models.ForeignKey(User, on_delete=models.CASCADE)
car = models.ForeignKey(Car, on_delete=models.CASCADE)
skill = models.ForeignKey(Skill, on_delete=models.CASCADE)
It's scalable and can handle the large number of cars in your database while providing flexibility for future additions or changes to the skill system.