I want to express some many to many relatinships from a database in RDF format. For example user A rated Item B with value C.

How I have to express a many to many relationship in rdf?

I am thinking of using a blank node.


user:1 item:ratting [ _:1 item:id "5";item:ratting-number "10".] In order to express that user 1 rated item 5 with 10. Is there a better way to do that?

asked 22 Feb '13, 18:09

nikosdi's gravatar image

accept rate: 0%

edited 22 Feb '13, 18:10

The approach you suggest is certainly a good option. Another popular approach is treating the relation as an object, e.g. for your example:

   _:1 a :item:Rating; 
       item:user user:1;
       item:id "5";
       item:rating-number "10" .

Though in this approach I would personally choose to create a new URI for the rating-object, rather than using a blank node, e.g. 'item:rating1'.

There is a W3C Note that discusses several approaches to modeling n-ary relations in RDF, which might be worth looking into.

permanent link

answered 22 Feb '13, 18:17

Jeen%20Broekstra's gravatar image

Jeen Broekstra ♦
accept rate: 37%

Thank you for your imidiate response! I was thinking to use a blank node because I dont have an actual URI for the relation

(22 Feb '13, 18:21) nikosdi nikosdi's gravatar image

Well, you certainly can use blank nodes, nothing wrong with that in principle, but not having a URI is no excuse: simply create one on the fly :)

(22 Feb '13, 18:26) Jeen Broekstra ♦ Jeen%20Broekstra's gravatar image
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 22 Feb '13, 18:09

question was seen: 1,679 times

last updated: 24 Feb '13, 06:35