Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

lirone's avatar

Polymorphic relation use cases with Laravel - Design Database

I try to design my database and I get confuse.

In my app, an user belong to a group and this group may have multiple stocks of only one type of equipement.

Those stocks can be of two types:

  • Stock of power lines
  • Stock of windturbine

Each stock has an identifier representing the area. Each stock has multiple equipements.

So, to summarize :

User A belongs to group A. Group A has :

  • Windturbine1 which has 5 individual windturbines
  • Windturbines2 which has 10 individual windturbines

User B belongs to group B. Group B has :

  • power_lines1 which has 10 individual powerlines

I tried to represent this scheme like this :

enter image description here

However, I'm not totally convinced. I'm not sure if the stock table need to be polymorphic with windturbine_area and power_line_area.

enter image description here

Any help on this please ?

0 likes
1 reply
bugsysha's avatar

As I see it, assuming that I understand, you have the following:

  • Many to many for group and user
  • A location that belongs to the group

And that is it. The location has a type that can be wind turbine or power line. I do not see how stock fits in.

Please or to participate in this conversation.