• Save
Jarrar: RDF - Graph Data Model
Upcoming SlideShare
Loading in...5

Jarrar: RDF - Graph Data Model



Lecture Notes by Mustafa Jarrar at Birzeit University, Palestine. ...

Lecture Notes by Mustafa Jarrar at Birzeit University, Palestine.
See the course webpage at: http://jarrar-courses.blogspot.com/2014/01/web-data-management.html
and http://www.jarrar.info

you may also watch this lecture at: http://www.youtube.com/watch?v=mrbvjAdhSHM

The lecture covers:
- Relational vs. Tree vs. Graph data models
- What is XML, and why it is not enough
- What is RDF
- Subject, Predicate & Object
- Main RDF Properties and Attributes.
- RDF Validator
- Mapping XML into RDF
- Mapping between R.DB and RDF
- Practice Session



Total Views
Views on SlideShare
Embed Views



13 Embeds 489

http://jarrar-courses.blogspot.com 412
http://jarrar-courses.blogspot.co.uk 30
http://jarrar-courses.blogspot.co.il 15
http://jarrar-courses.blogspot.ca 11
http://jarrar-courses.blogspot.it 6
http://jarrar-courses.blogspot.pt 4
http://www.blogger.com 2
http://jarrar-courses.blogspot.in 2
http://jarrar-courses.blogspot.de 2
http://jarrar-courses.blogspot.com.es 2
http://jarrar-courses.blogspot.dk 1
http://jarrar-courses.blogspot.nl 1
http://jarrar-courses.blogspot.fr 1


Upload Details

Uploaded via as Adobe PDF

Usage Rights

