Jéjé
Jéjé

Reputation: 115

Represent class and properties with RDFS

I want to represent this with RDFS:
- A book has a title and an author
- An author has a name

I tried this:

<rdf:RDF
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" >

    <rdf:Description rdf:ID="Book"> 
        <rdf:type rdf:resource="http://www.w3.org/…/rdf-schema#Class"/> 
    </rdf:Description>

    <rdf:Property rdf:ID="titleBook"> 
        <rdfs:domain rdf:resource="#Book"/> 
        <rdfs:range rdf:resource="xmlns:rdfsLiteral"/>
    </rdf:Property>

    <rdf:Property rdf:ID="authorBook"> 
        <rdfs:domain rdf:resource="#Book"/> 
        <rdfs:range rdf:resource="#Author"/>
    </rdf:Property>

    <rdf:Description rdf:ID="Author"> 
        <rdf:type rdf:resource="http://www.w3.org/…/rdf-schema#Class"/> 
    </rdf:Description>

    <rdf:Property rdf:ID="nameAuthor"> 
        <rdfs:domain rdf:resource="#Author"/> 
        <rdfs:range rdf:resource="xmlns:rdfsLiteral"/>
    </rdf:Property>

But I'm not sure, I'm confused between domain and range.
How to represent that a book contains an author (a class in a class) with RDFS ?

Thank you.

Upvotes: 1

Views: 851

Answers (1)

Joshua Taylor
Joshua Taylor

Reputation: 85923

But I'm not sure, I'm confused between domain and range.

When a property p has a domain D, it means that whenever you have a triple

x p y

then x is an instance of D. When a property p has a range R, it means that whenever you have a triple

x p y

then y is an instance of R. For instance, if you have:

ex:hasTitle rdfs:domain ex:Book

then from

:dickens1859 ex:hasTitle "A Tale of Two Cities"@en

you can infer that:

:dickens1859 rdf:type ex:Book

How to represent that a book contains an author (a class in a class) with RDFS ?

Classes in RDFS are not the same as classes in an object oriented programming language. Classes are much more like sets in set theory. In RDFS, you can declare Book and Author classes, and declare a hasAuthor property with domain Book and range Author:

ex:Book a rdfs:Class .
ex:Author a rdfs:Class .
ex:hasAuthor rdfs:domain ex:Book ;
             rdfs:range ex:Author .

If you want to say that every instance of Book has at least one author, you'd need to use a more powerful language than RDFS. For instance, you can use OWL, where you can say that "every book has an author" (that is, "at least one author") with an axiom like:

Book ⊑ ∃ hasAuthor.Author

Upvotes: 2

Related Questions