D
D
Didi002019-04-27 12:24:56
Database design
Didi00, 2019-04-27 12:24:56

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!
5cc41cd8c3ec4471884741.png5cc41fccb42e7321495124.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
U
UndineS, 2019-04-27
@UndineS

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;

How to connect to the database from PHP and send a request, you can read, for example, here: www.softtime.ru/bookphp/gl12_10.php

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question