| hoo added a comment. |
Just as a note:
I looked into (ab)using the pagelinks table for this purpose. If we want to link an entity to its parent, the pages in question must also be (indirectly) page-linked together. My idea was to get the (indirect) pagelinks from a to b first, and then check the entities in question to find out whether this actually is the kind of relationship we're looking for.
Such a query would look like this (find a link between an entity and a target entity with N hops in between):
SELECT pl0.pl_from, pl1.pl_from, pl2.pl_from, … plN.pl_from FROM pagelinks AS pl0
INNER JOIN page AS p1 ON pl0.pl_namespace = p1.page_namespace AND pl0.pl_title = p1.page_title INNER JOIN pagelinks AS pl1 ON pl1.pl_from = p1.page_id INNER JOIN page AS p2 ON pl1.pl_namespace = p2.page_namespace AND pl1.pl_title = p2.page_title INNER JOIN pagelinks AS pl2 ON pl2.pl_from = p2.page_id … INNER JOIN page AS pN ON pl(N-1).pl_namespace = pN.page_namespace AND pl(N-1).pl_title = pN.page_title INNER JOIN pagelinks AS plN ON plN.pl_from = pN.page_id WHERE pl0.pl_from = PAGE_ID_OF_THE_ENTITY AND plN.pl_namespace = 0 AND plN.pl_title = 'TARGET_ENTITY_PAGE_TITLE';
I briefly looked into this, but the resulting query clearly didn't cut it, so I'm not going to look into this further.
TASK DETAIL
EMAIL PREFERENCES
To: hoo
Cc: Lucas_Werkmeister_WMDE, thiemowmde, Lydia_Pintscher, daniel, Aklapper, aude, Ricordisamoa, Liuxinyu970226, hoo, Lahi, Gq86, GoranSMilovanovic, lisong, QZanden, LawExplorer, Wikidata-bugs, Mbch331
Cc: Lucas_Werkmeister_WMDE, thiemowmde, Lydia_Pintscher, daniel, Aklapper, aude, Ricordisamoa, Liuxinyu970226, hoo, Lahi, Gq86, GoranSMilovanovic, lisong, QZanden, LawExplorer, Wikidata-bugs, Mbch331
_______________________________________________ Wikidata-bugs mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/wikidata-bugs
