Imagine the following BIG-DATA situation:
There are 1 million persons stored in a SQL database. Each of them follows exactly 50 other persons.
So there is a table like this (with 50 million entries):
person1 | person2
0 | 1
0 | 2.341
0 | 212.881
.. | ..
999.999 | 421.111
999.999 | 891.129
999.999 | 920.917
Is it possible to use Oracle's connect by
or MySQL's WITH RECURSIVE
to find out if there is a connection (maybe over intermediaries) from one person to an other?
Would those queries literally run forever? (the data are highly connected)
Or is there a way to limit the depth of the queries? (in this case: only < 3 intermediaries)
context: this example will be used to explain why a graph database can be better in some cases and I want to show whether this is even solvable with SQL.