S
S
Sergey Litvinov2019-04-11 22:22:25
PHP
Sergey Litvinov, 2019-04-11 22:22:25

What is the best way to display relationships in tables?

Good afternoon
I'm writing a mini-framework. And I need to implement methods to query the mapper to the database. The question is:
Nested queries VS Joins.
On the one hand, nested queries are easy to write and quickly executed, on the other hand, joins seem to be there, so they need to be used. Given that the connection, for example, many-to-one, is implemented on joins unreasonably long (maybe I'm wrong).

Answer the question

In order to leave comments, you need to log in

3 answer(s)
I
Ivan Shumov, 2019-04-11
@SeApps

Take the implementation of Doctrine or Active Record already and don't chew your brain. Join and subquery are tools that are both good for their specific tasks. It is impossible to choose one of them as a spherical instrument in a vacuum. And subquery is usually much slower than join

I
irishmann, 2019-04-12
@irishmann

many-to-one implemented on joins is unreasonably long

There is a LEFT JOIN for such purposes

F
FanatPHP, 2019-04-12
@FanatPHP

Elderberry in the garden, and uncle in Kyiv. I am writing a microframework, I don’t understand how a nested query differs from a join, and I’ll put a PDO tag on the question, which has nothing to do with either.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question