How to recognize which is a master project and which is a subproject.
There is INV_FLAT_HIERARCHIES table that includes PARENT_ID and CHILD_ID columns.
PARENT_ID means Master Project ID.
CHILD_ID means Subproject ID.
Here is a sample query to get the pares of Master and Subproject. (Project and Program)
SELECT A.PARENT_ID MASTER_PROJECT_ID,
FROM INV_FLAT_HIERARCHIES A,
WHERE A.PARENT_ID =B.ID
AND A.PARENT_ID != A.CHILD_ID