The Core Structure of RDF


RDF does a good job of structuring itself like human thought patterns. The relationship between the data points mirrors the way you would structure these data points yourself. For instance, in the Hemingway example, you might structure a data relationship something like, "The book The Sun Also Rises has the author of Ernest Hemingway."

In this case, you have three entities-also called a triples or a statement. These data points include

  • q A subject-The item of focus. In the case of the Hemingway example, the subject is the book The Sun Also Rises. Any metadata provided is meant to further define this subject.

  • q A predicate-a term that provides a property or relation to the subject. This is also considered the verb of the statement.

  • q An object- A term that works with the predicate to apply a specific relation between the object and subject.

You can break the sentence apart as shown in the diagram in Figure 24-1.

image from book
Figure 24-1

Instead of having just a subject value within your data store, such as the book The Sun Also Rises, using RDF you can also put in place relations such as those presented in Figure 24-1. In fact, you can continue the triples structure and branch out to all kinds of actual relations.

As stated, the three items taken together (the subject, predicate, and object) are referred to as a statement. A series of statements taken together are referred to as a model.

A model is basically a hierarchical set of statements that are interrelated in some fashion. For instance, if you add statements around Hemingway, you come up with the logical model presented in Figure 24-2.

image from book
Figure 24-2

As you can see, the relationships between the items are the predicates. Each item is either a subject or an object (in most cases, an item can be both depending on the combinations of subjects and objects you are working with). In this diagram, you see a large list of RDF statements which includes all the triples, as shown in the following table.

Open table as spreadsheet

Subject

Predicate

Object

Ernest Hemingway

wrote a book called

The Sun Also Rises

Ernest Hemingway

wrote a book called

For Whom the Bell Tolls

Ernest Hemingway

had a granddaughter named

Mariel Hemingway

The Sun Also Rises

was published in

the year 1926

For Whom the Bell Tolls

was published in

the year 1940

The Sun Also Rises

was published by

Charles Scribner's Sons

For Whom the Bell Tolls

was published by

Charles Scribner's Sons

Mariel Hemingway

was in a movie named

Manhattan

You can see that relationships really can go on forever because everything is related to something somewhere. Try to focus your RDF statements on the most meaningful and relevant relationships.

RDF creates these relations by relying upon unique identifiers: the triples that make up the RDF statement. Many folks are aware of the URL, or the Uniform Resource Locator, which is used to uniquely identify a Web page or Web resource on the Internet. When you type a URL in the address bar of the browser, you are directed to a specific resource.

In addition to URLs, you find URIs, also known as Uniform Resource Identifiers. Not everything can be a URL-accessible resource, so URIs were created to allow for other items to have unique identifiers. An example URI is presented here:

http://www.lipperweb.com/myURI

Most URIs appear to be URLs (of actual Web resources). Although a URI need not be a Web site URL (like the one in the previous example), this is usually a good idea. The URI can be anything you want it to be. For example, you could write one using terms like myData or 12345. This kind of URI does not guarantee any uniqueness, however. Another URI in another file elsewhere may use the same value. Therefore, it is common practice to use a URL as the value of your URI. In the end, this practice really serves two purposes. First, it guarantees a unique URI that won't conflict with any other. The other advantage of using a URL as the URI is that an URL identifies where the data originated.

When constructing your URIs, you don't have to point to an actual file. In fact, it is usually better not to do just that, but instead to use something like the following:

http://www.mydomain.com/myNamespaceName




Professional XML
Professional XML (Programmer to Programmer)
ISBN: 0471777773
EAN: 2147483647
Year: 2004
Pages: 215

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net