Jamie Thomson : linked datahttp://sqlblog.com/blogs/jamie_thomson/archive/tags/linked+data/default.aspxTags: linked dataenCommunityServer 2.1 SP2 (Build: 61129.1)Traversing the Facebook Graph using Data Explorerhttp://sqlblog.com/blogs/jamie_thomson/archive/2013/02/28/traversing-the-facebook-graph-using-data-explorer.aspxThu, 28 Feb 2013 22:16:44 GMT21093a07-8b3d-42db-8cbf-3350fcbf5496:47967jamiet6http://sqlblog.com/blogs/jamie_thomson/comments/47967.aspxhttp://sqlblog.com/blogs/jamie_thomson/commentrss.aspx?PostID=47967http://sqlblog.com/blogs/jamie_thomson/rsscomments.aspx?PostID=47967<p>As I <a href="http://sqlblog.com/blogs/jamie_thomson/archive/2013/02/27/data-explorer-hits-full-preview.aspx" target="_blank">mentioned yesterday</a> Microsoft Data Explorer Preview for Excel has hit the streets and one new feature is a built-in adapter for talking to the <a href="https://developers.facebook.com/docs/reference/api/" target="_blank">Facebook Graph API</a>:</p> <p><a href="http://sqlblog.com/blogs/jamie_thomson/image_21EAA092.png"><img title="image" style="border-top:0px;border-right:0px;background-image:none;border-bottom:0px;padding-top:0px;padding-left:0px;border-left:0px;display:inline;padding-right:0px;" border="0" alt="image" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_6EAE6728.png" width="408" height="351" /></a></p> <p>I’ve been taking it for a spin for today and was quite interested in its capabilities. Even without landing any data into Excel this is still a handy interactive Facebook graph explorer as I’ll demonstrate herein.</p> <hr /> <p>A good place to start is with a list of statuses. I have chosen “me” as the “Username or object id” (because frankly I didn’t know what else to put in there) and “statuses” as the dataset to return:</p> <p><a href="http://sqlblog.com/blogs/jamie_thomson/image_546DFE04.png"><img title="image" style="border-top:0px;border-right:0px;background-image:none;border-bottom:0px;padding-top:0px;padding-left:0px;border-left:0px;display:inline;padding-right:0px;" border="0" alt="image" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_2CC781DA.png" width="675" height="278" /></a></p> <p>After the standard merry authentication dance with Facebook Connect one’s history of Facebook statuses is returned which on its own might make interesting reading:</p> <p><a href="http://sqlblog.com/blogs/jamie_thomson/SNAGHTMLc6a91d4_24CFDF78.png"><img title="SNAGHTMLc6a91d4" style="border-top:0px;border-right:0px;background-image:none;border-bottom:0px;padding-top:0px;padding-left:0px;border-left:0px;display:inline;padding-right:0px;" border="0" alt="SNAGHTMLc6a91d4" src="http://sqlblog.com/blogs/jamie_thomson/SNAGHTMLc6a91d4_thumb_08DEAA80.png" width="999" height="422" /></a></p> <p>however let’s do something a bit more interesting. I remove the columns I’m not interested in:</p> <p><a href="http://sqlblog.com/blogs/jamie_thomson/SNAGHTMLc6db2eb_312DDCD4.png"><img title="SNAGHTMLc6db2eb" style="border-top:0px;border-right:0px;background-image:none;border-bottom:0px;padding-top:0px;padding-left:0px;border-left:0px;display:inline;padding-right:0px;" border="0" alt="SNAGHTMLc6db2eb" src="http://sqlblog.com/blogs/jamie_thomson/SNAGHTMLc6db2eb_thumb_2EA4AB16.png" width="993" height="305" /></a></p> <p>to leave just my statuses, likes and comments:</p> <p><a href="http://sqlblog.com/blogs/jamie_thomson/SNAGHTMLc6e96f2_482C3843.png"><img title="SNAGHTMLc6e96f2" style="border-top:0px;border-right:0px;background-image:none;border-bottom:0px;padding-top:0px;padding-left:0px;border-left:0px;display:inline;padding-right:0px;" border="0" alt="SNAGHTMLc6e96f2" src="http://sqlblog.com/blogs/jamie_thomson/SNAGHTMLc6e96f2_thumb_32624FE6.png" width="460" height="207" /></a></p> <p>Notice that the likes and comments fields contain either a hyperlinked “Table” or <em>null,</em> “Table” means we have a set of likes or comments respectively – in other words Data Explorer is letting me browse through the one-to-many relationships inherent in the data and I happen to think that is very cool indeed. For example, selecting a link shows me the likes or comments respectively for the status in question (“Want to hear my Elton John joke? Its a little bit funny…”):</p> <p><a href="http://sqlblog.com/blogs/jamie_thomson/SNAGHTMLcb762f9_460F397A.png"><img title="SNAGHTMLcb762f9" style="border-top:0px;border-right:0px;background-image:none;border-bottom:0px;padding-top:0px;padding-left:0px;border-left:0px;display:inline;padding-right:0px;" border="0" alt="SNAGHTMLcb762f9" src="http://sqlblog.com/blogs/jamie_thomson/SNAGHTMLcb762f9_thumb_23D72DF4.png" width="1031" height="308" /></a></p> <p>What would be more interesting would be if I could expand to show all comments against a status and also who made that comment. Turns out we can do just that, first click on this button called “Expand”:</p> <p><a href="http://sqlblog.com/blogs/jamie_thomson/image_6CAD9FFA.png"><img title="image" style="border-top:0px;border-right:0px;background-image:none;border-bottom:0px;padding-top:0px;padding-left:0px;border-left:0px;display:inline;padding-right:0px;" border="0" alt="image" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_450723D0.png" width="345" height="156" /></a></p> <p>which displays a list of columns that I want to show in the resultset; I choose “from” &amp; “message”:</p> <p><a href="http://sqlblog.com/blogs/jamie_thomson/image_721C109E.png"><img title="image" style="border-top:0px;border-right:0px;background-image:none;border-bottom:0px;padding-top:0px;padding-left:0px;border-left:0px;display:inline;padding-right:0px;" border="0" alt="image" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_4A759474.png" width="371" height="336" /></a></p> <p>and now I can see all the comments against the relevant status. For all you out there whose heads are in SQL-land, I’ve effectively LEFT JOINed statuses to comments:</p> <p><a href="http://sqlblog.com/blogs/jamie_thomson/image_706B44CA.png"><img title="image" style="border-top:0px;border-right:0px;background-image:none;border-bottom:0px;padding-top:0px;padding-left:0px;border-left:0px;display:inline;padding-right:0px;" border="0" alt="image" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_78BEF454.png" width="858" height="171" /></a></p> <p>Last step, the comments.from field tells me who left the comment:</p> <p><a href="http://sqlblog.com/blogs/jamie_thomson/image_7B84A947.png"><img title="image" style="border-top:0px;border-right:0px;background-image:none;border-bottom:0px;padding-top:0px;padding-left:0px;border-left:0px;display:inline;padding-right:0px;" border="0" alt="image" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_28999616.png" width="535" height="150" /></a></p> <p>So let’s do a similar trick to show the name of the commenter in my resultset and voila:</p> <p><a href="http://sqlblog.com/blogs/jamie_thomson/SNAGHTMLc870b67_2E7439AF.png"><img title="SNAGHTMLc870b67" style="border-top:0px;border-right:0px;background-image:none;border-bottom:0px;padding-top:0px;padding-left:0px;border-left:0px;display:inline;padding-right:0px;" border="0" alt="SNAGHTMLc870b67" src="http://sqlblog.com/blogs/jamie_thomson/SNAGHTMLc870b67_thumb_3376775E.png" width="961" height="227" /></a></p> <p>we have a list of my statuses along with all the comments and the name of the person that made the comment! We have effectively joined three linked datasets (statuses, comments, person), all inside Excel, and all without writing a scrap of code. Personally I think that’s very cool.</p> <p> <hr />Now let’s go back to just our list of statuses:</p> <p><a href="http://sqlblog.com/blogs/jamie_thomson/SNAGHTMLc6e96f2_11AA9ECD.png"><img title="SNAGHTMLc6e96f2" style="border-top:0px;border-right:0px;background-image:none;border-bottom:0px;padding-top:0px;padding-left:0px;margin:0px;border-left:0px;display:inline;padding-right:0px;" border="0" alt="SNAGHTMLc6e96f2" src="http://sqlblog.com/blogs/jamie_thomson/SNAGHTMLc6e96f2_thumb_29CE0928.png" width="460" height="207" /></a></p> <p>Let’s say we now want to count the number of likes and comments on each status and sort the data accordingly. I use the expand feature as before except this time I choose to aggregate rather than expand:</p> <p><a href="http://sqlblog.com/blogs/jamie_thomson/image_28897049.png"><img title="image" style="border-top:0px;border-right:0px;background-image:none;border-bottom:0px;padding-top:0px;padding-left:0px;border-left:0px;display:inline;padding-right:0px;" border="0" alt="image" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_2ED046D7.png" width="377" height="240" /></a></p> <p>That gives me the number of likes and comments per status which I can then sort however I choose:</p> <p><a href="http://sqlblog.com/blogs/jamie_thomson/image_6DC1C772.png"><img title="image" style="border-top:0px;border-right:0px;background-image:none;border-bottom:0px;padding-top:0px;padding-left:0px;border-left:0px;display:inline;padding-right:0px;" border="0" alt="image" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_3129C8D5.png" width="402" height="145" /></a></p> <p>and with a couple of quick aesthetic column renames I have all my statuses with number of likes and comments in descending order of popularity (as measured by the count of likes):</p> <p><a href="http://sqlblog.com/blogs/jamie_thomson/SNAGHTMLca00a5e_305162EB.png"><img title="SNAGHTMLca00a5e" style="border-top:0px;border-right:0px;background-image:none;border-bottom:0px;padding-top:0px;padding-left:0px;border-left:0px;display:inline;padding-right:0px;" border="0" alt="SNAGHTMLca00a5e" src="http://sqlblog.com/blogs/jamie_thomson/SNAGHTMLca00a5e_thumb_1D30363F.png" width="582" height="339" /></a></p> <p>I can then pull that resultset into Excel and chart it to see if there is any correlation between number of likes and number of comments:</p> <p><a href="http://sqlblog.com/blogs/jamie_thomson/image_3B9A7728.png"><img title="image" style="border-top:0px;border-right:0px;background-image:none;border-bottom:0px;padding-top:0px;padding-left:0px;border-left:0px;display:inline;padding-right:0px;" border="0" alt="image" src="http://sqlblog.com/blogs/jamie_thomson/image_thumb_28794A7C.png" width="574" height="336" /></a></p> <p>Imagine aggregating over something more interesting than Facebook statuses and I think you can realise the potential here.</p> <p> <hr />Hopefully this has served as a useful introduction to Data Explorer’s ability to query Facebook data. What interests me most about this is not the ability to query Facebook per se, its the ability to query and traverse over graph data using a tool that isn’t aimed at developers. Now imagine being being able to do the same with the growing corpus of <a href="http://linkeddata.org/" target="_blank">linked data</a> graphs that exist on the web in RDF format and you start to realise the potential here; I truly hope that the ability to query RDF data is high on the agenda of the Data Explorer team*.</p> <p>If you want to have a go with Data Explorer yourself then go ahead and download it from <a title="http://www.microsoft.com/en-us/download/details.aspx?id=36803" href="http://www.microsoft.com/en-us/download/details.aspx?id=36803">http://www.microsoft.com/en-us/download/details.aspx?id=36803</a>; its free, although you will need Excel 2010 or Excel 2013 installed.</p> <p><a href="http://twitter.com/jamiet" target="_blank">@Jamiet</a>&#160;</p> <p>* For what its worth I’ve had a watching brief on RDF, the Semantic Web and Linked Data since way back in <a href="http://consultingblogs.emc.com/jamiethomson/archive/2004/11/13/The-semantic-web-and-FOAF.aspx" target="_blank">November 2004</a> and I’ve been waiting since then for it to hit the big time. I don’t think that’s going to happen any time soon but having support from tools like Data Explorer would be a step in the right direction.</p><img src="http://sqlblog.com/aggbug.aspx?PostID=47967" width="1" height="1">linked dataData ExplorerGraph APIExplaining the difference between OData & RDF by way of analogyhttp://sqlblog.com/blogs/jamie_thomson/archive/2010/04/14/explaining-the-difference-between-odata-rdf-using-an-analogy.aspxWed, 14 Apr 2010 10:18:00 GMT21093a07-8b3d-42db-8cbf-3350fcbf5496:24273jamiet5http://sqlblog.com/blogs/jamie_thomson/comments/24273.aspxhttp://sqlblog.com/blogs/jamie_thomson/commentrss.aspx?PostID=24273http://sqlblog.com/blogs/jamie_thomson/rsscomments.aspx?PostID=24273<p>A couple of months back I wrote a blog post entitled <a href="http://sqlblog.com/blogs/jamie_thomson/archive/2010/02/03/microsoft-odata-and-rdf.aspx" target="_blank">Microsoft, OData and RDF</a> where I gave a high level view of the <a href="http://www.odata.org" target="_blank">OData protocol</a> and how it compares to <a href="http://www.w3.org/RDF/" target="_blank">RDF</a>. I talked about linked data, triples and such like which may have been somewhat useful however jargon-heavy. Earlier today <a href="http://sw-app.org/mic.xhtml#i" target="_blank">Dr Michael Hausenblas</a> (<a href="http://webofdata.wordpress.com/" target="_blank">blog</a> | <a href="http://twitter.com/mhausenblas">twitter</a>) offered an analogy which I think is probably more useful and with Michael's permission I'm re-posting it here:</p><blockquote><p><i>Imagine a Web (a Web of Documents, if you wish), which is not based
on HTML and hyperlinks, but on MS Word documents. The documents are all
available on the Internet, so you can download them and consume the
content. But after you’re done with a certain document that talks about
a book, how do you learn more about it? For example, reviews about the
book or where you can purchase it? Maybe the original document mentions
that there is some more related information on another server. So you’d
need to go there and look for the related bit of information yourself.
You see? That’s what the Web is great at – you just click on a
hyperlink and it takes you to the document (or section) you’re
interested in. All the legwork is taken care of for you through HTML,
URIs and HTTP.</i></p><p><i>Hm, right, but how is this related to OData?</i></p><p><i>
Well, OData feels a bit like the above mentioned scenario, just
concerning data. Of course you – well actually rather a software
program I guess – can consume it (a single source), but that’s it.</i></p><p><i>from <a href="http://webofdata.wordpress.com/2010/04/14/oh-it-is-data-on-the-web/" rel="bookmark" title="Permanent Link: Oh – it is data on the&nbsp;Web">Oh – it is data on the&nbsp;Web by Michael Hausenblas<br></a></i></p></blockquote>
<p>I believe that OData has loads of use cases but its important to understand its limitations as well and I think Michael has done a good job of explaining those limitations.</p><p><a href="http://twitter.com/jamiet" target="_blank">@Jamiet</a> <br></p><p>&nbsp;</p><img src="http://sqlblog.com/aggbug.aspx?PostID=24273" width="1" height="1">ODatalinked dataRDFsemantic webMicrosoft, OData and RDFhttp://sqlblog.com/blogs/jamie_thomson/archive/2010/02/03/microsoft-odata-and-rdf.aspxWed, 03 Feb 2010 16:53:00 GMT21093a07-8b3d-42db-8cbf-3350fcbf5496:21784jamiet5http://sqlblog.com/blogs/jamie_thomson/comments/21784.aspxhttp://sqlblog.com/blogs/jamie_thomson/commentrss.aspx?PostID=21784http://sqlblog.com/blogs/jamie_thomson/rsscomments.aspx?PostID=21784<p class="MsoNormal">Earlier today Chris Webb posted a blog entry entitled <a href="http://cwebbbi.spaces.live.com/Blog/cns%217B84B0F2C239489A%216224.entry">OData and Microsoft BI</a> where he remarked upon the increasing importance of Microsoft’s burgeoning <a href="http://www.odata.org/" target="_blank">OData protocol </a>for accessing data over HTTP. Chris also linked to Douglas Purdy’s blog post <a href="http://www.douglaspurdy.com/2010/02/01/odata-the-movie/">OData: The Movie</a> which listed the following Microsoft and non-Microsoft technologies that support (or soon will support) OData either as a data producer or a data consumer:</p> <ul> <li>Excel</li> <li>.Net client</li> <li>AJAX Client</li> <li>PHP client</li> <li>Java client</li> <li>Visual Studio</li> <li>Sharepoint</li> <li>SQL Server (via Reporting Services)</li> <li>Codename &quot;Dallas&quot;</li> <li>Websphere</li> </ul> <p class="MsoNormal">To that list I would add Windows Azure which exposes data from its storage engine using OData and also the forthcoming Live Framework technology that is expected to surface user-centric data from Microsoft’s various Live Services properties (e.g. SkyDrive, Messenger, Calendar).<o:p></o:p></p> <p class="MsoNormal"><o:p>&#160;</o:p></p> <p class="MsoNormal">Chris suggested that a pervasive format for data on the web would be a big step forward because any consumer that understood that format could talk to any producer that chose to expose it; win-win-win indeed. Unfortunately life is of course never that simple and as is so often the case there are many competing technologies in this space including (but, I suspect, not limited to) Microsoft’s OData, Google’s <a href="http://code.google.com/apis/gdata/index.html" target="_blank">GData </a>and the World Wide Web consortium’s <a href="http://www.w3.org/RDF/" target="_blank">Resource Description Framework (RDF)</a>.</p> <p class="MsoNormal">&#160;</p> <p class="MsoNormal">This is nothing new of course; we can draw parallels with Atom and RSS which were recent competing technologies used to expose blog syndication feeds. Interestingly both of these technologies generally sit side-by-side quite happily these days (read: <a href="http://www.25hoursaday.com/weblog/2009/01/06/WillTheOnlineIdentityWarTurnOutLikeTheXMLSyndicationWar.aspx" target="_blank">Will the Online Identity War turn out like the XML Syndication War?</a>) and it will be interesting to see whether the same will happen in the OData/GData/RDF space; will organisations opt to expose multiple service heads for their various databases? I await the answer to that one with interest.<o:p></o:p></p> <p class="MsoNormal"><o:p>&#160;</o:p></p> <p class="MsoNormal">RDF is of particular interest chiefly because one of its main proponents is Sir Tim Berners-Lee, the inventor of the world wide web. RDF has been knocking around for about 10 years now and Berners-Lee sees it as the technology that will underpin the growth of the fabled Semantic Web; indeed he has been heavily involved with the recently announced service <a href="http://data.gov.uk/">http://data.gov.uk</a> which exposes data held by the UK government and it is no surprise that that service exposes its data using RDF.<o:p></o:p></p> <p class="MsoNormal"><o:p>&#160;</o:p></p> <p class="MsoNormal">I don’t know too much about GData but I do have a working knowledge of both OData &amp; RDF so perhaps an overview and comparison of the two might be useful. To this observer it appears as though OData is closely tied to the tables-rows-and-columns paradigm that anybody familiar with traditional relational databases will understand. An OData service exposes multiple entities (roughly analogous to tables) and the relationships between them.<o:p></o:p></p> <p class="MsoNormal"> <br />RDF however is built around the concept of triples which I assert is more analogous to a conceptual Entity-Attribute-Value model (that assertion is something I hope to explore in a future blog post). The key difference between RDF and OData though is that an RDF document can contain links to RDF documents that are hosted on <i>other</i> services and attributes of entities are defined in terms of those other services. Put more simply, RDF data is one massively distributed, non-centralised, interlinked web of data and if that sounds an awful lot like the mass of HTML documents which form the world wide web then you shouldn’t be too surprised given that Berners-Lee is so heavily involved. The notion of linking data together in this way has also given rise to the very descriptive moniker <a href="http://linkeddata.org/" target="_blank">linked data</a> which you may well hear mentioned in the same sentence as “semantic web” from time to time.<o:p></o:p></p> <p class="MsoNormal"><o:p>&#160;</o:p></p> <p class="MsoNormal">This has been a rather rambling blog post and really its just me dumping some thoughts out onto your computer screen as you can tell from the rather unimaginative title. Nonetheless there is some interesting stuff going on here that I hope to explore in the future so if you're interested please return some time. If you have any thoughts I'd love to read them in the comments section below.<o:p></o:p></p> <p class="MsoNormal"><o:p>&#160;</o:p></p> <p class="MsoNormal"><a href="http://twitter.com/jamiet" target="_blank">@Jamiet</a><o:p></o:p></p><img src="http://sqlblog.com/aggbug.aspx?PostID=21784" width="1" height="1">ODatalinked dataRDFsemantic web