CC Attribution-NonCommercial-NoDerivs LicenseCC Attribution-NonCommercial-NoDerivs LicenseCC Attribution-NonCommercial-NoDerivs License

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
Post Comment
Edit your comment

    Jarrar: RDF - Graph Data Model Jarrar: RDF - Graph Data Model Presentation Transcript

    • Mustafa Jarrar Lecture Notes, Web Data Management (MCOM7348) University of Birzeit, Palestine 1st Semester, 2013 RDF Graph Data Model Dr. Mustafa Jarrar University of Birzeit mjarrar@birzeit.edu www.jarrar.info Jarrar © 2013 1
    • Watch this lecture and download the slides from http://jarrar-courses.blogspot.com/2013/11/web-data-management.html Jarrar © 2013 2
    • Outline •  Relational vs. Tree vs. Graph data models •  Why XML is not enough •  RDF •  Mapping between R.DB and RDF Keyword: Graph Data Models, Try Data Models, Relational Data Models, RDF, Directed Labeled Graph, XML Semantics, Mapping XML to RDF, Mapping RDB to RDF Jarrar © 2013 3
    • Reading RDF Primer (http://www.w3.org/TR/rdf-syntax-grammar/ ) Please have a look only to: Chapter 2 Making Statements About Resources Chapter 3 An XML Syntax for RDF: RDF/XML Chapter 3 Defining RDF Vocabularies: RDF Schema Jarrar © 2013 4
    • Relational vs Tree vs Graph Data model Relational Data models •  Data is represented in tuples, groups into relations •  Relational databases Tree data models •  Parent / child relationships •  Directed Acyclic Graphs •  XML is a tree data model Graph Data Models •  A nodes is a data element and links are relations between these elements. •  Directed Labeled Graphs •  RDF is a graph data model è  Tree are special case of graphs Jarrar © 2013 5
    • What is XML •  Provides a common syntax for marking up documents. •  Easy to exchange between computers (web) •  Data model: an XML Document is an ordered labeled tree (/collection of trees). •  W3C standard since 1997. bookinfo <bookInfo> <title>Orientalism</title> <author> <persName> <title>Prof.</title> <foreName>Edward</foreName> <surName>Said</surName> <roleName>University Professor <placeName>Columbia University </placeName> </roleName> </persName> </author> </bookInfo> title author persName title foreName surName roleName placeName Jarrar © 2013 6
    • XML Example <address> <name>Universsity of Birzeit</name> <street>Almarj 435</street> <town>Birzeit</town> </address> Jarrar © 2013 7
    • Address Example: XML to XML XML Markup 1: <address> <name>University of Birzeit</name> <street>Almarj 435</street> <town>Birzeit</town> </address> XML stylesheets to transform between XML representations XML Markup 2: <address> <name>University of Birzeit</name> <place> <street>Almarj 435</street> <town>Birzeit</town> </place> </address> Jarrar © 2013 8
    • Why XML is Not Enough? •  It provides syntax, but not semantics, which is important when exchanging/representing data over the Web. <aaaa> <bbbb>Universsity of Birzeit</bbbb> <cccc>Almarj 435</cccc> <dddd>Birzeit</dddd> </aaaa> •  Not primitive. Same data can be represented in many ways, which is a problem when exchanging/representing data over the Web. <address> <name>University of Birzeit</name> <street>Almarj 435</street> <town>Birzeit</town> </address> <address name=“University of Birzeit”> <street>Almarj 435</street> <town>Birzeit</town> </address> Jarrar © 2013 9
    • What is RDF? •  W3C standard since 1999 •  RDF stands for Resource Description Framework. •  For describing resources on the web. •  Written in XML. It is not a language but a framework •  You see it as a way of writing XML è making it meaningful and more primitive. •  You may see it independent, RDF data might never occur in XML form Jarrar © 2013 10
    • Makes use of URIs •  In order to refer to and identify things on the web (i.e., web resource) RDF uses a URI (Uniform Resource Identifier). •  è URIs are like Global Primary Key. •  Unlike URLs, URIs are not limited to identifying things that have a network location. •  A URI reference (URIref) is a URI, together with an optional fragment identifier at the end. http://www.example.org/index.html#section2 Jarrar © 2013 11
    • RDF Important Concepts •  Data is represented in RDF as a directed labeled graph. •  An RDF graph is a set of triples, of the form <Subject, Predicate, Object> http://www.amazon.com/Orientalism-Edward-W-Said/dp/039474067Xc 11$ :Author Edward Said Orientalism Each Subject and each Predicate must be a URI; that is, it has to be a unique identifier, not a literal. An Object can be either a URI or a literal. Jarrar © 2013 12
    • Example http://www.amazon.com/Orientalism-Edward-W-Said/dp/039474067Xc 11$ :Author Edward Said Orientalism <?xml version="1.0"?> <rdf:RDF xmlns:rdf=http://www.w3.org/1999/02/22-rdf-syntax-ns# xmlns:a="http://www.example.com" xmlns:w="http://en.wikipedia.org/wiki/"> <rdf:Description rdf:about="http://www.amazon.com/Orientalism-Edward-W-Said/dp/039474067X"> <a:Title>Orientalism</a:Title> <a:Price>11$</a:Price> <a:Author>Edward_Said</a:Author> </rdf:Description> </rdf:RDF> Jarrar © 2013 13
    • Example a:Author http://en.wikipedia.org/wiki/Edward_Said a:Die dAt 25/9/2003 11$ Orientalism 1/11/1935 a:BirthCity http://www.amazon.com/Orientalism-Edward-W-Said/dp/039474067Xc Edward Saïd <?xml version="1.0"?> <rdf:RDF xmlns:rdf=http://www.w3.org/1999/02/22-rdf-syntax-ns# Jerusalem xmlns:a="http://www.example.com/" xmlns:w="http://en.wikipedia.org/wiki/"> <rdf:Description rdf:about="http://www.amazon.com/Orientalism-Edward-W-Said/dp/039474067X"> <a:Title>Orientalism</a:Title> <a:Price>11$</a:Price> <a:Author> <rdf:Description rdf:about="w:Edward_Said"> <a:BirthCity>Jerusalem</a:BirthCity> <a:BornAt>1/11/1935</a:BornAt> <a:DiedA>25/9/2003</a:DiedA> </rdf:Description> </a:Author> </rdf:Description> </rdf:RDF> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> Jarrar © 2013 14
    • Example :Author http://en.wikipedia.org/wiki/Edward_Said :Died 25/9/2003 At :BirthCity http://www.amazon.com/Orientalism-Edward-W-Said/dp/039474067Xc <?xml version="1.0"?> Orientalism Edward Saïd <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" 11$ xmlns:dc="http://purl.org/dc/elements/1.1/" 1/11/1935 xmlns:a="http://www.example.com#" xmlns:w="http://en.wikipedia.org/wiki/"> http://en.wikipedia.org/wiki/Jerusalem <rdf:Description rdf:about="http://www.amazon.com/Orientalism-Edward-W-Said/dp/039474067X"> <a:Title>Orientalism</a:Title> <a:Price>11$</a:Price> <a:Author> <rdf:Description rdf:about="w:Edward_Said"> <a:BornAt>1/11/1935</a:BornAt> <a:DiedA>25/9/2003</a:DiedA> 760800 Palestine <a:BirthCity> <rdf:Description rdf:about="http://en.wikipedia.org/wiki/Jerusalem"> <a:Population>760800</a:Population> <a:CapitalOf>Palestine</a:CapitalOf> </rdf:Description> </a:BirthCity> </rdf:Description> </a:Author> </rdf:Description> </rdf:RDF> Jarrar © 2013 15
    • Another Example Jarrar © 2013 16
    • Directed Labelled Graph Representation Jarrar © 2013 17
    • Simple Example <?xml version="1.0"?> <RDF> <Description about="http://www.w3schools.com/default.asp"> <author>Jan Egil Refsnes</author> <created>November 1, 1999</created> <modified>February 1, 2004</modified> </Description> </RDF> Jarrar © 2013 18
    • Example Explained •  In the example: –  the URI "http://www.w3schools.com/-default.asp" is used to identify a web page, –  the property "author" describes the author of the page, –  the property value is "Jan Egil Refsnes". –  The property "created" tells when the page was created, and the property "modified" when it was last modified. Jarrar © 2013 19
    • Subject, Predicate & Object •  RDF terminology also use the words subject, predicate and object. •  The resource http://www.w3schools.com/default.asp is the subject •  The property "author" is the predicate •  The value "Jan Egil Refsnes" is the object Jarrar © 2013 20
    • Example 2 <rdf:RDF> xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax ns#" xmlns:cd="http://www.recshop.fake/cd"> <rdf:Description rdf:about="http://www.recshop.fake/cd/Empire Burlesque"> <cd:artist>Bob Dylan</cd:artist> <cd:country>USA</ cd:country> <cd:company>Columbia</cd:company> <cd:price>10.90</cd:price> <cd:year>1985</cd:year> </rdf:Description> ............ Jarrar © 2013 21
    • Example 2 (cont) <rdf:Description rdf:about="http://www.recshop.fake/cd/Hide your heart"> <cd:artist>Bonnie Tyler</cd:artist> <cd:country>UK</ cd:country> <cd:company>CBS Records</cd:company> <cd:price>9.90</cd:price> <cd:year>1988</cd:year> </rdf:Description> </rdf:RDF> Jarrar © 2013 22
    • Details of the Example •  The first line in the XML file is the XML declaration, telling the version of XML. •  The rdf:RDF element indicates that the content is RDF. •  The xmlns:rdf namespace, specifies that tags with the rdf: prefix are from the namespace defined by "http://www.w3.org/1999/02/22-rdf-syntax-ns#". •  The xmlns:cd namespace, specifies that tags with the cd: prefix are from the namespace defined by "http://www.recshop.fake/cd". •  The rdf:Description element contains the description of a resource identified by the rdf:about attribute. •  The cd:artist element describes a property of the resource, and so does cd:country, etc. Jarrar © 2013 23
    • Table Representation (List of Triples) Subject Predicate Object http://www.recshop.fake/cd/Empire Burlesque http://www.recshop.fake/cdartist "Bob Dylan" http://www.recshop.fake/cd/Empire Burlesque http://www.recshop.fake/ cdcountry "USA” http://www.recshop.fake/cd/Empire Burlesque http://www.recshop.fake/ cdcompany "Columbia” http://www.recshop.fake/cd/Empire Burlesque http://www.recshop.fake/cdprice "10.90” http://www.recshop.fake/cd/Empire Burlesque http://www.recshop.fake/cdyear "1985” Jarrar © 2013 24
    • Main RDF Properties and Attributes Main RDF Properties •  rdf:subject The subject of the resource in an RDF Statement •  rdf:predicate The predicate of the resource in an RDF Statement •  rdf:object The object of the resource in an RDF Statement •  rdf:type The resource is an instance of a class Main RDF Attributes •  rdf:RDF The root of an RDF document •  rdf:about Defines the resource being described •  rdf:Description Container for the description of a resource •  rdf:resource Defines a resource to identify a property •  rdf:datatype Defines the data type of an element Jarrar © 2013 25
    • RDF Validator •  Check the correctness of an RDF document: http://www.w3.org/RDF/Validator/ •  Result shows the subject, predicate and object of each element of the document and a graph of the model. Jarrar © 2013 26
    • Mapping XML into RDF (Example) XML <XML> ID=B1 Year=“2000”> <Article <Article ID=B2 Year=“2005”> <Author href=“#A1”/> <Author ID=A1> <Author ID=A2> <Name>Tom</Name> <Name>Bob</Name> <Affiliation ID=UoM> <Affiliation ID=UoC> <Name>University of Malta</Name> <Name>University of Cyprus</Name> <Country ID=mt> <Country ID=cy> <Name> Malta</Name> <Name> Cyprus</Name> <Capital>Valletta</Capital> <Capital>Nicosia</Capital> </Country> </Country> </Affiliation> </Affiliation> <Author> <Author> </Article> </Article> 2000 B1 le Artic Root A1 Affiliation N a me e B2 Article RDF Articl Author Employs B4 B3 2008 ACM Author Author A2 2005 A3 2007 e Nam Affiliation UoM e Nam County <Article ID=B3 Year=“2007”> <Author ID=A3> <email>ps@uoc</email> <Affiliation href=“#UoC”/> <Author> </Article> <Article ID=B4 Year=“2008”> <Publisher ID=ACM/> </Article> </XML> “University of Malta” “Malta” mt “Valletta” “Tom” “Bob” Employs ion Affiliat WorksFor ema il UoC County cy Nam e “Cyprus” “Nicosia” “University of Cyprus” p3@uoc Jarrar © 2013 27
    • Mapping Database into RDF (Example) Ar1cle   ID   Year   B1   Data  Web   2007   B2   Author   Tile   Seman;c  Web   2005   Ar1cle   Person   Person   B1   A1   ID   Name   Affilia1on   B1   A2   A1   Tom  Lara   UoM   B2   A2   A2   Bob  Hacker   UoC   Country   Affilia1on   ID   Name   ID   Country   mt   Malta   UoM   mt   cy   Cyprus   UoC   cy   S   :B1   :B1   :B1   :B2   :B2   :B2   :B1   :B1   :B2   :A1   :A1   :A1   :A2   :A2   :A2   :UoM   :UoM   :mt   :mt   :UoC   :UoC   :cy   :cy   Jarrar © 2013 RDF   P   rdf:Type   :Title   :Year   rdf:Type   :Title   :Year   :Author   :Author   :Author   rdf:Type   :Name   :Affilia;on   :Type   :Name   :Affilia;on   :Type   :Country   :Type   :Name   :Type   :Country   :Type   :Name   O   :Ar;cle   “Data  Web”   2007   :Ar;cle   “Seman;c  Web”   2005   :A1   :A2   :A1   :Person   “Tom  Lara”   :UoM   :Person   “Bob  Hacker”   :UoC   :University   :mt   :Country   “Malta”   :University   :cy   :Country   “Cyprus”   28
    • Practice Session Write all information in your Passport into formats: 1.  in RDF/XML format, 2.  as SPO table. Jarrar © 2013 29
    • Practice Session ( Solution Example) <?xml version="1.0"?> <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:mz="http://www.example.com/" xmlns:xsd="http://www.w3.org/2001/XMLSchema-datatypes"> <rdf:Description rdf:about="http://mohammad.example.com/"> <mz:id rdf:datatype="xsd:integer">111111111</mz:id> <mz:firstname>Mohammad</mz:firstname> <mz:firstname xml:lang="ar"> ‫/< ﻡمﺡحﻡمﺩد‬mz:firstname> <mz:familyname>ZeinEddin</mz:familyname> <mz:wife rdf:resource="http://tamara.example.com/" /> </rdf:Description> <rdf:Description rdf:about="http://tamara.example.com/"> <mz:id rdf:datatype="xsd:integer">2222222222</mz:id> <mz:firstname>Tamara</mz:firstname> <mz:familyname>Adam</mz:familyname> </rdf:Description> </rdf:RDF> Jarrar © 2013 30
    • Practice Session ( Solution Example) Jarrar © 2013 31
    • Practice Session ( Solution Example) Jarrar © 2013 32