I have some trouble,
Data Example:
animal_table:
- id
- name
- desc
farmer_table:
- id
- name
- desc
investor_table:
- id
- name
- desc
Main Trouble: now i will create Simple CRUD applications, but there is some conditions.
Investors(Many) to Animals(Many)
Farmers(One) to Animals(Many)
how do i create the database Structure for this problems
2
Answers
In this answer it is shown what you need:
How to implement one-to-one, one-to-many and many-to-many relationships while designing tables?
For your example it would be something like this:
Investors(Many) to Animals(Many)
You need a need Table like investor_animal:
Farmers(One) to Animals(Many)
You can give the animal table a farmer_id. So the animal knows who is the farmer.
The textbook solution to implementing a many-to-many relationship is a mapping table with the IDs of the entities you want to have in the relationship. Each row in this mapping table represents a connection between the two entities. E.g.: