Help:Semantic MediaWiki

Semantic MediaWiki is, without fear of hyperbole, one of the coolest things ever to be added to the basic MediaWiki software.

It transforms the wiki into a truly relational database, and gives you the power to actually use the data that the wiki has been collecting to answer question.

It allows you to make the wiki tell you the answers to question like:
 * "Which Tenth Doctor story was dedicated to Verity Lambert?"
 * "Which BBC Wales story thanked Marc Platt?"
 * "Which BBC Wales Dalek stories were not produced by Phil Collinson?

Moreover all of SMW's output is dynamic. Thus, if you asked the system to tell you which stories were directed by Euros Lyn, it would automatically update Euros Lyn's page if he ever directed more episodes.

In short, SMW gives us the power to improve the accuracy of our pages in perpetuity — without doing more work.

A basic example
Let's imagine that you wanted to know the names of the stories on which Stephan Pehrsson was the director of photography. In the past, your only real hope was going to Stephan's page and hoping that another editor had maintained the list of Stephan's contributions. Now, however you can type this simple command: To break this down, you're ing the database, within the category, Doctor Who (2005) television stories, in which did the property called "DOP" have a value of "Stephan Pehrsson"?

The answer?

Now, that'll get you your answer, but it's not very pretty. So let's quickly throw it into a more tabular form. The code  creates a new column into which the property DOP is placed.

And that's a lot more readable. Not pretty, of course, but readable. We can then dress it up in all sorts of ways. But that involves knowing something about coding tables, which is a little off-topic for us now.

One thing that's easy to spot is that we've created a redlink. We haven't created the property DOP yet, so therefore we get a redlink. For the moment, we can sort of "paper over the crack" by simply unlinking the title. Let's also add in a header for the first column.

Making the  plain and adding a   of "Episode name" results in this:

Truth is, though, you probably wouldn't want a table for something like this, because you really only have one variable — the name of the episode. If you wanted to put this dynamic list on the page Stephan Pehrsson, a simple list would do. If we simply define, we'll get a bulleted list.

If we simply define, we'll get a bulleted list. Cool, huh? But there's still one unsatisfactory element. Our dab terms are showing. So how do we get rid of them so that we're just looking at pure titles? Easy. We force the output to run through, our dab term stripper. Note here that we also have to set  simply because  outputs a linked version of a raw name. So if you give it  it will give you. Stripping the links before you pass the data to is necessary, or you'd end up with.

The final result then is precisely what we want: a list that looks like any other list on any other page about a crew member. It's simple, bulleted, respects both and.

Best of all, if he comes back and does a new episode, we won't have to update the page. It'll be done for us. Automatically. Simple, perpetual accuracy.

How it works
Before we go on to more advanced (read: fun) queries, let's stop for a moment to consider how this all works. How is that by adding  to an   command that we get this list of titles? Is it voodoo magic? Kinda-sorta.

Basically, in order to get useful data back from the page, you have to change the way you link things. Imagine we add the following to a page: DOP::Stephan Persson Thi will mark that page as having the property of DOP equalling Stephan Pehrsson. So any time I look for that property value, that page will pop up.

Note, too, that there is no cosmetic difference between these two things: Stephan Pehrsson, the traditional link and DOP::Stephan Persson, the SMW link Both of these look the same way to anyone reading the page, even down to the mouseover. Stephan Pehrsson (normal) DOP::Stephan Pehrsson (SMW). See?

This doesn't mean that we have to go around to every page and start changing these links. To be fair, there are some times when manual editing might be required. But most of this can be handled easily by modifying a single template.

In this case, — which appears on every BBC Wales-made programme — is hugely helpful. We can simply change the to output something like this: producer::{{{producer}}, director::, DOP:: This globally converts all those links in the crew sections of BBC Wales pages from a sea of hundreds of tiny links into something you can really use.