The last “What is MQL?” blog entry mentioned that MQL was a query language on top of a web service (which really should be called the “Freebase MQL web service” to distinguish it from the query language itself.) Let’s look at the web service aspect a little more closely.
The first web services were HTML forms. You passed parameters to them over HTTP, and received an HTML response. One early example is the Yahoo finance quote service. You fetch the URL http://finance.yahoo.com/q?s=GOOG and receive an HTML page containing the most recent price for Google. Change the stock ticker and you get a different quote.
Such services are difficult for computers to use effectively (”screen scraping” is the usual solution). The need for machine parseable responses lead to a number of data formats (XML, JSON) and service standards (SOAP, REST) being adopted. A good example of this evolution is the Yahoo Search web service Greatly simplified, you provide a query string, and get a set of results back in XML or JSON.
One thing that the finance HTML service, and the search XML service have in common is that they are very restricted in their domain. You can’t ask the finance service about “The Joshua Tree” and while you can ask the search service about “YHOO”, you can’t ask it specifically for a stock quote. (It may give you one anyway, depending on how the implementation is feeling that day). You can’t ask detailed questions either; the service can only provide web pages related to “The Joshua Tree”, it can’t give you a list of the tracks. (Surely you wanted the national park?)
The Freebase MQL service is the next generation of these services. It accepts questions about any topic and returns answers. While you can’t ask it for a stock quote (yet!) MQL allows you to phrase questions such as: “what is the population of New York City?” and “On which U2 album was ‘One Tree Hill’ first released?”. You can combine questions in very powerful (or very strange) ways: “Is there a state that is governed by a winner of Mr Universe, and if so what movies has he appeared in?”
How do you ask these questions in MQL? Say tuned.

March 21st, 2007 at 10:04 pm
How does the Freebase MQL service relate to the API (in which you can, at this point, use the MQL query language to query the Freebase database directly). Will I be able to use the Freebase MQL service in my web application? For example, could I query the API with a question like “On which U2 album was ‘One Tree Hill’ first released?” and it return the results to my web application? These kinds of queries would obviously not be computer generated but from the users of my web application.
March 22nd, 2007 at 7:43 am
The MQL read/write service IS the programmatic API to Freebase. To find out “On which U2 album was ‘One Tree Hill’ first released?”, try invoking the MQL read service with the following url with your browser:
http://www.freebase.com/api/service/mqlread?queries={”myquery”:{”query”:{”name”:”U2″,”type”:”/music/artist”,”album”:[{"name":null, "track":[{"name":"One Tree Hill"}]}]}}}
You will get an application/json response saying that in fact “One Tree Hill” only appeard in one album named “The Joshua Tree”.
March 22nd, 2007 at 7:49 am
continued….
You will NOT be able to invoke an XMLHttpRequest to freebase.com if your page was served up from jeremyolson.com because of javascript’s same-origin policy. However there are numerous methods in getting around this restriction in which Mr. David Flanagan has wonderfully addressed in our documentation, “Developing Metaweb-Enabled Web Applications”. See http://www.freebase.com/view/documentation/ch04.html#id2619120.
March 22nd, 2007 at 7:50 am
continued…
Also, we have built a javascript templating engine to work with Freebase and just about any other web services and get around javascript’s same-origin policy. See http://mjtemplate.org/.
Once you get your hands dirty, you should consider joining our developers mailing list at http://lists.freebase.com/mailman/listinfo/developers for any questions regarding developing applications using the Freebase API.
March 22nd, 2007 at 11:27 am
Thanks for the responses, I am impressed by the openness and quick responses of the Metaweb team.
I understand how to programmaticly get the answer to “On which U2 album was ‘one Tree Hill’ first released?” via the API. I guess what I was really wondering was if Metaweb was going to have some standard way to translate human readable queries like “On which U2 album was ‘one Tree Hill’ first released?” to programmatic queries like {”myquery”:{”query”:{”name”:”U2″,”type”:”/music/artist”,”album”:[{”name”:null, “track”:[{”name”:”One Tree Hill”}]}]}}}. Or is it up to the developer using the API to do that?
March 26th, 2007 at 8:21 pm
I think the post was a little misleading. No, Metaweb doesn’t have plans to allow for plain english queries. The JSON formatted MQL query is *it*. One really nice thing about MQL is that it’s quite a bit closer to expressing something in human language than, say, SQL which can get pretty gnarly when you’re joining a bunch of tables in your query.
March 31st, 2007 at 12:11 am
Brendan, thanks for the clarification. I should have read between the lines a little bit better. I wonder if someone will come up with a natural language processing system that translates natural language into MQL.
April 13th, 2007 at 7:29 pm
Jeremy, you might want to take a look at William Pietri’s Query Builder (it’s one of the featured apps on Freebase). It’s still in early stages, and it’s definitely not NLP, but it greatly simplifies the process of generating a MQL query and I think is a step in the direction of making it easy for end users to ask questions of the system.