dr. alexandra i. cristea acristea/ cs 253: topics in database systems: c3

56
Dr. Alexandra I. Cristea http://www.dcs.warwick.ac.uk/ ~acristea/ CS 253: Topics in Database Systems: C3

Upload: ashley-mccullough

Post on 28-Mar-2015

215 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Dr. Alexandra I. Cristea acristea/ CS 253: Topics in Database Systems: C3

Dr. Alexandra I. Cristea

http://www.dcs.warwick.ac.uk/~acristea/

CS 253: Topics in Database Systems: C3

Page 2: Dr. Alexandra I. Cristea acristea/ CS 253: Topics in Database Systems: C3

2

• Previously we looked at:– XML and its query language(s)

• Next:– RDF and its query languages

Page 3: Dr. Alexandra I. Cristea acristea/ CS 253: Topics in Database Systems: C3

3

RDF

Page 4: Dr. Alexandra I. Cristea acristea/ CS 253: Topics in Database Systems: C3

4

RDF Definition

• The Resource Description Framework (RDF) is a W3C standard for describing resources on the Web.

• RDF is a framework for describing Web resources, – e.g., title, author, modification date,

content, and copyright information of a Web page.

Page 5: Dr. Alexandra I. Cristea acristea/ CS 253: Topics in Database Systems: C3

5

What (else) is RDF?

• RDF provides a model for data, and a syntax so that independent parties can exchange and use it

• RDF is designed to be read and understood by computers

• RDF is not designed for being displayed to people • RDF (can be) written in XML • RDF is a part of the W3C's Semantic Web Activity • RDF is a W3C Recommendation (so a standard!)

• http://www.w3.org/RDF/

Page 6: Dr. Alexandra I. Cristea acristea/ CS 253: Topics in Database Systems: C3

6

RDF Usage Examples• Describing properties for shopping items,

such as price and availability • Describing time schedules for web events • Describing information about web pages,

such as content, author, created and modified date

• Describing content and rating for web pictures • Describing content for search engines • Describing electronic libraries

Page 7: Dr. Alexandra I. Cristea acristea/ CS 253: Topics in Database Systems: C3

7

RDF is Designed to be Read by Computers

• RDF was designed to provide a common way to describe information so it can be read and understood by computer applications.

• RDF descriptions are not designed to be displayed on the web.

Page 8: Dr. Alexandra I. Cristea acristea/ CS 253: Topics in Database Systems: C3

8

RDF can be Written in XML

• RDF documents can be written in XML. XML language : RDF/XML.

• information exchange between – different types of computers – types of operating systems and – application languages.

Page 9: Dr. Alexandra I. Cristea acristea/ CS 253: Topics in Database Systems: C3

9

RDF and "The Semantic Web"

• The RDF language is a part of the W3C's Semantic Web Activity. W3C's "Semantic Web Vision" is a future where:– Web information has exact meaning – Web information can be understood and

processed by computers – Computers can integrate information

from the web

Page 10: Dr. Alexandra I. Cristea acristea/ CS 253: Topics in Database Systems: C3

10

RDF Statements

• RDF is built of Statement s• known as the

– subject, – predicate and – object

(of a Statement).

Page 11: Dr. Alexandra I. Cristea acristea/ CS 253: Topics in Database Systems: C3

11

RDF Statements

SubjectPredicate

Object

Page 12: Dr. Alexandra I. Cristea acristea/ CS 253: Topics in Database Systems: C3

12

Examples

• Let's look at some example statements to get a better understanding:– Statement: "The author of

http://www.w3schools.com/RDF is Jan Egil Refsnes".– Statement: "The homepage of

http://www.w3schools.com/RDF is http://www.w3schools.com".

Page 13: Dr. Alexandra I. Cristea acristea/ CS 253: Topics in Database Systems: C3

13

Examples – cont.

• Statement: "The author of http://www.w3schools.com/RDF is Jan Egil Refsnes".– The subject of the statement above is:

http://www.w3schools.com/RDF – The predicate is: author – The object is: Jan Egil Refsnes

• Statement: "The homepage of http://www.w3schools.com/RDF is http://www.w3schools.com".– The subject of the statement above is:

