Jump to content

Topic on Talk:Wikibase

Which table does Wikibase query for getting the current statements on a Wikidata item?

3
Rdrg109 (talkcontribs)

I'm trying to understand how the internals of Wikibase work. Specifically, I want to know how Wikibase is able to show the current statements of a Wikidata item in the web browser of end users.

I decided to inspect the source code (link to the Wikibase repository in gerrit.wikimedia.org), but as I am not very familiar with PHP and the internals of Wikibase, I believed that I didn't find the relevant part that accomplishes what I am looking for.

I presume that Wikibase keeps track of the current statements in a table and whenever a new revision is added to the Mediawiki's the revision table, the table that stores Wikibase statements is modified accordingly. Then, when someone asks for the current statements of a Wikidata item, Wikibase returns the rows at the table that stores current Wikibase statements.

My question is: What is the workflow that is followed for Wikibase to return the current statements of a Wikidata item to users so that they see it in their web browsers?

Rdrg109 (talkcontribs)

I asked a similar question in Libera Chat's room #wikimedia-cloud and some user replied:

19:35 <rdrg109> I still have a question though: How does Wikibase is able to know the existing statements on a given Wikibase item? I presume Wikibase stores that information somewhere in a table in a database. Isn't that information stored in any of the tables named wb_* or wbt_*?
19:44 <rdrg109> ^ For the record, I opened a topic for this question in Talk:Wikibase: https://www.mediawiki.org/wiki/Topic:Y3u994hnsgkbgbz0
19:46 <+wm-bb> <<hidden username>> it’s stored in a table that’s not available on the replicas
19:46 <+wm-bb> <<hidden username>> see https://wikitech.wikimedia.org/wiki/Help:Toolforge/Database#Unavailable_tables, the `text` table is the one with all the page contents
Jdforrester (WMF) (talkcontribs)

The "workflow" is that it fetches the JSON of the Entity (not from the text table, but via external storage) and decodes it. You can call the wbgetclaims API to get the statements ('claims'), like this one for Q42/Douglas Adams, or if you really want you could fetch the raw entity JSON over the Wikibase API and decode it yourself, I suppose. Hope this helps!

Reply to "Which table does Wikibase query for getting the current statements on a Wikidata item?"