0

Is it somehow possible to allow duplicate items in a many-to-many relation in Strapi? If not, whats the alternative?

I can have item A, B, C as it is now, not A, B, C, A, B which I need.

keysersoze
  • 777
  • 3
  • 12
  • 27

1 Answers1

0

A many-to-many relation requires an auxillary table, which cannot have duplicate entries.

What is the use case you are trying to solve? if its possible with usual database relations its also possible in strapi, but it has more to do with database design than strapi.

Markido
  • 424
  • 3
  • 8
  • Hi @Markido If I look at the tables, there is a unique key for each row, its not a combined key, so by design it should be possible. Adding a "legal" row directly in the database works fine, adding an "illegal" row does not fail but it does not show the "illegal" row in the Strapi backend. What I am about to design is an excercise application - a programme contains one or more sets, a set contains one or more excercises and a set should be able to contain the same excercise more than once. – keysersoze Jul 22 '21 at 14:11
  • That sounds like two different many-to-many relations. – Markido Jul 22 '21 at 14:22
  • And three, four and five if an exercise could be included more times? Strapi should be able to do better when the database structure is fine – keysersoze Jul 22 '21 at 17:28
  • Im surprised that Strapi would limit this for you. However, perhaps it would be worth making a feature request on this? if we can formalise it and the community approves, i wouldn't mind implementing it. – Markido Jul 22 '21 at 20:03