UML association class and OOP languages

367 Views Asked by At

I am building a web application with Django, I did the design app with UML2. i read that association class concept does not exist in object oriented programming languages, is that true ?? thank you.

class diagram

class diagram

1

There are 1 best solutions below

3
On BEST ANSWER

No. You can implement that model relationship design as follows:

class Society(models.Model):
    name = models.CharField(max_length=100)

class User(models.Model):
    name = models.CharField(max_length=100)
    societies = models.ManyToManyField(Society, through='Employment', related_name='users', blank=True)

class Employment(models.Model):
    class Meta:
        unique_together = [('user', 'society')]
    user = models.ForeignKey(User, on_delete=models.CASCADE)
    society = models.ForeignKey(Society, on_delete=models.CASCADE)
    salary = models.IntegerField()