Database Design – Handling Multiple Associative Tables

database-design

I really need so help regarding an issue I'm having. I'm trying my best to explain the problem, if anything is not clear please tell me. Some help would mean the world to me!

Here's my problem, let's say I have these 4 tables:

**CRIMINAL**
+ ID
+ Name
+ Image


**CAR_CRIMINAL**
+ ID
+ Type
+ Image

**COMPANY_CRIMINAL**
+ ID
+ Name
+ Image

**IMAGE**
+ ID
+ Link

For example, all entities (Criminal, car_criminal, Company_criminal) all have the attribute image. But an image can be assigned to multiple companies and a company can have multiple images so therefor it's a many-to-many relationship right?

That's also applicable to the all other tables. My question is, would I have to create an associative table for each of those many-to-many relationships or is there another way to resolve this problem?

Best Answer

Yes, if you want to reuse an image between multiple entities and a single entity can have multiple images you'll need to make it a many-to-many relationship. And yes, you would want to create multiple associative tables for each many-to-many relationship.

The only way around this would be to create one Entity table that all of the other tables pulled their IDs from, but I think what you currently have is easier to maintain going forward.