Stack Apps is a question and answer site for apps, scripts, and development with the Stack Exchange API. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

For those who wish to maintain object graphs or to persist api domain objects authoritative documentation of the field(s) that define a unique key for the object would be of value.

Some are obvious and some not so obvious and this post should serve as a discussion leading to a definition, as can be arrived at.

Please contribute your observations and if you are one of the few with definitive knowledge, your input is expressly solicited.

Seems Obvious

  • answers - answer_id
  • badges - badge_id
  • comments - comment_id
  • questions - question_id
  • users - user_id
  • revisions - revision_guid (with revision_number as a sort field?)
  • tags - name (+ user_id when appropriate)

Not So Obvious

It seems the best we can do here is a 'soft' key dependent on the very slim chance of a collision on the date field.

  • user_timelines - ?? post_id + user_id + timeline_type + creation_date

  • post_timelines - ?? post_id + user_id + timeline_type + creation_date

  • rep_changes - ?? user_id + post_id + on_date

share|improve this question
I am having trouble seeing why you need a username to guarantee uniqueness in a tag... – Nathan Osman Aug 8 '10 at 0:17
@geo - because tags belong both to the site and to many users. So, if you are wanting to keep a list of tags on the site, user_id is not necessary. If you want to store tags for users, unless you want to create a table in your database for every user in stack exchange, you would probably want to use the user_id field as part of a composite key. clear? – Sky Sanders Aug 8 '10 at 1:04
@code: ´┐╗Ah, yes. I get it. – Nathan Osman Aug 8 '10 at 1:36
@geo - also, on a more practical level, /users/{id}/tags accepts multiple keys so the tags response will contain tags from multiple users, the user_id field is necessary for segregation. – Sky Sanders Aug 8 '10 at 4:24
@code: K. Completely unrelated, but has your schedule allowed you to work with Flash yet? You were saying in another post somewhere that you were eventually going to do that. I'm hoping you'll give ActionStack a go :) – Nathan Osman Aug 8 '10 at 6:25
@geo - no - the dive into implementing a fully relational IEnumerable model over the API for Soapi.cs has consumed my life lately. The next step is to replicate it in JavaScript first for Soapi.js and then I will consider the next move. – Sky Sanders Aug 8 '10 at 9:22

You must log in to answer this question.

Browse other questions tagged .