afuna: Cat under a blanket. Text: "Cats are just little people with Fur and Fangs" (afuna, cats)afuna ([personal profile] afuna) wrote in [site community profile] dw_dev_training,
@ 2009-10-25 12:02 pm UTC
Entry tags:naming conventions
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.


(9 comments) - (Post a new comment)
(Flat) (Top-level comments only)

pne: A picture of a plush toy, halfway between a duck and a platypus, with a green body and a yellow bill and feet. (Martin)


[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....

(Reply to this)  (Thread


afuna: Cat under a blanket. Text: "Cats are just little people with Fur and Fangs" (afuna, cats)


[personal profile] afuna
2009-10-25 06:14 am UTC (link)
Yup! More accurately, jitemid is the internal id that's stored in the database, as opposed to ditemd, which is derived from it.

anum is stored in the db as well, but you generally don't have to interact with it directly, so I chose to only touch on it briefly for the post.

(Reply to this)  (Thread from start)  (Parent


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"?

Last edited 2009-10-25 04:00 pm UTC

(Reply to this)  (Thread


afuna: Cat under a blanket. Text: "Cats are just little people with Fur and Fangs" (afuna, cats)


[personal profile] afuna
2009-10-25 04:15 pm UTC (link)
Oops, yes, thanks. anum is a random number, combined with the jitemid, to prevent the entry urls from being easily guessable. That's so that bots=spammers/etc, can't just get a list of all entries by a user just by going 1... 2.... 4....

(Reply to this)  (Thread from start)  (Parent


janinedog: (support)


[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. :)

(Reply to this


aphenine: Teresa and Claire (angels, anime, claymore)


[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*

(Reply to this)  (Thread


afuna: Cat under a blanket. Text: "Cats are just little people with Fur and Fangs" (afuna, cats)


[personal profile] afuna
2009-10-26 03:44 am UTC (link)
Oh, hmm. I wonder if that would make it easier to do the parent/child feature. Obviously won't work in most places, but maybe it's a starting point?

*eyes the code thoughtfully*

(Reply to this)  (Thread from start)  (Parent


mark: Photo of Mark's face, taken in standard office fluorescent. (me)


[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'

(Reply to this)  (Thread from start)  (Parent


yvi: Kaylee half-smiling, looking very pretty (Firefly - Kaylee)


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

(Reply to this



(9 comments) - (Post a new comment)
(Flat) (Top-level comments only)