-
Notifications
You must be signed in to change notification settings - Fork 0
MetaMapping
Meta Mapping is a feature introduced in -ontop- 1.9. This feature allows users to put variables in the target of mapping without restriction. This implies that class and property names can be loaded from the database dynamically with meta mapping. For example, the following mapping, which was invalid before as a normal mapping, is now a valid meta mapping.
?x rdf:type ?y SELECT x, y FROM table
The syntax of meta mapping is the same with the normal mapping, except that there is no restriction on the usage of variables. For example, the following two mappings are valid meta mappings.
mappingId mapping1 target {uri} a :{value}_{code} . source SELECT value, uri, code FROM table1 where code > 0
mappingId mapping2 target {uri} :{role}_{code} {value} . source SELECT value, uri, code, role FROM table1 where code > 0
With meta mappings, the class and property names can be constructed from the database, which is similar to the individuals in the normal mapping.
Continue with the example mappings. Suppose we have a table named table1 as follows.
uri | value | code | role |
---|---|---|---|
'uri1' | 'A' | '1' | 'P' |
'uri2' | 'B' | '2' | 'P' |
'uri3' | 'A' | '2' | 'Q' |
'uri4' | 'B' | '2' | 'Q' |
uri1 a :A_1 . uri2 a :B_2. uri3 a :A_2 . uri4 a :B_2 .
And mapping2 will generate triples:
uri1 :P_1 A . uri2 :P_2 B . uri3 :Q_2 A . uri4 :Q_2 B .
The implementation of meta mappings is by meta mapping expansion, which expands a given meta mapping as a template to a set of normal mappings based on the data in the database.
For example, to expand mapping1
mappingId mapping1 target {uri} a :{value}_{code} . source SELECT value, uri, code FROM table1 where code > 0the expander first queries what can be replaced for value and code by the SQL query:
SELECT DISTINCT value, code FROM table1 where code > 0
There are three results:
value | code |
---|---|
'A' | '1' |
'B' | '2' |
'A' | '2' |
target {uri} a :A_1 . source SELECT uri FROM table1 where code > 0 AND value = 'A' AND code = '1'
target {uri} a :B_2 . source SELECT uri FROM table1 where code > 0 AND value = 'B' AND code = '2'
target {uri} a :A_2 . source SELECT uri FROM table1 where code > 0 AND value = 'A' AND code = '2'
Finally, the meta mapping is replaced by the normal mappings and the original meta mapping is removed internally. Quest then handle the expanded mappings as before.
- Quick Start Guide
- Easy-Tutorials
- More Tutorials
- Examples
- FAQ
- Using Ontop
- Learning more
- Troubleshooting
- Developer Guides
- Links