Answer the question
In order to leave comments, you need to log in
What is the best way to make relationships between tables?
I went on academic leave, now I'm back and I need to complete my diploma. But a couple of questions arose. One of the modules of the project is a catalog of exercises. There is an exercise, a group of muscles (legs, arms, chest, etc.), the muscles themselves separately.
Relationship:
1) Muscle groups to individual muscles: one to many.
2) Muscle groups for exercise: one to many.
3) Individual muscles to exercise: many to many. But there should be 2 many-to-many relationships, the first in relation to the target muscles, and the second to the muscles that receive the indirect load.
Is it normal that there will be 2 many-to-many relationships, but for different purposes?
Answer the question
In order to leave comments, you need to log in
Exercise
(# Id -- exercise
id * Grp_Id -- muscle group id, ext key
* Name -- Name,
* Descr -- Description
)
Muscles
(# Id -- muscle id,
* Grp_Id -- muscle group id , foreign key,
* Name -- Name
)
Muscle group
(# Id -- muscle group id,
* Name -- Name
)
Exercise impact
(# Id -- impact id,
* Ex_Id -- exercise id, ext. key
* Mus_Id -- muscle id, extern key
* Power -- strength of impact or just target flag
)
If you are talking about a "many-many" relationship, then you should know that behind it there is another plate that implements an associative relationship between the main objects, and in fact these are two relationships through a table. In your case, it is the Impact of the exercise. If we take the concept of a graph ("many-many" is always a graph, or rather its ribs). Then, exercises and muscles are the vertices of the graph, and the edges are just the pairs [ex_id, mus_id], the weight of the edge is the impact force. In the same table, it would be possible to store the edges of influences on muscle groups [ex_id, grp_id], in this case mus_id will be filled with null values, but the task says that you need to associate muscle groups with exercises.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question