- Transitivity, in my understanding means
A->B + B->C = A->C
- Among thousands of users it is unlikely that all connected.
In such assumptions we are talking about connectedness of the graph. Hierarchical data structure(tree, graph) foreign to the relational algebra of SQL. Known solutions Adjacency list and Nested sets
. Adjacency list requires WITH RECURSIVE. Nested sets involves a lot of resampling operations(especially INSERT).
You need a data model it would be more convenient to implement in hierarchical DB (e.g. simple hierarchical key value Redis or levelDB will do) or graph DB or certificated DB (for example just in the XML, which in essence is hierarchical)