0

currently I'm doing a project and planning on creating a REST API but the problem I'm facing is designing the database primarily a many to many table (marked in red on the image).

In college I was thought that I need to use composite keys when creating many to many tables but since I'm doing a REST API I feel it will get to complicated especially since the many to many table can have one to many relationships and reason for this is the following: many plant species can have the same useful part but the image of the part can be different and so can the bioactive substance.

I was thinking about creating a normal Auto increment key for the many to many table and just add an unique index on the plantspecies_id and usefulpart_id but I'm not sure if that is the correct way.

Is there a optimal way of doing this but keep the database design as correct as possible in terms of rules?

enter image description here

I.Miljancic
  • 29
  • 1
  • 4
  • Please [use text, not images/links, for text--including tables & ERDs](https://meta.stackoverflow.com/q/285551/3404097). Give just what you need & relate it to your problem. Use images only for what cannot be expressed as text or to augment text. Images cannot be searched for or cut & pasted. Include a legend/key & explanation with an image. – philipxy May 09 '20 at 02:38
  • Yes, you can *add* an `_ID` if for some reason you want or must, see: https://stackoverflow.com/questions/14588304/composite-primary-key-vs-additional-id-column/14591232#14591232 – Damir Sudarevic May 09 '20 at 11:35

0 Answers0