Complex Relation

I have manager (model Manager), categories(model Category), brands (model Brand), every manager should have a relation with Category.Brand, what should be the relation ?

Hi odermy,

I think it totally depends on the business logic of your application.

What is the relation between Category and Brand in your app? It may be "Category HAS_MANY Brand / Brand BELONGS_TO Category". But it can be "Category MANY_MANY Brand" … a category can have multiple brands and a brand can belongs to multiple categories at the same time. Which do you want?

And you also have to state clearly what you mean by "every manager should have a relation with Category.Brand".

Hi softark !

Relation between Category and Brand is many to many, Every manager can have relation, to all categories of brand, or only to some of them

OK, that’s fine.

I don’t understand it.

Is the relation between Manager and Category, or between Manager and Brand?

Manager to Categor - many to many, Manager to Brand - many to many

Looks a kind of chaotic situation.

But, well, if the things in the business are in fact like that, then you have to build your database relations according to that.

I do believe you answered your own question. You know the relations now.

Yeah, I mean that. :D