Why are predicate and class distinct in rdf?
In RDF, a class is distinguished from a predicate or attribute. What is the benefit of doing this versus just having one thing, a class, that can appear as subject, predicate or object in any triple?
Edit: for example:
1 book has chapters
2 book1 is book
3 chapter1 is chapter
4a book1 chapter chapter1
In this example, chapter is both an object (in statement 3) and a predicate (in statement 4a). Some p开发者_JAVA百科eople claim that this is not a good idea.
The meaning of these statements is quite obvious - a book has chapters, book1 is a book, chapter1 is a chapter, book1 has a chapter called chapter1. An alternative suggested is to replace 4 above with 4b:
4b book1 has chapter1
However, this requires more effort to parse/reason: if book has chapter, book has author, book has publisher, then a statement like book1 has foo requires a lot more work to figure out (we have to find that foo is, say, an author to figure out that book1's author is foo). Better still, I can avoid statement 3 above, since statement 4 tells me that chapter1 is a chapter.
This pattern appears commonly in graphs containing both data and metadata. Are there any disadvantages in using 1,2,4a versus 1,2,3,4b? The only problem I see is that this violates the distinction between a property and a class (subject/object), but how does that affect us practically?
Your example (books and chapters) only appears to make sense because of the loose and flexible way we use language, and our human interpretation (and your use of a possessive as the example)
So if I said
Book - Chapter - Chapter1
then that only appears to make sense because mentally we map the noun Chapter to the verb phrase "has Chapter", because we understand how books and chapters work. Machines consuming RDF do not understand this!
But if I said Book - Person - John, what are we to make of this? Is John the author, the reader, one of the characters, or what? This is why we need to specify an unambiguous predicate, e.g.
Book - hasAuthor - John
Book - readBy - John
I don't entirely understand your question here. The RDF data model is based upon three kinds of terms:
- URIs (aka Named Resources) - These may appear in any position in the Triple
- Blank Nodes (aka Anonymous Resources) - These may appear as the Subject/Object of a Triple
- Literals - These may appear only as the Object of a Triple
When you start talking about classes you are no longer talking pure RDF as you are brining in a schema language like RDFS or OWL which define the notion of classes. The main reason for using these higher level schema languages is that it allows you to define restrictions and relationships more clearly and perhaps use some reasoning over those.
Regardless of whether something is a Class the only restrictions on where it can appear in a triple are the term type. So for example I could write the following:
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix ex: <http://example.org/> .
ex:Thing a rdfs:Class .
ex:this ex:Thing ex:that .
That's perfectly legal RDF it just doesn't necessarily actually express data that makes any sense to anyone!
精彩评论