Exmaples RDF application

click here for RDF tables
click here for RDF table:post
click here for RDF table:post record 7
click here for RDF table:post record 8
click here for RDF table:comment
click here for RDF table:comment record 7
click here for RDF table:comment record 8
click here for RDF table:tag
click here for RDF table:tag record 7
click here for RDF table:tag record 8

Code to generate the above links

1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
69.
70.
71.
72.
73.
74.
75.
76.
77.
78.
79.
80.
81.
82.
83.
84.
85.
86.
87.
88.
89.
90.
91.
92.
db.rdf_namespaces = {'_xmlns:rdf':"http://www.w3.org/1999/02/22-rdf-syntax-ns#", 
'_xmlns:relational':"http://www.dbs.cs.uni-duesseldorf.de/RDF/relational.owl#"
}

db.define_table('post',
Field('author', 'string'),
Field('title', 'string'),
Field('body', 'text'))

#db.post.author.rdf = 'sioc:has_creator'
db.post.title.rdf = 'dc:title'
db.post.body.rdf = 'sioc:content'
db.post.author.rdf = { 'name':'sioc:has_creator',
'children': [ { 'name':'sioc:User',
'_rdf:about':'http://chrisbaron.com',
'_rdf:label':'$VALUE',
'children': [ { 'name':'rdf:seeAlso',
'_rdf:resource':'http://web2py.com'
} ]
} ]
}


db.post.rdf = {
'type': 'http://rdfs.org/sioc/ns#Post',
'references': { 'comment': 'sioc:has_reply' },
'namespaces': {
"_xmlns:dc":"http://purl.org/dc/elements/1.1/",
"_xmlns:sioc":"http://rdfs.org/sioc/ns#"
}
}

db.define_table('comment',
Field('post_id', db.post),
Field('author', 'string'),
Field('body', 'text'))

db.comment.author.rdf = 'sioc:has_creator'
db.comment.body.rdf = 'sioc:content'

db.comment.rdf = {
'type': 'http://rdfs.org/sioc/ns#Post',
'namespaces': { "_xmlns:sioc":"http://rdfs.org/sioc/ns#" }
}

db.define_table('tag',
Field('name', 'string'))

db.tag.name.rdf = 'sioc:content'

db.tag.rdf = {
'type': 'http://rdfs.org/sioc/ns#topic',
'namespaces': { "_xmlns:sioc":"http://rdfs.org/sioc/ns#" }
}

db.define_table('post_tag_link',
Field('post_id', db.post),
Field('tag_id', db.tag),
Field('ranking', 'integer'))

db.post_tag_link.rdf_mapping = { 'post': { 'reference': 'sioc:topic',
'columns': { 'ranking': 'sioc:tagRank' } } }

if not db(db.post.id>0).count():
post_id_1 = db.post.insert(author = "Chris Baron",
title = "How To Publish RDF Using web2py",
body = "How To Publish RDF Using web2py, really")

post_id_2 = db.post.insert(author = "Massimo Di Pierro",
title = "How To Create a Web Application",
body = "Use web2py.")

db.comment.insert(post_id = post_id_1,
author = "Jon Doe",
body = "I like your post")

db.comment.insert(post_id = post_id_2,
author = "Jane Doe",
body = "I don't like your post")

tag_id_1 = db.tag.insert(name = "RDF")
tag_id_2 = db.tag.insert(name = "web2py")

db.post_tag_link.insert(post_id = post_id_1,
tag_id = tag_id_1,
ranking = 10)

db.post_tag_link.insert(post_id = post_id_2,
tag_id = tag_id_2,
ranking = 5)