6

I have looked into Database schema documentation for the public data dump and SEDE.

But there is no explanation about the postlinks table. Can anyone explain me the meaning of each column of that table?

6
  • There are Id, CreationDate, PostId, RelatedPostID and LinkTypeId fields Mar 26, 2014 at 11:30
  • 1
    Look at the Linked section to the right of your question. I believe your answer lies there. Mar 26, 2014 at 11:31
  • If a post has duplicates (or has linked posts), this table holds that data. Mar 26, 2014 at 11:32
  • @FrédéricHamidi: The FAQ doesn't actually document that table.. Mar 26, 2014 at 11:32
  • @Martijn, I was actually referring to the section itself, not to the content of the FAQ link there :) Mar 26, 2014 at 11:38
  • @FrédéricHamidi: ah, yes, but that doesn't actually explain the contents of the schema, not as such. :-) Mar 26, 2014 at 11:40

1 Answer 1

7

The table lists all 'linked' and 'duplicate' links related to a post.

You can use it to query what posts are linked as a duplicate for example.

Schema explanation:

PostLinks

  • Id - primary key
  • CreationDate - when the link was created
  • PostId - id of source post
  • RelatedPostId - id of target post
  • LinkTypeId - type of link (currently either 1, linked, or 3, dupe)

Linked post are any internal link referenced in the question or in answers or comments below a question. Duplicate links are created when the source post has been closed as a duplicate.

Quoting from the schema, the LinkTypeId values are:

  • 1 = Linked (PostId contains a link to RelatedPostId)
  • 3 = Duplicate (PostId is a duplicate of RelatedPostId)

The PostId column only ever refers to questions; the vast majority of RelatedPostId targets are questions too, with about 1000 exceptions (which are answers); it is unclear when the site will insert an answer link instead of a question, but all these exceptions are 'linked' links, not duplicates.

5
  • For a question does this include links that are in answers? Mar 26, 2014 at 13:25
  • @IanRingrose: scratch that, I was wrong. Yes, links in answers are linked from the question id. Mar 26, 2014 at 13:32
  • @IanRingrose: I posted a 'see this other answer of mine' reference in a post that I used to test this with; neither the source answer ID nor the target answer are listed in the PostLinks table, but the questions are. So answerA posted on questionA refers to answerB on questionB, and a link was addded from questionA to questionB. Mar 26, 2014 at 13:38
  • There is no PostLinkTypes table on SEDE.
    – ashleedawg
    Nov 29, 2019 at 13:10
  • 2
    @ashleedawg: that table appears to have been removed. It was there when this answer was written. Nov 29, 2019 at 21:56

You must log in to answer this question.

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