Journal Quantum Jim's Journal: A Brief Introduction to RDF
A Brief Introduction to the Resource Description Framework
===========================================================
Note: The following is a draft. Will revise and webify. ASCII art is formatted for 80 character lines.
Definitions
===========
RDF is a language framework for describing directed graphs. First, some definitions:
* A _directed graph_ is a bunch of nodes connected by arrows.
* The node at the beginning of an arrow is called the _subject_.
* The node at the end of an arrow is called the _object_.
* The arrow is called the _predicate_.
* The whole thing is called a _statement_.
Example Graphs in Pictures
==========================
Here's a graph composed of only one statement:
----------- predicate ----------
| subject |--------------->| object |
----------- ----------
A subject node for one statement can be the object node of another statment:
----------- predicate ----------- predicate2 -----------
| subject |--------------->| object1 |---------------->| object2 |
----------- ----------- -----------
Node and Arrow String Values
============================
Now each node can have a string value:
* It could have no string value; these nodes are called _blank nodes_.
* It can also have a URI value; a URL is an example of an URI. In fact, every "node" with the same URI value is actually the same node (i.e. they are not seperate nodes).
* Objects can also be any arbitrary string - including the empty string ("") - but subjects can only be URI strings. These types of objects are called _literals_.
Note that every predicate MUST have a URI value; they can't be blank or arbitrary strings. It is also a VERY BAD IDEA to let predicates end with anything other than the characters a-z, A-Z, or 0-9 (that is, the end of the uri SHOULD be a valid xml name).
URI Examples
============
Here are some examples of URIs that could be a subjects, predicates, or objects. There is no way of knowing in isolation which is which. Each URI is DIFFERENT (even if they point to the same thing on the web).
1. http://example.com/subject
2. http://example.com/subject/index.html
3. http://example.com#predicate
4. file:///C:/Files/old/Video%20Game/mario.jpg
5. http://www.google.com/search?q=mario
If the URIs are all predicates, then 1, 3, and 5 are formatted best. Here are some real-world examples of precicates:
* http://purl.org/dc/elements/1.1/creator
* http://www.w3.org/2000/01/rdf-schema#isDefinedBy
Here are some example strings that could be literals:
* http://purl.org/dc/elements/1.1/creator
* Mary had a little lamb
* <strong><acronym>HTML</acronym> is cool</strong>
* 47
Datatypes
=========
Literals can also have a property called its _datatype_. For example, the literal string "47" is also an integer, so it could be described by a datatype that means integer. This isn't required, of course, and many literals have no defined datatype.
The datatype is like a predicate and can only be a URI. Here are some real-life examples of datatypes:
* http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral
* http://www.w3.org/2001/XMLSchema#int
Review of Values of Nodes and Arrows
====================================
In review:
* A subject can either have:
* No string value.
* URI string value.
* A predicate MUST have ONLY a:
* URI string value.
* An object can either have:
* No string value.
* URI string value.
* Literal string value.
* A literal object can optional have:
* A datatype
* A datatype MUST have ONLY a:
* URI string value.
Graphs as Databases
===================
Graphs can be thought of as collections of statements, and statements can be thought of as subject/predicate/object tuples. I tend to think of statements as English sentences and graphs as paragraphs or stories. The analogy holds up pretty well.
Graphs can also be looked at as a tables in a database. Here's an example (First set is the heading):
Subject
Prediate
Object
(Datatype) .
http://example.com#subject1
http://purl.org/dc/elements/1.1/creator
"Jimmy"
http://www.w3.org/2001/XMLSchema#string .
http://example.com#subject1
http://purl.org/dc/elements/1.1/creator
"John" .
http://example.com#subject1
http://purl.org/dc/elements/1.1/creator
http://example.com/subject2 .
http://example.com/subject2
http://purl.org/dc/elements/1.1/creator
"Jimmy"
http://www.w3.org/2001/XMLSchema#string .
Conclusion
==========
There's a lot more, but these are the basics.
===========================================================
Note: The following is a draft. Will revise and webify. ASCII art is formatted for 80 character lines.
Definitions
===========
RDF is a language framework for describing directed graphs. First, some definitions:
* A _directed graph_ is a bunch of nodes connected by arrows.
* The node at the beginning of an arrow is called the _subject_.
* The node at the end of an arrow is called the _object_.
* The arrow is called the _predicate_.
* The whole thing is called a _statement_.
Example Graphs in Pictures
==========================
Here's a graph composed of only one statement:
----------- predicate ----------
| subject |--------------->| object |
----------- ----------
A subject node for one statement can be the object node of another statment:
----------- predicate ----------- predicate2 -----------
| subject |--------------->| object1 |---------------->| object2 |
----------- ----------- -----------
Node and Arrow String Values
============================
Now each node can have a string value:
* It could have no string value; these nodes are called _blank nodes_.
* It can also have a URI value; a URL is an example of an URI. In fact, every "node" with the same URI value is actually the same node (i.e. they are not seperate nodes).
* Objects can also be any arbitrary string - including the empty string ("") - but subjects can only be URI strings. These types of objects are called _literals_.
Note that every predicate MUST have a URI value; they can't be blank or arbitrary strings. It is also a VERY BAD IDEA to let predicates end with anything other than the characters a-z, A-Z, or 0-9 (that is, the end of the uri SHOULD be a valid xml name).
URI Examples
============
Here are some examples of URIs that could be a subjects, predicates, or objects. There is no way of knowing in isolation which is which. Each URI is DIFFERENT (even if they point to the same thing on the web).
1. http://example.com/subject
2. http://example.com/subject/index.html
3. http://example.com#predicate
4. file:///C:/Files/old/Video%20Game/mario.jpg
5. http://www.google.com/search?q=mario
If the URIs are all predicates, then 1, 3, and 5 are formatted best. Here are some real-world examples of precicates:
* http://purl.org/dc/elements/1.1/creator
* http://www.w3.org/2000/01/rdf-schema#isDefinedBy
Here are some example strings that could be literals:
* http://purl.org/dc/elements/1.1/creator
* Mary had a little lamb
* <strong><acronym>HTML</acronym> is cool</strong>
* 47
Datatypes
=========
Literals can also have a property called its _datatype_. For example, the literal string "47" is also an integer, so it could be described by a datatype that means integer. This isn't required, of course, and many literals have no defined datatype.
The datatype is like a predicate and can only be a URI. Here are some real-life examples of datatypes:
* http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral
* http://www.w3.org/2001/XMLSchema#int
Review of Values of Nodes and Arrows
====================================
In review:
* A subject can either have:
* No string value.
* URI string value.
* A predicate MUST have ONLY a:
* URI string value.
* An object can either have:
* No string value.
* URI string value.
* Literal string value.
* A literal object can optional have:
* A datatype
* A datatype MUST have ONLY a:
* URI string value.
Graphs as Databases
===================
Graphs can be thought of as collections of statements, and statements can be thought of as subject/predicate/object tuples. I tend to think of statements as English sentences and graphs as paragraphs or stories. The analogy holds up pretty well.
Graphs can also be looked at as a tables in a database. Here's an example (First set is the heading):
Subject
Prediate
Object
(Datatype)
http://example.com#subject1
http://purl.org/dc/elements/1.1/creator
"Jimmy"
http://www.w3.org/2001/XMLSchema#string
http://example.com#subject1
http://purl.org/dc/elements/1.1/creator
"John"
http://example.com#subject1
http://purl.org/dc/elements/1.1/creator
http://example.com/subject2
http://example.com/subject2
http://purl.org/dc/elements/1.1/creator
"Jimmy"
http://www.w3.org/2001/XMLSchema#string
Conclusion
==========
There's a lot more, but these are the basics.
A Brief Introduction to RDF More Login
A Brief Introduction to RDF
Slashdot Top Deals