http://www.w3schools.com/RDF – The predicate is: homepage – The object is: http://www.w3schools.com

Page 14: Dr. Alexandra I. Cristea acristea/ CS 253: Topics in Database Systems: C3

14

RDF Statements

SubjectPredicate

author http://www.w3schools.com/RDF

Object

Jan Egil Refsnes

Page 15: Dr. Alexandra I. Cristea acristea/ CS 253: Topics in Database Systems: C3

15

RDF Resource, Property, and Property Value

• RDF identifies things using Web identifiers (URIs), and • describes resources with properties and property

values.

• A Resource is anything that can have a URI, – such as "http://www.w3schools.com/RDF"

• A Property is a Resource that has a name, – such as "author" or "homepage"

• A Property value is the value of a Property, – such as "Jan Egil Refsnes" or "http://www.w3schools.com"

(note that a property value can be another resource)

Page 16: Dr. Alexandra I. Cristea acristea/ CS 253: Topics in Database Systems: C3

16

RDF Statements

SubjectPredicate

author http://www.w3schools.com/RDF

ResourceProperty

Can be another resource !!

Object

Jan Egil Refsnes

Property Value

Page 17: Dr. Alexandra I. Cristea acristea/ CS 253: Topics in Database Systems: C3

17

Example

Page 18: Dr. Alexandra I. Cristea acristea/ CS 253: Topics in Database Systems: C3

18

RDF original purpose & the metadata

• originally created in 1999

• as a standard on top of XML, for encoding metadata– literally, data about data. – e.g., who authored a web page, what date a

blog entry was published, etc., – secondary info

Page 19: Dr. Alexandra I. Cristea acristea/ CS 253: Topics in Database Systems: C3

19

So, RDF ..

• Different world view

• Triples (instead of pairs)

• More natural?

• This is the concept … how to implement it?

Page 20: Dr. Alexandra I. Cristea acristea/ CS 253: Topics in Database Systems: C3

20

RDF/XML

Page 21: Dr. Alexandra I. Cristea acristea/ CS 253: Topics in Database Systems: C3

21

Example RDF/XML

• <?xml version="1.0"?> • <RDF> • <Description about="http://www.w3schools.com/RDF"> <author> </author> <homepage>http://www.w3schools.com</homepage> • </Description> • </RDF>

Resource Property

Jan Egil Refsnes

Property value

Page 22: Dr. Alexandra I. Cristea acristea/ CS 253: Topics in Database Systems: C3

22

RDF/XML• Is not the only solution, • but the recommended one• No one-to-one mapping

– RDF doesn’t have ordering– XML does!– Serialization of a graph!– So is this the price to pay?

• Others: Notation 3 http://www.w3.org/DesignIssues/Notation3.html , Turtle http://www.dajobe.org/2004/01/turtle/

Page 23: Dr. Alexandra I. Cristea acristea/ CS 253: Topics in Database Systems: C3

23

RDF namespace

<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:cd="http://www.recshop.fake/cd#">

Page 24: Dr. Alexandra I. Cristea acristea/ CS 253: Topics in Database Systems: C3

24

Other namespaces

<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:cd="http://www.recshop.fake/cd#">

Page 25: Dr. Alexandra I. Cristea acristea/ CS 253: Topics in Database Systems: C3

25

RDF Online Validator• W3C's RDF Validation Service is useful when learning

RDF. Here you can experiment with RDF files.• The online RDF Validator parses your RDF document,

checks your syntax, and generates tabular and graphical views of your RDF document.

• Sample result: the triple(s): http://www.w3schools.com/rdf/RDFvalidationresult.htm

Page 26: Dr. Alexandra I. Cristea acristea/ CS 253: Topics in Database Systems: C3

26

The <rdf:RDF> Element• <rdf:RDF> is the root element of an RDF document. It

defines the XML document to be an RDF document. • It also contains a reference to the RDF namespace.

<?xml version="1.0"?>

<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> . . Description goes here

</rdf:RDF>

Page 27: Dr. Alexandra I. Cristea acristea/ CS 253: Topics in Database Systems: C3

27

The <rdf:Description> Element• The <rdf:Description> element identifies a resource

with the about attribute.• The <rdf:Description> element contains elements

that describe the resource.<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>

Page 28: Dr. Alexandra I. Cristea acristea/ CS 253: Topics in Database Systems: C3

28

A Resource and its Description

<?xml version="1.0"?> <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">

… </rdf:Description> . . . </rdf:RDF>

Page 29: Dr. Alexandra I. Cristea acristea/ CS 253: Topics in Database Systems: C3

29

Another example

Title Artist Country Company Price Year

Empire Burlesque

Bob Dylan USA Columbia 10.90 1985

Hide your heart Bonnie Tyler UK CBS Records 9.90 1988

...        

Page 30: Dr. Alexandra I. Cristea acristea/ CS 253: Topics in Database Systems: C3

30

<?xml version="1.0"?> <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> <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>

RDF Declaration

Page 31: Dr. Alexandra I. Cristea acristea/ CS 253: Topics in Database Systems: C3

31

Properties as Attributes• The property elements can also be defined as

attributes (instead of elements):

<rdf:Description rdf:about="http://www.recshop.fake/cd/Empire Burlesque" cd:artist="Bob Dylan" cd:country="USA" cd:company="Columbia" cd:price="10.90" cd:year="1985" />

Can you identify the triples here? (resource, property, value)

Page 32: Dr. Alexandra I. Cristea acristea/ CS 253: Topics in Database Systems: C3

32

Properties as Resources• The property elements can also be defined as

resources:<rdf:Description

rdf:about="http://www.recshop.fake/cd/Empire Burlesque">

<cd:artist rdf:resource="http://www.recshop.fake/cd/dylan" />

. . . </rdf:Description>

Page 33: Dr. Alexandra I. Cristea acristea/ CS 253: Topics in Database Systems: C3

33

Compare: properties as• elements <rdf:Description rdf:about="http://www.recshop.fake/cd/Empire

Burlesque"> <cd:artist>Bob Dylan</cd:artist>

</rdf:Description> • attributes<rdf:Description rdf:about="http://www.recshop.fake/cd/Empire

Burlesque" cd:artist="Bob Dylan" />• resources<rdf:Description rdf:about="http://www.recshop.fake/cd/Empire

Burlesque"> <cd:artist rdf:resource="http://www.recshop.fake/cd/dylan" /></rdf:Description>

Page 34: Dr. Alexandra I. Cristea acristea/ CS 253: Topics in Database Systems: C3

34

RDF Containers

• RDF containers are used to describe group of things.

• e.g, to list the authors of a book or to list the members in a band.

• The following RDF elements are used to describe such groups:

<Bag>, <Seq>, and <Alt>.

Page 35: Dr. Alexandra I. Cristea acristea/ CS 253: Topics in Database Systems: C3

35

RDF Bag• The <rdf:Bag> element is used to describe a list of values that

is intended to be unordered.• The <rdf:Bag> element may contain duplicate values.

<rdf:Description rdf:about="http://www.recshop.fake/cd/Beatles"> <cd:artist> <rdf:Bag> <rdf:li>John</rdf:li> <rdf:li>Paul</rdf:li> <rdf:li>George</rdf:li> <rdf:li>Ringo</rdf:li> </rdf:Bag> </cd:artist> </rdf:Description>

Page 36: Dr. Alexandra I. Cristea acristea/ CS 253: Topics in Database Systems: C3

36

Student example<?xml version="1.0"?> <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"

xmlns:s="http://example.org/students/vocab#"> <rdf:Description rdf:about="http://example.org/courses/6.001"> <s:students> <rdf:Bag> <rdf:li rdf:resource="http://example.org/students/Amy"/> <rdf:li

rdf:resource="http://example.org/students/Mohamed"/> <rdf:li rdf:resource="http://example.org/students/Johann"/> <rdf:li rdf:resource="http://example.org/students/Maria"/> <rdf:li rdf:resource="http://example.org/students/Phuong"/> </rdf:Bag> </s:students> </rdf:Description> </rdf:RDF>

Page 37: Dr. Alexandra I. Cristea acristea/ CS 253: Topics in Database Systems: C3

37

RDF Bag

Page 38: Dr. Alexandra I. Cristea acristea/ CS 253: Topics in Database Systems: C3

38

The <rdf:Seq> Element• The <rdf:Seq> element is used to describe a list of values that is

intended to be ordered (For example, in alphabetical order).• The <rdf:Seq> element may contain duplicate values.• <rdf:Description rdf:about="http://www.recshop.fake/cd/Beatles"> • <cd:artist> • <rdf:Seq> • <rdf:li>George</rdf:li> • <rdf:li>John</rdf:li> • <rdf:li>Paul</rdf:li> • <rdf:li>Ringo</rdf:li> • </rdf:Seq> • </cd:artist> • </rdf:Description>

Page 39: Dr. Alexandra I. Cristea acristea/ CS 253: Topics in Database Systems: C3

39

The <rdf:Alt> Element

• The <rdf:Alt> element is used to describe a list of alternative values (the user can select only one of the values).

<rdf:Description rdf:about="http://www.recshop.fake/cd/Beatles">

<cd:format> <rdf:Alt> <rdf:li>CD</rdf:li> <rdf:li>Record</rdf:li> <rdf:li>Tape</rdf:li> </rdf:Alt> </cd:format> </rdf:Description>

Page 40: Dr. Alexandra I. Cristea acristea/ CS 253: Topics in Database Systems: C3

40

RDF Alt

Page 41: Dr. Alexandra I. Cristea acristea/ CS 253: Topics in Database Systems: C3

41

The rdf:parseType="Collection" Attribute

• container cannot be closed.

• other members are allowed.

• RDF collections are used to describe group that contains ONLY the specified members.

• A collection is described by the attribute rdf:parseType="Collection".

Page 42: Dr. Alexandra I. Cristea acristea/ CS 253: Topics in Database Systems: C3

42

Collection attribute example<?xml version="1.0"?> <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-

ns#" xmlns:cd="http://recshop.fake/cd#"> <rdf:Description rdf:about="http://recshop.fake/cd/Beatles">

<cd:artist rdf:parseType="Collection"> <rdf:Description rdf:about="http://recshop.fake/cd/Beatles/George"/> <rdf:Description rdf:about="http://recshop.fake/cd/Beatles/John"/> <rdf:Description rdf:about="http://recshop.fake/cd/Beatles/Paul"/> <rdf:Description rdf:about="http://recshop.fake/cd/Beatles/Ringo"/>

</cd:artist> </rdf:Description> </rdf:RDF>

Page 43: Dr. Alexandra I. Cristea acristea/ CS 253: Topics in Database Systems: C3

43

Collection: a graphical representation

Page 44: Dr. Alexandra I. Cristea acristea/ CS 253: Topics in Database Systems: C3

44

RDF Reification

• Statements about statements– E.g., record info about when statements

were made, who made them, etc. ("provenance" information).

Page 45: Dr. Alexandra I. Cristea acristea/ CS 253: Topics in Database Systems: C3

45

Example• example.com could record the fact that: John

Smith made the original statement about the tent's weight

• By: – original statement URIref (exproducts:triple12345),

describing it w. reification, then – adding an additional statement that

exproducts:triple12345 was written by John Smith (w. URIref for John Smith)

Page 46: Dr. Alexandra I. Cristea acristea/ CS 253: Topics in Database Systems: C3

46

Example figure: reification

original statement

John

Page 47: Dr. Alexandra I. Cristea acristea/ CS 253: Topics in Database Systems: C3

47

RDF Schema and Application Classes

• RDF describes resources with classes, properties, and values

• RDF needs to define application-specific classes and properties– with extensions to RDF

• One such extension is RDF Schema

Page 48: Dr. Alexandra I. Cristea acristea/ CS 253: Topics in Database Systems: C3

48

RDF Schema (RDFS)

• does not provide actual application-specific classes and properties.

• … but framework to describe them

• Classes ~ OO programming languages.

• Resources: – instances of classes, or – subclasses of classes.

Page 49: Dr. Alexandra I. Cristea acristea/ CS 253: Topics in Database Systems: C3

49

RDFS ExampleThe following example demonstrates some of the RDFS facilities:<?xml version="1.0"?> <rdf:RDF xmlns:rdf= "http://www.w3.org/1999/02/22-rdf-syntax-ns#"

xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xml:base= "http://www.animals.fake/animals#">

<rdf:Description rdf:ID="animal"> <rdf:type rdf:resource="http://www.w3.org/2000/01/rdf-schema#Class"/> </rdf:Description> <rdf:Description rdf:ID="horse"> <rdf:type rdf:resource="http://www.w3.org/2000/01/rdf-schema#Class"/> <rdfs:subClassOf rdf:resource="#animal"/> </rdf:Description> </rdf:RDF>

In the example above, the resource "horse" is a subclass of the class "animal".

Page 50: Dr. Alexandra I. Cristea acristea/ CS 253: Topics in Database Systems: C3

50

Example of class structure

Page 51: Dr. Alexandra I. Cristea acristea/ CS 253: Topics in Database Systems: C3

51

<?xml version="1.0"?> <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"

xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xml:base="http://example.org/schemas/vehicles">

<rdf:Description rdf:ID="MotorVehicle"> <rdf:type rdf:resource="http://www.w3.org/2000/01/rdf-schema#Class"/> </rdf:Description> <rdf:Description rdf:ID="PassengerVehicle"> <rdf:type rdf:resource="http://www.w3.org/2000/01/rdf-schema#Class"/> <rdfs:subClassOf rdf:resource="#MotorVehicle"/> </rdf:Description> <rdf:Description rdf:ID="Van"> <rdf:type rdf:resource="http://www.w3.org/2000/01/rdf-schema#Class"/> <rdfs:subClassOf rdf:resource="#MotorVehicle"/> </rdf:Description> <rdf:Description rdf:ID="MiniVan"> <rdf:type rdf:resource="http://www.w3.org/2000/01/rdf-schema#Class"/> <rdfs:subClassOf rdf:resource="#Van"/> <rdfs:subClassOf rdf:resource="#PassengerVehicle"/> </rdf:Description> </rdf:RDF>

Multiple inheritance!

Page 52: Dr. Alexandra I. Cristea acristea/ CS 253: Topics in Database Systems: C3

52

Example Abbreviated

• Since an RDFS class is an RDF resource we can abbreviate it using rdfs:Class instead of rdf:Description, and drop the rdf:type information

Page 53: Dr. Alexandra I. Cristea acristea/ CS 253: Topics in Database Systems: C3

53

Original Class declaration<?xml version="1.0"?> <rdf:RDF xmlns:rdf= "http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xml:base= "http://www.animals.fake/animals#"> <rdf:Description rdf:ID="animal"> <rdf:type rdf:resource="http://www.w3.org/2000/01/rdf-schema#Class"/> </rdf:Description> <rdf:Description rdf:ID="horse"> <rdf:type rdf:resource="http://www.w3.org/2000/01/rdf-schema#Class"/> <rdfs:subClassOf rdf:resource="#animal"/> </rdf:Description> </rdf:RDF>

Page 54: Dr. Alexandra I. Cristea acristea/ CS 253: Topics in Database Systems: C3

54

Example Class Abbreviated<?xml version="1.0"?> <rdf:RDF xmlns:rdf= "http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xml:base= "http://www.animals.fake/animals#"> <rdfs:Class rdf:ID="animal" /> <rdfs:Class rdf:ID="horse"> <rdfs:subClassOf rdf:resource="#animal"/> </rdfs:Class> </rdf:RDF>

Page 55: Dr. Alexandra I. Cristea acristea/ CS 253: Topics in Database Systems: C3

55

Original and abbreviated class

So we replace:<rdf:Description rdf:ID="animal">

<rdf:type rdf:resource="http://www.w3.org/2000/01/rdf-schema#Class"/>

</rdf:Description>

with<rdfs:Class rdf:ID="animal" />

Page 56: Dr. Alexandra I. Cristea acristea/ CS 253: Topics in Database Systems: C3

56

RDF Conclusion

• We have learned:– RDF definition– Usage scenarios, basics– Existence of RDFS– Comparison w. XML