Generally, you're trying to model a network in a relational database. Doable, but very difficult.
When data describes a social network, or a family tree, or a bill of materials, hierarchical depth depends on the data. You no longer know how many Joins will be needed to walk the network. You may need a different data model: the graph, about which you may wih to read a little (https://en.wikipedia.org/wiki/Graph_database). Also about network databases (https://en.wikipedia.org/wiki/Network_model).
There's an example relational schema of a social network at
http://www.databaseanswers.org/data_models/social_networking/index.htm. If you decide ti stick with relational, that might be a place to start.
> if these tables would work for this output
That's the key question in relational database design. The only way to find out is to try to write the queries, and modify the schema as you go. I'm very suspicious about ...
p_id1 int(11) NOT NULL,
p_id2 int(11) NOT NULL,
o_id1 int(11) NOT NULL,
o_id2 int(11) NOT NULL,
but it's premature to quibble about details.