6

I am doing some analysis of Stack Overflow posts using the Stack Exchange dump. I'd like to do analyze the downstream effects of posts on the community, and I was wondering if there is a source that gives the related questions for each questions.

0

1 Answer 1

3

The table PostLinks is available in both SEDE and the data-dump. This is its schema as found in Database schema documentation for the public data dump and SEDE :

PostLinks

  • Id primary key
  • CreationDate when the link was created
  • PostId id of source post
  • RelatedPostId id of target/related post
  • LinkTypeId type of link
    1 = Linked (PostId contains a link to RelatedPostId)
    3 = Duplicate (PostId is a duplicate of RelatedPostId)

There are two types of links: One due to a question being closed as a duplicate (LinkTypeid = 3) and one due to a question being linked in the body of a post or in a comment (LinkTypeId = 1).

With this knowledge you can for example find the question that is the most linked:

select top 1
       relatedpostid [Post Link]
from PostLinks
group by relatedpostid
order by count(*) desc

returning this question: What is a NullPointerException, and how do I fix it?

Do note that besides 'hard links' there is also 'related' questions (see the side bar). That isn't available in the data-dump, nor in SEDE. Instead you would have to leverage the Stack Exchange API, specially the /questions/{ids}/related endpoint.

From its description:

Returns questions that the site considers related to those identified in {ids}.

The algorithm for determining if questions are related is not documented, and subject to change at any time. Furthermore, these values are very heavily cached, and may not update immediately after a question has been editted. It is also not guaranteed that a question will be considered related to any number (even non-zero) of questions, and a consumer should be able to handle a variable number of returned questions.

If you need help with usage of the API, you can search or ask on Stack Apps or visit their chat.

1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .