So I have this table :
+----+-----------+----------+
| id | id_parent | id_child |
+----+-----------+----------+
| 1 | 10 | 9 |
| 2 | 11 | 9 |
| 3 | 12 | 11 |
| 4 | 13 | 11 |
| 5 | 14 | 13 |
+----+-----------+----------+
And I'd like to select the parent with the most children. Obviously if 9 is a child of 11 and 11 is a child of 13, then 9 is a child of 13. here if I use :
SELECT id_parent,COUNT(id_child) AS count
from dependency
GROUP BY id_parent ORDER BY count DESC;
It would give 1 for each parent. Is there any way to do this without adding more records to the database. (That means without adding 9 child of 13...etc.) (Modification to the table schema could also be a solution).