afuna: Cat under a blanket. Text: "Cats are just little people with Fur and Fangs" (Default)
afuna ([personal profile] afuna) wrote in [site community profile] dw_dev_training2009-10-25 12:02 pm
Entry tags:

jtalkid vs dtalkid vs jitemid vs ditemid

One of the minor things that has always confused me, and I always forget to ask about, is the difference between the very similarly named "ditemid" and "jitemid" (ditto for "dtalkid" and "jtalkid"). Whenever I need to use these, I have to look for code similar to what I am working on, or look up the function definitions in cgi-bin/LJ/Comment.pm and cgi-bin/LJ/Entry.pm.

I was looking through code and stumbled across a comment that cleared things right up:
# - ditemid -- display itemid (with anum)


So! Noting here what I have gleaned:

itemid = entry
talkid = comment

j* = journal
== the per-journal internal id for the entry/comment. This is the value stored in the database. The "j" is to distinguish it from old-style itemids. In a much earlier iteration, LJ entry ids were shared among all users -- DW doesn't have any old-style itemids, and I suspect much of the earlier support is gone.

d* = display
== the display id. This is the value that you see in URLs, etc. It is combined with a random number, to make sure that bots cannot just iterate over all entries by adding +1 to the previous entry id.

If you want to get into specifics, ditemid = jitemid*256+anum.
pne: A picture of a plush toy, halfway between a duck and a platypus, with a green body and a yellow bill and feet. (Default)

[personal profile] pne 2009-10-25 05:34 am (UTC)(link)
This is the value stored in the database.

The anum is also stored in the database, right?

So I expect the primary key for a journal entry will be something along the lines of (userid, jitemid, anum).

Otherwise there'd be no way to consistently reproduce the same ditemid....
av8rmike: 10 HOME; 20 SWEET; 30 GOTO 10 (home sweet goto)

[personal profile] av8rmike 2009-10-25 03:58 pm (UTC)(link)
the difference between the very similarly named "ditemid" and "jtalkid"

"ditemid" and "jitemid", I'm assuming?
Also, what is the purpose of "anum"?
Edited 2009-10-25 16:00 (UTC)
janinedog: (Default)

[personal profile] janinedog 2009-10-25 08:25 pm (UTC)(link)
You know, I knew all of this except that the "d" stood for "display". That makes complete sense, and seems obvious now, haha. :)
aphenine: Teresa and Claire (Default)

[personal profile] aphenine 2009-10-26 02:20 am (UTC)(link)
Just to add confusion, sometimes there's a j* type of id (I think jid, but this is off the top of my head, so I could be wrong) which is actually the userid. Seemingly, it implies that someone once thought that the users might have many journals and wanted to avoid confusion. In the meantime, they hacked the system by making the jid equal to the userid. *shrug*
mark: A photo of Mark kneeling on top of the Taal Volcano in the Philippines. It was a long hike. (Default)

[staff profile] mark 2009-10-26 04:16 am (UTC)(link)
'user' and 'journal' are interchangeable ways to refer to an account (user, community, feed, etc), the latter is preferred.

'userid' == 'uid' == 'journalid' == 'jid'
yvi: Kaylee half-smiling, looking very pretty (Default)

[personal profile] yvi 2009-10-26 01:36 pm (UTC)(link)
Also, there's 'nodeid', at least in the database.