Answer the question
In order to leave comments, you need to log in
Connections (relationships) between entities. Tracking connections of the second, third, n+ levels. What are the solutions?
Good afternoon!
There is a task of tracking connections of the second, third, n+ levels between entities in the database.
MySQL database, PHP programming language.
Please suggest the best solutions.
This means in which direction to go deep, technologies, algorithms, links to documents, solutions.
What is the possible optimal solution in php - mysql ?
It may be worth using additional tools, technologies.
Thank you in advance!
Answer the question
In order to leave comments, you need to log in
Look at examples on database normalizations, there should be just about similar cases of "one-to-many", "many-to-many" relationships. And about primary/foreign keys.
Generally standard solutions:
To form a query with unloading links of large nesting, you should use JOIN - joining tables by keys. Using JOIN, you can make a selection of the type:
Select the records of the "Character"
table Join with the "Character - Domain" table by the condition "Character.ID"="Character-Domain.ID_Character"
Join with the "Domain" table by the condition "Character-Domain. Domain_ID"="Domain.ID"
Thus, you can add as many joins as you need to the query.
MySQL JOIN example:
SELECT person.*, domain.*
FROM person
LEFT JOIN person_domain ON person.id=person_domain.person_id
LEFT JOIN domain ON person_domain.domain_id=domain.id;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question