index.html
148 KB
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="EN" xml:lang="EN">
<head>
<title>R2RML: RDB to RDF Mapping Language</title>
<meta name="RCS-Id" content=
"$Id: Overview.html,v 1.3 2011/09/20 13:14:52 denis Exp $" />
<link rel="stylesheet" type="text/css" href=
"http://www.w3.org/StyleSheets/TR/W3C-WD.css" />
<style type="text/css">
/*<![CDATA[*/
dfn { color: navy; font-weight: bold; }
pre { margin-left: 0; padding: 0 2em; }
dt { margin-top: 0.8em; }
th, td { padding: 0.3em 0.5em; }
cite { font-style: normal }
th { text-align: left; }
h2, h3 { margin-top: 2em; }
em.rfc2119 { text-transform: lowercase; font-variant: small-caps; font-style: normal; }
.figure { margin: 2em 0; text-align: center; }
.figure .caption { margin-top: 1.6em; }
table.term-index th code { font-weight: normal; }
table.term-index th, table.term-index td { padding: 0.1em 0.5em; }
.issue { background-color: #fdd; border: 1px solid #800; margin: 1em 0em; padding: 1em; page-break-inside: avoid ; font-style: italic; }
.issue a.tracker { font-style: normal; font-weight: bold; }
.note { background: #e2fff0; border: 2px solid #cff6d9; margin: 1em 0em 0em; padding: 1em; }
.note:before { background: #fff; border: 1px solid #cff6d9; content: "Note"; display: block; font-weight: bold; margin: -1.5em 0 0.5em 0; padding: 0.2em 0.8em; width: 2.5em; }
.ex-data, table.ex-data th, table.ex-data td { background: #cee; border: 1px solid #acc; }
table.ex-data { border-collapse: collapse; margin-bottom: 1.5em; }
table.ex-data caption, table.ex-data th, table.ex-data td { font-family: monospace; }
table.ex-data caption, table.ex-data th { font-size: 125%; }
table.ex-data caption { font-weight: bold; }
table.ex-data th small, table.ex-data caption small { display: block; font-size: 65%; font-weight: normal; }
pre.vocab, pre.ex-mapping, pre.ex-output, pre.ex-sql { margin-top: 1.5em; padding: 1em; }
pre.vocab:before, pre.ex-mapping:before, pre.ex-output:before, pre.ex-sql:before { background: white; display: block; font-family: sans-serif; font-size: 90%; margin: -1.7em 0 0.5em 0; padding: 0.2em 0.4em; }
pre.vocab { background: #d4dddd; }
pre.vocab, pre.vocab:before { border: 1px solid #bbb; }
pre.vocab:before { color: #888; content: "R2RML vocabulary definition"; width: 13em; }
pre.ex-mapping, pre.ex-sql { background: #eeb; }
pre.ex-mapping, pre.ex-mapping:before, pre.ex-sql, pre.ex-sql:before { border: 1px solid #cc9; }
pre.ex-mapping:before { color: #996; content: "Example R2RML mapping"; width: 12em; }
pre.ex-sql:before { color: #996; content: "Example SQL query"; width: 9em; }
.ex-output { background: #cfc; }
.ex-output, .ex-output:before, .ex-output th, .ex-output td { border: 1px solid #aca; }
pre.ex-output:before { color: #797; content: "Example output data"; width: 9.5em; }
.toc ul { list-style-type: none; }
.toc > li { font-weight: bold; margin-bottom: 0.8em; }
.toc li li { font-weight: normal; }
/*]]>*/
</style>
</head>
<body>
<div class="head">
<p><a href="http://www.w3.org/"><img src="http://www.w3.org/Icons/w3c_home" alt="W3C"
height="48" width="72" /></a></p>
<h1><a name="title" id="title"></a>R2RML: RDB to RDF Mapping Language</h1>
<h2><a name="w3c-doctype" id="w3c-doctype"></a><em>W3C Working Draft 20 September 2011</em></h2>
<dl>
<dt>This version:</dt>
<dd><a href="http://www.w3.org/TR/2011/WD-r2rml-20110920/">http://www.w3.org/TR/2011/WD-r2rml-20110920/</a></dd>
<dt>Latest Editor's Draft:</dt>
<dd><a href=
"http://www.w3.org/2001/sw/rdb2rdf/r2rml/">http://www.w3.org/2001/sw/rdb2rdf/r2rml/</a></dd>
<dt>Latest published version:</dt>
<dd><a href="http://www.w3.org/TR/r2rml/">http://www.w3.org/TR/r2rml/</a></dd>
<dt>Previous version:</dt>
<dd><a href=
"http://www.w3.org/TR/2011/WD-r2rml-20110324/">http://www.w3.org/TR/2011/WD-r2rml-20110324/</a></dd>
<dt>Editors:</dt>
<dd>Souripriya Das, Oracle</dd>
<dd>Seema Sundara, Oracle</dd>
<dd>Richard Cyganiak, DERI, National University of Ireland, Galway</dd>
</dl>
<p class="copyright"><a href=
"http://www.w3.org/Consortium/Legal/ipr-notice#Copyright">Copyright</a> ©
2011 <a href="http://www.w3.org/"><acronym title=
"World Wide Web Consortium">W3C</acronym></a><sup>®</sup> (<a href=
"http://www.csail.mit.edu/"><acronym title=
"Massachusetts Institute of Technology">MIT</acronym></a>, <a href=
"http://www.ercim.eu/"><acronym title=
"European Research Consortium for Informatics and Mathematics">ERCIM</acronym></a>,
<a href="http://www.keio.ac.jp/">Keio</a>), All Rights Reserved. W3C <a href=
"http://www.w3.org/Consortium/Legal/ipr-notice#Legal_Disclaimer">liability</a>,
<a href="http://www.w3.org/Consortium/Legal/ipr-notice#W3C_Trademarks">trademark</a>
and <a href="http://www.w3.org/Consortium/Legal/copyright-documents">document use</a>
rules apply.</p>
</div>
<hr />
<h2><a name="abstract" id="abstract"></a>Abstract</h2>
<p>This document describes R2RML, a language for expressing customized mappings from
relational databases to RDF datasets. Such mappings provide the ability to view
existing relational data in the RDF data model, expressed in a structure and target
vocabulary of the mapping author's choice. R2RML mappings are themselves RDF graphs and
written down in Turtle syntax. R2RML enables different types of mapping
implementations. Processors could, for example, offer a virtual SPARQL endpoint over
the mapped relational data, or generate RDF dumps, or offer a Linked Data
interface.</p>
<div>
<h2><a name="status" id="status"></a>Status of this Document</h2>
<p><em>This section describes the status of this document at the time of its
publication. Other documents may supersede this document. A list of current W3C
publications and the latest revision of this technical report can be found in the
<a href="http://www.w3.org/TR/">W3C technical reports index</a> at
http://www.w3.org/TR/.</em></p>
<p>This document is a <a href="http://www.w3.org/2005/10/Process-20051014/tr.html#last-call">Last Call Working Draft</a> of the "R2RML: RDB to RDF Mapping Language". Publication as a Last Call Working Draft indicates that the <a href="http://www.w3.org/2001/sw/rdb2rdf/">RDB2RDF Working Group</a> believes it has addressed all substantive issues and that the document is stable. The Working Group expects to advance this specification to <a href="http://www.w3.org/2004/02/Process-20040205/tr.html#RecsW3C">Recommendation Status</a>.</p><p>Comments on this document should be sent to <a href="mailto:public-rdb2rdf-comments@w3.org">public-rdb2rdf-comments@w3.org</a>, a mailing list with
a <a href="http://lists.w3.org/Archives/Public/public-rdb2rdf-comments/">public archive</a>. Comments on this working draft are due on or before <strong>1 November 2011</strong>. </p>
<p>Publication as a Working Draft does not imply endorsement by the W3C Membership.
This is a draft document and may be updated, replaced or obsoleted by other documents
at any time. It is inappropriate to cite this document as other than work in
progress.</p>
<p>This document was produced by the
<a href="http://www.w3.org/2001/sw/rdb2rdf/">W3C RDB2RDF Working Group</a>.
R2RML has changed significantly since the previous Working Draft. Much of the
document has been rewritten, many terms were renamed and other design details
have changed. New language features include
a detailed
account of the <a href="#datatype-conversions">conversion of SQL datatypes
to RDF</a>. The <a href="#generated-rdf">triples in the output dataset</a>
are now more accurately specified. One major open question remains, and the
working group seeks feedback on it: should
R2RML processors be <a href="#syntax">required to support the Turtle
syntax</a>? Apart from this, the working group anticipates no major further
changes.</p>
<p>This document was produced by a group operating under the <a href=
"http://www.w3.org/Consortium/Patent-Policy-20040205/">5 February 2004 W3C Patent
Policy</a>. W3C maintains a <a rel="disclosure" href=
"http://www.w3.org/2004/01/pp-impl/43889/status">public list of any patent
disclosures</a> made in connection with the deliverables of the group; that page also
includes instructions for disclosing a patent. An individual who has actual knowledge
of a patent which the individual believes contains <a href=
"http://www.w3.org/Consortium/Patent-Policy-20040205/#def-essential">Essential
Claim(s)</a> must disclose the information in accordance with <a href=
"http://www.w3.org/Consortium/Patent-Policy-20040205/#sec-Disclosure">section 6 of
the W3C Patent Policy</a>.</p>
</div>
<div class="toc">
<h2><a name="contents" id="contents"></a>Table of Contents</h2>
<ul class="toc">
<li><a href="#introduction">1 Introduction</a>
<ul>
<li><a href="#conventions">1.1 Document Conventions</a></li>
</ul></li>
<li><a href="#overview">2 R2RML Overview and Example (Informative)</a>
<ul>
<li><a href="#example-input-database">2.1 Example Input Database</a></li>
<li><a href="#desired-rdf">2.2 Desired RDF Output</a></li>
<li><a href="#example-simple">2.3 Example: Mapping a Simple Table</a></li>
<li><a href="#example-r2rml-view">2.4 Example: Computing a Property with an R2RML View</a></li>
<li><a href="#example-fk">2.5 Example: Linking Two Tables</a></li>
<li><a href="#example-m2m">2.6 Example: Many-to-Many Tables</a></li>
</ul></li>
<li><a href="#conformance">3 Conformance</a></li>
<li><a href="#definitions">4 R2RML Processors and Mapping Documents</a>
<ul>
<li><a href="#vocabulary">4.1 Mapping Graphs and the R2RML Vocabulary</a></li>
<li><a href="#syntax">4.2 RDF-based Turtle Syntax; Media Type</a></li>
<li><a href="#data-errors">4.3 Data Errors</a></li>
</ul></li>
<li><a href="#logical-tables">5 Defining Logical Tables</a>
<ul>
<li><a href="#physical-tables">5.1 Base Tables and SQL Views (<code>rr:tableName</code>)</a></li>
<li><a href="#r2rml-views">5.2 R2RML Views (<code>rr:sqlQuery</code>)</a></li>
</ul></li>
<li><a href="#triples-map">6 Mapping Logical Tables to RDF with Triples Maps</a>
<ul>
<li><a href="#subject-map">6.1 Creating Resources with Subject Maps</a></li>
<li><a href="#typing">6.2 Typing Resources (<code>rr:class</code>)</a></li>
<li><a href="#predicate-object-map">6.3 Creating Properties and Values with Predicate-Object Maps</a></li>
</ul></li>
<li><a href="#term-map">7 Creating RDF Terms with Term Maps</a>
<ul>
<li><a href="#constant">7.1 Constant RDF Terms (<code>rr:constant</code>)</a></li>
<li><a href="#from-column">7.2 From a Column (<code>rr:column</code>)</a></li>
<li><a href="#from-template">7.3 From a Template (<code>rr:template</code>)</a></li>
<li><a href="#termtype">7.4 IRIs, Literal, Blank Nodes (<code>rr:termType</code>)</a></li>
<li><a href="#language-tags">7.5 Language Tags (<code>rr:language</code>)</a></li>
<li><a href="#typed-literals">7.6 Typed Literals (<code>rr:datatype</code>)</a></li>
<li><a href="#inverse">7.7 Inverse Expressions (<code>rr:inverseExpression</code>)</a></li>
</ul></li>
<li><a href="#foreign-key">8 Foreign Key Relationships among Logical Tables (<code>rr:parentTriplesMap</code>, <code>rr:joinCondition</code>, <code>rr:child</code> and <code>rr:parent</code>)</a></li>
<li><a href="#named-graphs">9 Assigning Triples to Named Graphs</a>
<ul>
<li><a href="#blank-nodes">9.1 Scope of Blank Nodes</a></li>
</ul></li>
<li><a href="#datatype-conversions">10 Datatype Conversions</a>
<ul>
<li><a href="#datatype-table">10.1 Table of Corresponding Datatypes</a></li>
<li><a href="#to-string">10.2 Conversion to String</a></li>
<li><a href="#to-boolean">10.3 Conversion to <code>xsd:boolean</code></a></li>
<li><a href="#datetime">10.4 Conversion to Datetime</a></li>
<li><a href="#binary">10.5 Conversion to <code>xsd:base64Binary</code></a></li>
</ul></li>
<li><a href="#generated-rdf">11 The Output Dataset</a>
<ul>
<li><a href="#generated-triples">11.1 The Generated RDF Triples of a Triples Map</a></li>
<li><a href="#generated-rdf-terms">11.2 The Generated RDF Terms of a Term Map</a></li>
</ul></li>
<li><a href="#terminology">A. RDF Terminology (Informative)</a></li>
<li><a href="#index">B. Index of R2RML Vocabulary Terms (Informative)</a>
<ul>
<li><a href="#class-index">B.1 Classes</a></li>
<li><a href="#property-index">B.2 Properties</a></li>
<li><a href="#other-index">B.3 Other Terms</a></li>
</ul></li>
<li><a href="#references">C. References</a>
<ul>
<li><a href="#normative-refs">C.1 Normative References</a></li>
<li><a href="#non-normative-refs">C.2 Other References</a></li>
</ul></li>
<li><a href="#acknowledgements">D. Acknowledgements (Informative)</a></li>
</ul>
</div>
<hr />
<div class="body">
<h2><a name="introduction" id="introduction"></a>1 Introduction</h2>
<p>This specification describes R2RML, a language for expressing customized mappings
from relational databases to RDF datasets. Such mappings provide the ability to view
existing relational data in the RDF data model, expressed in a structure and target
vocabulary of the mapping author's choice.</p>
<p>This specification has a companion that defines <cite><a class="inform"
href="http://www.w3.org/TR/2011/WD-rdb-direct-mapping-20110920/">a direct mapping
from relational databases to RDF</a></cite> [<cite><a href="#DM">DM</a></cite>].
In the direct mapping of a database, the
structure of the resulting RDF graph directly reflects the structure of the database,
the target RDF vocabulary directly reflects the names of database schema elements,
and neither structure nor target vocabulary can be changed. With R2RML on the other
hand, a mapping author can define highly customized views over the relational
data.</p>
<p>Every R2RML mapping is tailored to a specific database schema and target
vocabulary. The input to an R2RML mapping is a relational database that conforms to
that schema. The output is an <cite><a class="norm" href=
"http://www.w3.org/TR/2008/REC-rdf-sparql-query-20080115/#rdfDataset">RDF
dataset</a></cite> [<cite><a href="#SPARQL">SPARQL</a></cite>], as defined in SPARQL,
that uses predicates and types from the target vocabulary. The mapping is conceptual;
R2RML processors are free to materialize the output data, or to offer virtual access
through an interface that queries the underlying database, or to offer any other
means of providing access to the output RDF dataset.</p>
<p>R2RML mappings are themselves expressed as RDF graphs and written down in
<cite><a class="norm" href=
"http://www.w3.org/TeamSubmission/2008/SUBM-turtle-20080114/">Turtle
syntax</a></cite> [<cite><a href="#TURTLE">TURTLE</a></cite>].</p>
<p>The intended audience of this specification is implementors of software
that
generates or processes R2RML mapping documents, as well as mapping authors looking
for a reference to the R2RML language constructs. The document uses concepts from
<cite><em><a class="norm" href=
"http://www.w3.org/TR/2004/REC-rdf-concepts-20040210/">RDF Concepts and Abstract
Syntax</a></em></cite> [<cite><a href="#RDF">RDF</a></cite>] and from the <cite>SQL
language specifications</cite> [<cite><a href="#SQL1">SQL1</a></cite>][<cite><a href=
"#SQL2">SQL2</a></cite>]. A reader's familiarity with the contents of these
documents, as well as with the Turtle syntax, is assumed.</p>
<p>The R2RML language is designed to meet the use cases and requirements identified
in <cite><em><a class="inform" href=
"http://www.w3.org/TR/2010/WD-rdb2rdf-ucr-20100608/">Use Cases and Requirements for
Mapping Relational Databases to RDF</a></em></cite> [<cite><a href=
"#UCNR">UCNR</a></cite>].</p>
<h3 id="conventions">1.1 Document Conventions</h3>
<p>In this document, examples assume the following namespace prefix bindings unless
otherwise stated:</p>
<table rules="all" summary="list of prefixes used in the document">
<tr>
<th>Prefix</th>
<th>IRI</th>
</tr>
<tr>
<td><code>rr:</code></td>
<td><code>http://www.w3.org/ns/r2rml#</code></td>
</tr>
<tr>
<td><code>rdf:</code></td>
<td><code>http://www.w3.org/1999/02/22-rdf-syntax-ns#</code></td>
</tr>
<tr>
<td><code>rdfs:</code></td>
<td><code>http://www.w3.org/2000/01/rdf-schema#</code></td>
</tr>
<tr>
<td><code>xsd:</code></td>
<td><code>http://www.w3.org/2001/XMLSchema#</code></td>
</tr>
<tr>
<td><code>ex:</code></td>
<td><code>http://example.com/ns#</code></td>
</tr>
</table>
<p>Throughout the document, boxes containing Turtle markup and SQL data will appear.
These boxes are color-coded. Gray boxes contain RDFS definitions of R2RML vocabulary
terms:</p>
<pre class="vocab">
# This box contains RDFS definitions of R2RML vocabulary terms
</pre>
<p>Yellow boxes contain example fragments of R2RML mappings in Turtle syntax:</p>
<pre class="ex-mapping">
# This box contains example R2RML mappings
</pre>
<p>Blue tables contain example input into an R2RML mapping:</p>
<table class="ex-data">
<caption>EXAMPLE</caption>
<tr><th>ID <small>INTEGER PRIMARY KEY</small></th><th>DESC <small>VARCHAR(100)</small></th></tr>
<tr><td>1</td><td>This is an example input table.</td></tr>
<tr><td>2</td><td>The table name is EXAMPLE.</td></tr>
<tr><td>3</td><td>It has six rows.</td></tr>
<tr><td>4</td><td>It has two columns, ID and DESC.</td></tr>
<tr><td>5</td><td>ID is the table's primary key and of type INTEGER.</td></tr>
<tr><td>6</td><td>DESC is of type VARCHAR(100)</td></tr>
</table>
<p>Green boxes contain example output:</p>
<pre class="ex-output">
# This box contains example output RDF triples or fragments
</pre>
<h2 id="overview">2 R2RML Overview and Example (Informative)</h2>
<p>This section gives a brief overview of the R2RML mapping language,
followed by a simple example relational database with an
R2RML mapping document and its output RDF. Further R2RML examples can
be found in the
<cite><em><a class="inform" href="http://www.w3.org/2001/sw/rdb2rdf/test-cases/">R2RML and Direct Mapping Test Cases</a></em></cite>
[<cite><a href="#TC">TC</a></cite>].</p>
<p>An <a href="#dfn-r2rml-mapping">R2RML mapping</a> refers to
<a href="#dfn-logical-table">logical tables</a> to retrieve
data from the <a href="#dfn-input-database">input database</a>.
A logical table can be one of the following:</p>
<ol>
<li>A base table,</li>
<li>a view, or</li>
<li>a valid SQL query (called an
“<a href="#dfn-r2rml-view">R2RML view</a>” because it
emulates a SQL view without modifying the database).</li>
</ol>
<p>Each logical table is mapped to RDF using a
<a href="#dfn-triples-map">triples map</a>. The triples map is
a rule that maps each <a href="#dfn-logical-table-row">row in the
logical table</a> to a number of <a href="#dfn-rdf-triple">RDF triples</a>.
The rule has two main parts:</p>
<ol>
<li>A <a href="#dfn-subject-map">subject map</a> that generates the subject
of all RDF triples that will be generated from a logical table row.</li>
<li>Multiple <a href="#dfn-predicate-object-map">predicate-object maps</a>
that in turn consist of <a href="#dfn-predicate-map">predicate maps</a> and
<a href="#dfn-object-map">object maps</a>
(or <a href="#dfn-referencing-object-map">referencing object maps</a>).
</li>
</ol>
<p>Triples are produced by combining the subject map with a predicate
map and object map, and applying these three to each
<a href="#dfn-logical-table-row">logical table row</a>. For example, the
complete rule for generating a set of triples might be:</p>
<ul>
<li><strong>Subjects:</strong> A template <code>http://data.example.com/employee/{empno}</code> is used to generate subject <a href="#dfn-iri">IRIs</a> from the <code>empno</code> column.</li>
<li><strong>Predicates:</strong> The constant vocabulary <a href="#dfn-iri">IRI</a> <code>ex:name</code> is used.</li>
<li><strong>Objects:</strong> The value of the <code>ename</code> column is used to produce an <a href="#dfn-literal">RDF literal</a>.</li>
</ul>
<p>By default, all <a href="#dfn-rdf-triple">RDF triples</a> are in the
<a href="#dfn-default-graph">default graph</a> of the
<a href="#dfn-output-dataset">output dataset</a>.
A triples map can contain
<a href="#dfn-graph-map">graph maps</a>
that place some or all of the triples into
<a href="#dfn-named-graph">named graphs</a> instead.</p>
<div class="figure">
<img src="images/uml-overview.png" alt="UML overview diagram of R2RML"/>
<br /><br />
Figure 1: An overview of R2RML
</div>
<h3 id="example-input-database">2.1 Example Input Database</h3>
<p>The following example database consists of two tables,
<code>EMP</code> and <code>DEPT</code>, with one row each:</p>
<table class="ex-data" summary="EMP table: sample data" id="ex_EMP">
<caption>EMP</caption>
<tr>
<th>EMPNO <small>INTEGER PRIMARY KEY</small></th>
<th>ENAME <small>VARCHAR(100)</small></th>
<th>JOB <small>VARCHAR(20)</small></th>
<th>DEPTNO <small>INTEGER REFERENCES DEPT (DEPTNO)</small></th>
</tr>
<tr>
<td><code>7369</code></td>
<td><code>SMITH</code></td>
<td><code>CLERK</code></td>
<td><code>10</code></td>
</tr>
</table>
<table class="ex-data" summary="DEPT table: sample data" id="ex_DEPT">
<caption>DEPT</caption>
<tr>
<th>DEPTNO <small>INTEGER PRIMARY KEY</small></th>
<th>DNAME <small>VARCHAR(30)</small></th>
<th>LOC <small>VARCHAR(100)</small></th>
</tr>
<tr>
<td><code>10</code></td>
<td><code>APPSERVER</code></td>
<td><code>NEW YORK</code></td>
</tr>
</table>
<h3 id="desired-rdf">2.2 Desired RDF Output</h3>
<p>The desired RDF triples to be produced from this database are
as follows:</p>
<pre class="ex-output">
<http://data.example.com/employee/7369> rdf:type ex:Employee.
<http://data.example.com/employee/7369> ex:name "SMITH".
<http://data.example.com/employee/7369> ex:department <http://data.example.com/department/10>.
<http://data.example.com/department/10> rdf:type ex:Department.
<http://data.example.com/department/10> ex:name "APPSERVER".
<http://data.example.com/department/10> ex:location "NEW YORK".
<http://data.example.com/department/10> ex:staff 1.</pre>
<p>Note in particular:</p>
<ul>
<li>Construction of custom IRI identifiers for departments and employees;</li>
<li>use of a custom target vocabulary (<code>ex:Employee</code>, <code>ex:location</code> etc.);</li>
<li>the <code>ex:staff</code> property has the total number of staff of a department; this value is not stored directly in the database but has to be computed.</li>
<li>the <code>ex:department</code> property relates an employee to their department, using the identifiers of both entities;</li>
</ul>
<h3 id="example-simple">2.3 Example: Mapping a Simple Table</h3>
<p>The following partial R2RML mapping document will produce
the desired triples from the <a href="#ex_EMP"><code>EMP</code> table</a>
(except the
<code>ex:department</code> triple, which will be added later):</p>
<pre class="ex-mapping">
@prefix rr: <http://www.w3.org/ns/r2rml#>.
<#TriplesMap1>
rr:logicalTable [ rr:tableName "EMP" ];
rr:subjectMap [
rr:template "http://data.example.com/employee/{EMPNO}";
rr:class ex:Employee;
];
rr:predicateObjectMap [
rr:predicate ex:name;
rr:objectMap [ rr:column "ENAME" ];
].</pre>
<pre class="ex-output">
<http://data.example.com/employee/7369> rdf:type ex:Employee.
<http://data.example.com/employee/7369> ex:name "SMITH".</pre>
<h3 id="example-r2rml-view">2.4 Example: Computing a Property with an R2RML View</h3>
<p>Next, the <a href="#ex_DEPT"><code>DEPT</code> table</a> needs
to be mapped. Instead of using the table directly as the basis
for that mapping, an “<a href="#dfn-r2rml-view">R2RML view</a>”
will be defined based on a SQL query.
This allows computation of the staff number.
(Alternatively, one could define this view directly in the database.)</p>
<pre class="ex-sql">
<#DeptTableView> rr:sqlQuery """
SELECT DEPTNO,
DNAME,
LOC,
(SELECT COUNT(*) FROM EMP WHERE EMP.DEPTNO=DEPT.DEPTNO) AS STAFF
FROM DEPT;
""".
</pre>
<p>The definition of a triples map that generates the desired
<code>DEPT</code> triples based on this R2RML view follows.</p>
<pre class="ex-mapping">
<#TriplesMap2>
rr:logicalTable <#DeptTableView>;
rr:subjectMap [
rr:template "http://data.example.com/department/{DEPTNO}";
rr:class ex:Department;
];
rr:predicateObjectMap [
rr:predicate ex:name;
rr:objectMap [ rr:column "DNAME" ];
];
rr:predicateObjectMap [
rr:predicate ex:location;
rr:objectMap [ rr:column "LOC" ];
];
rr:predicateObjectMap [
rr:predicate ex:staff;
rr:objectMap [ rr:column "STAFF" ];
].</pre>
<pre class="ex-output">
<http://data.example.com/department/10> rdf:type ex:Department.
<http://data.example.com/department/10> ex:name "APPSERVER".
<http://data.example.com/department/10> ex:location "NEW YORK".
<http://data.example.com/department/10> ex:staff 1.</pre>
<h3 id="example-fk">2.5 Example: Linking Two Tables</h3>
<p>To complete the mapping document, the <code>ex:department</code>
triples need to be generated. Their subjects come from
the first triples map (<code><#TriplesMap1></code>),
the objects come from the second triples map
(<code><#TriplesMap2></code>).</p>
<p>This can be achieved by adding another <code>rr:predicateObjectMap</code>
to <code><#TriplesMap1></code>. This one uses the other triples map,
<code><#TriplesMap2></code>, as a <a href="#foreign-key">parent
triples map</a>:</p>
<pre class="ex-mapping"><#TriplesMap1>
rr:predicateObjectMap [
rr:predicate ex:department;
rr:objectMap [
rr:parentTriplesMap <#TriplesMap2>;
rr:joinCondition [
rr:child "DEPTNO";
rr:parent "DEPTNO";
];
];
].</pre>
<p>This performs a join between the <code>EMP</code> table and the
R2RML view, on the
<code>DEPTNO</code> columns. The objects will be generated from
the subject map of the parent triples map, yielding the desired
triple:</p>
<pre class="ex-output">
<http://data.example.com/employee/7369> ex:department <http://data.example.com/department/10>.</pre>
<p>This completes the R2RML mapping document. An R2RML processor will
generate the triples listed above from this mapping document.</p>
<h3 id="example-m2m">2.6 Example: Many-to-Many Tables</h3>
<p>A final example will assume that a many-to-many relationship exists between
the extended versions of <a href="#ex_EMP_m2m"><code>EMP</code> table</a> and the <a
href="#ex_DEPT_m2m"><code>DEPT</code> table</a> shown below. This
many-to-many relationship is captured by the content of
the <a href="#ex_EMP2DEPT"><code>EMP2DEPT</code> table</a>. The database consisting of
the <code>EMP</code>, <code>DEPT</code>, and <code>EMP2DEPT</code> tables are shown below:</p>
<table class="ex-data" summary="EMP table: sample data" id="ex_EMP_m2m">
<caption>EMP</caption>
<tr>
<th>EMPNO <small>INTEGER PRIMARY KEY</small></th>
<th>ENAME <small>VARCHAR(100)</small></th>
<th>JOB <small>VARCHAR(20)</small></th>
<th>DEPTNO <small>INTEGER REFERENCES DEPT (DEPTNO)</small></th>
</tr>
<tr>
<td><code>7369</code></td>
<td><code>SMITH</code></td>
<td><code>CLERK</code></td>
<td><code>10</code></td>
</tr>
<tr>
<td><code>7369</code></td>
<td><code>SMITH</code></td>
<td><code>NIGHTGUARD</code></td>
<td><code>20</code></td>
</tr>
<tr>
<td><code>7400</code></td>
<td><code>JONES</code></td>
<td><code>ENGINEER</code></td>
<td><code>10</code></td>
</tr>
</table>
<table class="ex-data" summary="DEPT table: sample data" id="ex_DEPT_m2m">
<caption>DEPT</caption>
<tr>
<th>DEPTNO <small>INTEGER PRIMARY KEY</small></th>
<th>DNAME <small>VARCHAR(30)</small></th>
<th>LOC <small>VARCHAR(100)</small></th>
</tr>
<tr>
<td><code>10</code></td>
<td><code>APPSERVER</code></td>
<td><code>NEW YORK</code></td>
</tr>
<tr>
<td><code>20</code></td>
<td><code>RESEARCH</code></td>
<td><code>BOSTON</code></td>
</tr>
</table>
<table class="ex-data" summary="EMP2DEPT table: sample data" id="ex_EMP2DEPT">
<caption>EMP2DEPT <small>PRIMARY KEY (EMPNO, DEPTNO)</small></caption>
<tr>
<th>EMPNO <small>INTEGER REFERENCES EMP (EMPNO)</small></th>
<th>DEPTNO <small>INTEGER REFERENCES DEPT (DEPTNO)</small></th>
</tr>
<tr>
<td><code>7369</code></td>
<td><code>10</code></td>
</tr>
<tr>
<td><code>7369</code></td>
<td><code>20</code></td>
</tr>
<tr>
<td><code>7400</code></td>
<td><code>10</code></td>
</tr>
</table>
<pre class="ex-output">
<http://data.example.com/employee=7369/department=10>
ex:employee <http://data.example.com/employee/7369> ;
ex:department <http://data.example.com/department/10> .
<http://data.example.com/employee=7369/department=20>
ex:employee <http://data.example.com/employee/7369> ;
ex:department <http://data.example.com/department/20> .
<http://data.example.com/employee=7400/department=10>
ex:employee <http://data.example.com/employee/7400> ;
ex:department <http://data.example.com/department/10> .
</pre>
<p>The following R2RML mapping will produce the desired triples listed above:</p>
<pre class="ex-mapping"><#TriplesMap3>
rr:tableName "EMP2DEPT";
rr:subjectMap [ rr:template "http://data.example.com/employee={EMPNO}/department={DEPTNO}" ];
rr:predicateObjectMap [
rr:predicate ex:employee;
rr:objectMap [ rr:template "http://data.example.com/employee/{EMPNO}" ; rr:termType rr:IRI ]
];
rr:predicateObjectMap [
rr:predicate ex:department;
rr:objectMap [ rr:template "http://data.example.com/department/{DEPTNO}" ; rr:termType rr:IRI ]
].
</pre>
<p>However, if one does <em>not</em> require that the subjects in
the desired output uniquely identify the rows in the <a
href="#ex_EMP2DEPT"><code>EMP2DEPT</code> table</a>, the desired output
may look as follows: </p>
<pre class="ex-output">
<http://data.example.com/employee/7369>
ex:department <http://data.example.com/department/10> ;
ex:department <http://data.example.com/department/20> .
<http://data.example.com/employee/7400>
ex:department <http://data.example.com/department/10>.
</pre>
<p>The following R2RML mapping will produce the desired triples:</p>
<pre class="ex-mapping"><#TriplesMap3>
rr:tableName "EMP2DEPT";
rr:subjectMap [
rr:template "http://data.example.com/employee/{EMPNO}";
];
rr:predicateObjectMap [
rr:predicate ex:department;
rr:objectMap [ rr:template "http://data.example.com/department/{DEPTNO}"; rr:termType rr:IRI ]
].</pre>
<h2 id="conformance">3 Conformance</h2>
<p>As well as sections marked as non-normative in the section heading,
all diagrams, examples, and notes in this specification are
non-normative. Everything else in this specification is normative.</p>
<p>The key words <em class="rfc2119">must</em>,
<em class="rfc2119">must not</em>, <em class="rfc2119">required</em>,
<em class="rfc2119">should</em>, <em class="rfc2119">should not</em>,
<em class="rfc2119">recommended</em>, <em class="rfc2119">may</em>,
and <em class="rfc2119">optional</em> in this specification are to be
interpreted as described in
<cite><a href="http://tools.ietf.org/html/rfc2119">RFC 2119</a></cite>
[<cite><a href="#RFC2119">RFC2119</a></cite>].</p>
<p>This specification describes conformance criteria for:</p>
<ul>
<li><a href="#dfn-r2rml-mapping-document">R2RML mapping documents</a></li>
<li><a href="#dfn-r2rml-mapping-graph">R2RML mapping graphs</a></li>
<li><a href="#dfn-r2rml-processor">R2RML processors</a></li>
<li><a href="#dfn-r2rml-data-validator">R2RML data validators</a></li>
</ul>
<p>A collection of test cases for R2RML processors and
R2RML data validators is available in the
<cite><em><a class="inform" href="http://www.w3.org/2001/sw/rdb2rdf/test-cases/">R2RML and Direct Mapping Test Cases</a></em></cite> [<cite><a href="#TC">TC</a></cite>].</p>
<p>This specification defines R2RML for databases that conform to
<em>Core SQL 2008</em>, as defined in
<cite><em>ISO/IEC 9075-1:2008</em></cite>
[<cite><a href="#SQL1">SQL1</a></cite>] and
<cite><em>ISO/IEC 9075-2:2008</em></cite>
[<cite><a href="#SQL2">SQL2</a></cite>].
Processors and mappings may have
to deviate from the R2RML specification in order to support databases
that do not conform to this version of SQL.</p>
<p>Where SQL queries are embedded into R2RML mappings,
<a href="#dfn-sql-version-identifier">SQL version identifiers</a>
can be used to indicate the specific version of SQL that is being used.</p>
<h2 id="definitions">4 R2RML Processors and Mapping Documents</h2>
<p>An <dfn id="dfn-r2rml-mapping">R2RML mapping</dfn> defines a mapping
from a relational database to RDF. It is a structure that consists of
one or more <a href="#dfn-triples-map">triples maps</a>.</p>
<p>The input to an R2RML mapping is called the
<dfn id="dfn-input-database">input database</dfn>.</p>
<p>An <dfn id="dfn-r2rml-processor">R2RML processor</dfn> is a system
that, given an <a href="#dfn-r2rml-mapping">R2RML mapping</a> and an
<a href="#dfn-input-database">input database</a>, provides access to
the <a href="#dfn-output-dataset">output dataset</a>.</p>
<p>There are no constraints on the method of access to the output
dataset provided by a conforming R2RML processor. An R2RML processor
<em class="rfc2119">MAY</em>
materialize the output dataset into a file, or offer virtual access
through an interface that queries the input database, or offer any
other means of providing access to the output dataset.</p>
<p>An <a href="#dfn-r2rml-processor">R2RML processor</a> also has access
to an execution environment consisting of:</p>
<ul>
<li>A <dfn id="dfn-sql-connection">SQL connection</dfn>
to the <a href="#dfn-input-database">input database</a>,</li>
<li>a <dfn id="dfn-base-iri">base IRI</dfn> used in resolving
relative IRIs produced by the R2RML mapping.</li>
</ul>
<p>The <a href="#dfn-sql-connection">SQL connection</a>
is used by the R2RML processor to evaluate SQL queries against the input
database. It <em class="rfc2119">MUST</em> be established
with sufficient privileges for read access to all base tables and views that are
referenced in the R2RML mapping. It <em class="rfc2119">MUST</em> be
configured with a <dfn id="dfn-default-catalog">default catalog</dfn>
and <dfn id="dfn-default-schema">default schema</dfn> that will be
used when tables and views are accessed without an explicit
catalog or schema reference.</p>
<p>How the SQL connection is established, or how users
are authenticated against the database, is outside of the scope of this document.</p>
<p>The <a href="#dfn-base-iri">base IRI</a> <em class="rfc2119">MUST</em>
be a valid <a href="#dfn-iri">IRI</a>. It <em class="rfc2119">SHOULD</em>
end in a slash (“<code>/</code>”) character.</p>
<p class="note">Resolution of relative IRIs in R2RML uses simple
string concatenation instead of the more complex algorithm defined in
RFC 3986. This ensures that the original database value can be
reconstructed from the generated IRI.</p>
<p>An <dfn id="dfn-r2rml-data-validator">R2RML data validator</dfn>
is a system that takes as its input an
<a href="#dfn-r2rml-mapping">R2RML mapping</a>, a
<a href="#dfn-base-iri">base IRI</a>, and a
<a href="#dfn-sql-connection">SQL connection</a> to an
<a href="#dfn-input-database">input database</a>, and checks for
the presence of <a href="#dfn-data-error">data errors</a>.
When checking the input database, a data validator
<em class="rfc2119">MUST</em> report any data errors that are raised
in the process of generating the output dataset.</p>
<p>An <a href="#dfn-r2rml-processor">R2RML processor</a>
<em class="rfc2119">MAY</em> include an
<a href="#dfn-r2rml-data-validator">R2RML data validator</a>, but this
is not required.</p>
<h3 id="vocabulary">4.1 Mapping Graphs and the R2RML Vocabulary</h3>
<p>An <a href="#dfn-r2rml-mapping">R2RML mapping</a> is represented
as an <a href="#dfn-rdf-graph">RDF graph</a>. In other words,
RDF is used not just as the target data model of the mapping, but also
as a formalism for representing the R2RML mapping itself.</p>
<p>An <a href="#dfn-rdf-graph">RDF graph</a> that represents an
<a href="#dfn-r2rml-mapping">R2RML mapping</a> is called an
<dfn id="dfn-r2rml-mapping-graph">R2RML mapping graph</dfn>.</p>
<p>The <dfn id="dfn-r2rml-vocabulary">R2RML vocabulary</dfn> is the
set of <a href="#dfn-iri">IRIs</a> defined in this specification
that start with the <code>rr:</code> namespace IRI:</p>
<pre><strong><a href="http://www.w3.org/ns/r2rml#">http://www.w3.org/ns/r2rml#</a></strong></pre>
<p>An <a href="#dfn-r2rml-mapping-graph">R2RML mapping graph</a>:</p>
<ul>
<li><em class="rfc2119">SHOULD NOT</em> include any
<a href="#dfn-iri">IRIs</a> that start with the <code>rr:</code>
namespace IRI, but are not defined in the
<a href="#dfn-r2rml-vocabulary">R2RML vocabulary</a>.</li>
<li><em class="rfc2119">SHOULD NOT</em> include
<a href="#dfn-iri">IRIs</a> from the
<a href="#dfn-r2rml-vocabulary">R2RML vocabulary</a> where
such use is not explicitly allowed or required by a clause in this
specification.</li>
<li><em class="rfc2119">SHOULD NOT</em> contain any
mapping components (<a href="#dfn-logical-table">logical tables</a>,
<a href="#dfn-term-map">term maps</a>,
<a href="#dfn-predicate-object-map">predicate-object maps</a>)
that are not referenced by a <a href="#dfn-triples-map">triples map</a>
(in other words, are “unused”).</li>
<li><em class="rfc2119">MAY</em> contain arbitrary additional
<a href="#dfn-rdf-triple">triples</a> whose terms are not
from the <a href="#dfn-r2rml-vocabulary">R2RML vocabulary</a>.
In particular, a valid mapping graph <em class="rfc2119">MAY</em>
contain documentation in the form of <code>rdfs:label</code>,
<code>rdfs:comment</code> and similar properties.</li>
<li><em class="rfc2119">MAY</em> assign <a href="#dfn-iri">IRIs</a>
or <a href="#dfn-blank-node-identifier">blank node identifiers</a>
to any mapping component in order to enable re-use of mapping components
within the mapping graph.
For example, an IRI that represents
a <a href="#dfn-subject-map">subject map</a> may be used as the subject
map of multiple <a href="#dfn-triples-map">triples maps</a>; and may
even be used as an <a href="#dfn-object-map">object map</a> of another
triples map if it has the right properties.</li>
</ul>
<p>The <a href="#dfn-r2rml-vocabulary">R2RML vocabulary</a> also
includes the following <dfn id="dfn-R2RML-classes">R2RML classes</dfn>,
which represent various R2RML mapping constructs. Using these
classes is <em class="rfc2119">OPTIONAL</em> in a mapping graph.
The applicable class of a resource can always be inferred from its
properties.</p>
<ul>
<li><code>rr:TriplesMap</code> is the class of
<a href="#dfn-triples-map">triples maps</a>.</li>
<li><code>rr:LogicalTable</code> is the class of
<a href="#dfn-logical-table">logical tables</a>.</li>
<li><code>rr:SubjectMap</code> is the class of
<a href="#dfn-subject-map">subject maps</a>.</li>
<li><code>rr:PredicateMap</code> is the class of
<a href="#dfn-predicate-map">predicate maps</a>.</li>
<li><code>rr:ObjectMap</code> is the class of
<a href="#dfn-object-map">object maps</a>.</li>
<li><code>rr:GraphMap</code> is the class of
<a href="#dfn-graph-map">graph maps</a>.</li>
<li><code>rr:PredicateObjectMap</code> is the class of
<a href="#dfn-predicate-object-map">predicate-object maps</a>.</li>
<li><code>rr:RefObjectMap</code> is the class of
<a href="#dfn-referencing-object-map">referencing object maps</a>.</li>
<li><code>rr:Join</code> is the class of
<a href="#dfn-join-condition">join conditions</a>.</li>
</ul>
<p class="note">Many of these classes differ only in capitalization from
properties in the <a href="#dfn-r2rml-vocabulary">R2RML vocabulary</a>.</p>
<h3 id="syntax">4.2 RDF-based Turtle Syntax; Media Type</h3>
<div class="issue">
<p><a class="tracker" href="http://www.w3.org/2001/sw/rdb2rdf/track/issues/57">ISSUE-57</a>:
<strong>Should R2RML require a specific syntax?</strong></p>
<p>The working group has proposed two alternate proposals for this issue:</p>
<ol>
<li>The R2RML mapping document specifies both the vocabulary and
the syntax. The R2RML document <em class="rfc2119">MUST</em> be a Turtle document and
R2RML processors <em class="rfc2119">MUST</em> support Turtle to be able to read such
documents. Conformance criteria requires support of R2RML
vocabulary written in Turtle.</li>
<li>The R2RML mapping document specifies only the
vocabulary. There is no syntax specified. There can be an
accompanying "R2RML mapping document in Turtle" that specifies the
Turtle syntax. Conformance criteria for the R2RML mapping
document requires supporting the vocabulary in any language
(Turtle, N-Triple, RDF/XML etc.) Additionally, if an
implementation supports the Turtle syntax, it can claim
conformance to the "R2RML mapping document in Turtle".</li>
</ol>
<p>The advantage of the first approach is that it promotes
interoperability between different producers and consumers of
R2RML files by requiring all to support at least one shared
syntax. Without such a shared syntax, an R2RML file created in one
tool may be rejected by another tool because both assume different
RDF syntaxes. R2RML examples found in educational material may not
work in actual implementations due to different syntaxes. This is
seen as an impediment to the uptake of R2RML.
</p>
<p>The second approach distinguishes between the R2RML vocabulary
and the syntax and wants to keep them separate. The advantage of
the second approach is that the R2RML mapping document remains
independent of any exchange format. This gives flexibility as
different syntax flavours of R2RML could be easily defined. It is
in the spirit of RDF as an abstract format. Users may have to
convert between different RDF syntaxes in order to use R2RML
files, but such conversion is not difficult and therefore not seen
as an impediment. Thereby, it allows conformance with the R2RML
mapping document using any of the standard exchange formats.
</p>
<p>There is consensus that Turtle should be used for the examples in
this document, as well as for the test cases.</p>
<p>The working group seeks comments and opinions on this question
and encourages reports to <a href="http://lists.w3.org/Archives/Public/public-rdb2rdf-comments/">public-rdb2rdf-comments mailing list</a>.</p>
</div>
<p>An <dfn id="dfn-r2rml-mapping-document">R2RML mapping document</dfn> is any document
written in the <cite><a class="norm" href=
"http://www.w3.org/TeamSubmission/2008/SUBM-turtle-20080114/">Turtle</a></cite>
[<cite><a href="#TURTLE">TURTLE</a></cite>] RDF syntax that encodes an
<a href="#dfn-r2rml-mapping-graph">R2RML mapping graph</a>.</p>
<p>The media type for <a href="#dfn-r2rml-mapping-document">R2RML mapping
documents</a> is the same as for Turtle
documents in general: <code>text/turtle</code>. The content encoding of
Turtle content is always UTF-8 and the <code>charset</code> parameter
on the media type <em class="rfc2119">SHOULD</em> always be used:
<code>text/turtle;charset=utf-8</code>. The preferred file extension is
<code>.ttl</code>.</p>
<p>A conforming <a href="#dfn-r2rml-processor">R2RML processor</a>
<em class="rfc2119">MUST</em> accept <a href="#dfn-r2rml-mapping-document">
R2RML mapping documents</a> in Turtle syntax.
It <em class="rfc2119">MAY</em> accept
<a href="#dfn-r2rml-mapping-graph">R2RML mapping graphs</a> encoded in
other RDF syntaxes.</p>
<div class="note">
<p>It is common to use document-local IRIs in mapping documents by
defining the default prefix in the beginning of the document, and
using it for creating IRIs for mapping components such as triples maps:</p>
<pre>@prefix : <#>
…
:EmpQuery rr:sqlQuery """SELECT * FROM EMP WHERE …""".
…
:EmpTriples rr:logicalTable :EmpQuery.</pre>
</div>
<h3 id="data-errors">4.3 Data Errors</h3>
<p>A <dfn id="dfn-data-error">data error</dfn> is a condition
of the data in the <a href="#dfn-input-database">input database</a>
that would lead to the generation of an invalid
<a href="#dfn-rdf-term">RDF term</a>, such as an invalid
<a href="#dfn-iri">IRI</a> or an ill-typed
<a href="#dfn-literal">literal</a>.</p>
<p>When providing access to the
<a href="#dfn-output-dataset">output dataset</a>, an
<a href="#dfn-r2rml-processor">R2RML processor</a>
<em class="rfc2119">MUST</em> abort any operation that
requires inspecting or returning an <a href="#dfn-rdf-term">RDF term</a>
whose generation would give rise to a
<a href="#dfn-data-error">data error</a>, and report an error
to the agent invoking the operation. A conforming
<a href="#dfn-r2rml-processor">R2RML processor</a>
<em class="rfc2119">MAY</em>, however, allow other operations
that do not require inspecting or returning these
<a href="#dfn-rdf-term">RDF terms</a>,
and thus <em class="rfc2119">MAY</em> provide partial access to an
<a href="#dfn-output-dataset">output dataset</a> that contains
data errors. Nevertheless, an
<a href="#dfn-r2rml-processor">R2RML processor</a>
<em class="rfc2119">SHOULD</em> report data errors as early as possible.</p>
<p>The following conditions give rise to data errors:</p>
<ol>
<li>A <a href="#dfn-term-map">term map</a> with
<a href="#dfn-term-type">term type</a> <code>rr:IRI</code>
results in the <a href="#dfn-generated-rdf-terms">generation</a>
of an invalid <a href="#dfn-iri">IRI</a>.</li>
<li>A <a href="#dfn-term-map">term map</a> with a
<a href="#dfn-datatype-override">datatype override</a>
produces an <a href="#dfn-ill-typed">ill-typed</a> literal
of a <a href="#dfn-supported-rdf-datatype">supported RDF datatype</a>.</li>
</ol>
<p>The presence of <a href="#dfn-data-error">data errors</a>
does not make an <a href="#dfn-r2rml-mapping">R2RML mapping</a>
non-conforming.</p>
<div class="note">
<p><a href="#dfn-data-error">Data errors</a> cannot
generally be detected by analyzing the table schema of the database,
but only by scanning the data in the tables. For large and rapidly
changing databases, this can be impractical. Therefore,
<a href="#dfn-r2rml-processor">R2RML processors</a> are allowed to
answer queries that do not “touch” a data error, and the behavior
of such operations is well-defined. For the same reason,
the conformance of <a href="#dfn-r2rml-mapping">R2RML mappings</a>
is defined without regard for the presence of data errors.</p>
<p><a href="#dfn-r2rml-data-validator">R2RML data validators</a>
can be used to explicitly scan a database for data errors.</p>
</div>
<h2 id="logical-tables">5 Defining Logical Tables</h2>
<div class="figure">
<img src="images/logical-table.png" alt="Diagram: The properties of logical tables"/>
<br /><br />
Figure 2: The properties of logical tables
</div>
<p>A <dfn id="dfn-logical-table">logical table</dfn> is a
possibly virtual database table that is to be mapped to
<a href="#dfn-rdf-triple">RDF triples</a>. A logical table is either</p>
<ul>
<li>a <a href="#dfn-sql-base-table-or-view">SQL base table or view</a>,
or</li>
<li>a <a href="#dfn-r2rml-view">R2RML view</a>.</li>
</ul>
<p>Every logical table has an
<dfn id="dfn-effective-sql-query">effective SQL query</dfn> that,
if executed over the <a href="#dfn-sql-connection">SQL connection</a>,
produces as its result the contents of the logical table.</p>
<p>A <dfn id="dfn-logical-table-row">logical table row</dfn> is a row
in a <a href="#dfn-logical-table">logical table</a>.</p>
<p>A <dfn id="dfn-column-name">column name</dfn> is the name of a
column of a <a href="#dfn-logical-table">logical table</a>. A column name
<em class="rfc2119">MUST</em> be a valid
<a href="#dfn-sql-identifier">SQL identifier</a>. Column names
do not include any qualifying table, view or schema names.</p>
<p>A <dfn id="dfn-sql-identifier">SQL identifier</dfn> is the name of
a SQL object, such as a column, table, view, schema, or catalog.
A SQL identifier
<em class="rfc2119">MUST</em> match the <code><identifier></code>
production in [<cite><a href="#SQL2">SQL2</a></cite>]. When
comparing identifiers for equality, the comparison rules
of [<cite><a href="#SQL2">SQL2</a></cite>] <em class="rfc2119">MUST</em>
be used.</p>
<div class="note">
An informative summary of SQL identifier syntax rules:
<ol>
<li>SQL identifiers can be delimited identifiers (with double quotes),
or regular identifiers.</li>
<li>Regular identifiers must start with a Unicode character from
any of the following character classes: upper-case letter,
lower-case letter, title-case letter, modifier letter, other letter,
or letter number. Subsequent characters may be any of these, or
a nonspacing mark, spacing combining mark, decimal number,
connector punctuation, and formatting code.</li>
<li>Regular identifiers are case-insensitive.</li>
<li>Delimited identifiers can contain any character.</li>
<li>Double quotes inside delimited identifiers must be immediately
followed by another double quote.</li>
<li>Delimited identifiers are case-sensitive.</li>
<li><code>deptno</code> and <code>"deptno"</code> are not equivalent
(delimited identifiers that are not in all-upper-case are
not equivalent to any undelimited identifiers).</li>
<li><code>DEPTNO</code> and <code>"DEPTNO"</code> are equivalent
(all-upper-case delimited and undelimited identifiers are equivalent).</li>
<li>Five examples of valid column names:
<code>deptno</code>, <code>dept_no</code>, <code>"dept_no"</code>,
<code>"Department Number"</code>,
<code>"Identifier ""with quotes"""</code>.</li>
</ol>
Note that in R2RML, column name specified as an RDF <a
href="#dfn-plain-literal">plain literal</a> or within curly
braces, is considered a delimited SQL identifier. Thus the SQL column
name identifiers <code>deptno</code>, <code>dept_no</code>,
<code>"dept_no"</code>, <code>"Department Number"</code> can be
used as (part of) object value for the various relevant R2RML properties
as follows:
<pre>
[] rr:column "DEPTNO".
[] rr:parent "DEPT_NO".
[] rr:child "dept_no".
[] rr:template "http://data.example.com/department/{Department Number}".
</pre>
Note that Turtle string syntax requires escaping of double quotes with
a backslash, so the identifier <code>"Identifier ""with quotes"""</code> can be
used as (part of) value for the various relevant R2RML properties as follows:
<pre>
[] rr:column "Identifier \"\"with quotes\"\"".
[] rr:template "http://data.example.com/department/{Identifier \"\"with quotes\"\"}".
</pre>
These rules are for <em>Core SQL 2008</em>. See
<a href="#conformance">Section 3,
<em>Conformance</em></a> regarding databases that do not conform to this
version of SQL.
</div>
<h3 id="physical-tables">5.1 Base Tables and SQL Views (<code>rr:tableName</code>)</h3>
<p>A <dfn id="dfn-sql-base-table-or-view">SQL base table or view</dfn> is a
<a href="#dfn-logical-table">logical table</a> containing
SQL data from a base table or view in the
<a href="#dfn-input-database">input database</a>.
A SQL base tables or views is represented by a resource that
has exactly one <code>rr:tableName</code> property.</p>
<p>The value of <code>rr:tableName</code> specifies the
<dfn id="dfn-table-or-view-name">table or view name</dfn> of the base table or view.
Its value <em class="rfc2119">MUST</em>
be a valid <a href="#dfn-schema-qualified-name">schema-qualified name</a>
that names an existing base table or view in the
<a href="#dfn-input-database">input database</a>.</p>
<p>A <dfn id="dfn-schema-qualified-name">schema-qualified name</dfn>
is a sequence of one, two or three valid
<a href="#dfn-sql-identifier">SQL identifiers</a>, separated
by the dot character (“<code>.</code>”). The three identifiers
name, respectively, a catalog, a schema, and a table or view.
If no catalog or schema are specified, then the
<a href="#dfn-default-catalog">default catalog</a> and
<a href="#dfn-default-schema">default schema</a> of the
<a href="#dfn-sql-connection">SQL connection</a> are assumed.</p>
<p>The <a href="#dfn-effective-sql-query">effective SQL query</a>
of a <a href="#dfn-sql-base-table-or-view">SQL base table or view</a> is:</p>
<pre>SELECT * FROM <em>{table}</em></pre>
<p>with <code><em>{table}</em></code>
replaced with the
<a href="#dfn-table-or-view-name">table or view name</a>.</p>
<p>The following example shows a logical table specified using
a schema-qualified table name.</p>
<pre class="ex-mapping">
[] rr:tableName "SCOTT.DEPT".
</pre>
<p>The following example shows a logical table specified using
an unqualified table name. The SQL connection's default
schema will be used.</p>
<pre class="ex-mapping">
[] rr:tableName "DEPT".
</pre>
<h3 id="r2rml-views">5.2 R2RML Views (<code>rr:sqlQuery</code>, <code>rr:sqlVersion</code>)</h3>
<p>An <dfn id="dfn-r2rml-view">R2RML view</dfn>
is a <a href="#dfn-logical-table">logical table</a> whose contents
are the result of executing a SQL query against the
<a href="#dfn-input-database">input database</a>. It is represented
by a resource that has exactly one <code>rr:sqlQuery</code> property,
whose value <em class="rfc2119">MUST</em> be a valid
<a href="#dfn-sql-query">SQL query</a>.</p>
<p class="note">
R2RML mappings sometimes require data transformation, computation,
or filtering before
generating triples from the database. This can be achieved by defining
a SQL view in the <a href="#dfn-input-database">input database</a>
and referring to it with
<a href="#dfn-sql-base-table-or-view">rr:tableName</a>. However, this
approach may not be practical for lack of database privileges or other
reasons. <a href="#dfn-r2rml-view">R2RML views</a>
achieve the same effect without requiring changes to the
input database.</p>
<p class="note">
Note that unlike “real” SQL views, an R2RML view can not be
used as an input table in further SQL queries.
</p>
<p>A <dfn id="dfn-sql-query">SQL query</dfn> is a <code>SELECT</code>
query in the SQL language that can be executed over the
<a href="#dfn-input-database">input database</a>.
The value of <code>rr:sqlQuery</code> <em class="rfc2119">MUST</em>
conform to the production
<code><direct select statement: multiple rows></code>
in [<cite><a href="#SQL2">SQL2</a></cite>] with an
<em class="rfc2119">OPTIONAL</em> trailing semicolon character and
<em class="rfc2119">OPTIONAL</em> surrounding white space (excluding
comments) as defined in [<cite><a href="#TURTLE">TURTLE</a></cite>].
It <em class="rfc2119">MUST</em> be a valid SQL query if executed over
the <a href="#dfn-sql-connection">SQL connection</a>. It
<em class="rfc2119">MUST NOT</em> have duplicate column names
or unnamed derived columns in the <code>SELECT</code> list. For any
database objects referenced without an explicit catalog name
or schema name, the <a href="#dfn-default-catalog">default catalog</a>
and <a href="#dfn-default-schema">default schema</a> of the
<a href="#dfn-sql-connection">SQL connection</a> are used.</p>
<p>An <a href="#dfn-r2rml-view">R2RML view</a>
<em class="rfc2119">MAY</em> have one or more
<dfn id="dfn-sql-version-identifier">SQL version identifiers</dfn>.
They <em class="rfc2119">MUST</em> be valid <a href="#dfn-iri">IRIs</a>
and are represented as values of the <code>rr:sqlVersion</code>
property. The following <a href="#dfn-sql-version-identifier">SQL version
identifier</a> indicates that the SQL query conforms to
Core SQL 2008:</p>
<pre>http://www.w3.org/ns/r2rml#SQL2008</pre>
<p>The absence of a <a href="#dfn-sql-version-identifier">SQL version
identifier</a> indicates that no claim to Core SQL 2008 conformance
is made.</p>
<p class="note">No further identifiers besides <code>rr:SQL2008</code>
are defined in this specification.
The RDB2RDF Working Group intends to maintain a non-normative
<cite><a href="http://www.w3.org/2001/sw/rdb2rdf/wiki/SQL_Version_IRIs">list
of identifiers for other SQL versions</a></cite>
[<cite><a href="#SQLIRIS">SQLIRIS</a></cite>].</p>
<p>The <a href="#dfn-effective-sql-query">effective SQL query</a>
of an <a href="#dfn-r2rml-view">R2RML view</a> is the value of its
<code>rr:sqlQuery</code> property.</p>
<p>The following example shows a logical table specified as an R2RML view
conforming to Core SQL 2008.</p>
<pre class="ex-mapping">
[] rr:sqlQuery """
Select ('Department' || DEPTNO) AS DEPTID
, DEPTNO
, DNAME
, LOC
from SCOTT.DEPT
""";
rr:sqlVersion rr:SQL2008.</pre>
<h2 id="triples-map">6 Mapping Logical Tables to RDF with Triples Maps</h2>
<div class="figure">
<img src="images/triples-map.png" alt="Diagram: The properties of triples maps"/>
<br /><br />
Figure 3: The properties of triples maps
</div>
<p>A <dfn id="dfn-triples-map">triples map</dfn> specifies a rule
for translating each row of a <a href="#dfn-logical-table">logical table</a>
to zero or more <a href="#dfn-rdf-triple">RDF triples</a>.</p>
<p>The RDF triples generated from one row in the logical table
all share the same subject.</p>
<p>A triples map is represented by a resource that references the
following other resources:</p>
<ul>
<li>It <em class="rfc2119">MUST</em> have exactly one
<a href="#dfn-logical-table">logical table</a>,
which specifies a SQL query result to be mapped to triples.
The logical table may be specified in one of two ways:
<ol>
<li>The <a href="#dfn-triples-map">triples map</a>
<em class="rfc2119">MAY</em> have a <code>rr:logicalTable</code>
property, whose value <em class="rfc2119">MUST</em> be
the <a href="#dfn-logical-table">logical table</a>.</li>
<li>The resource representing the
<a href="#dfn-triples-map">triples map</a>
<em class="rfc2119">MAY</em> itself also represent
the <a href="#dfn-logical-table">logical table</a>
(that is, have the required properties such as
<code>rr:tableName</code> or <code>rr:sqlQuery</code>).</li>
</ol>
</li>
<li>It <em class="rfc2119">MUST</em> have exactly one
<a href="#dfn-subject-map">subject map</a>
that specifies how to generate the subjects for each row of the
logical table. It may be specified in two ways:
<ol>
<li>using the <code>rr:subjectMap</code> property,
whose value <em class="rfc2119">MUST</em> be
the subject map, or</li>
<li>using the <a href="#dfn-constant-shortcut-property">constant
shortcut property</a> <code>rr:subject</code>.</li>
</ol>
</li>
<li>It <em class="rfc2119">MAY</em> have zero or more
<code>rr:predicateObjectMap</code> properties,
whose values <em class="rfc2119">MUST</em> be
<a href="#dfn-predicate-object-map">predicate-object maps</a>.
Each specifies a predicate-object pair that, together with the
subjects generated by the subject map, may form one
<a href="#dfn-rdf-triple">RDF triple</a> for each row.</li>
</ul>
<p>The <a href="#dfn-referenced-columns">referenced columns</a> of
all <a href="#dfn-term-map">term maps</a> of a triples map
(subject map, predicate maps, object maps, graph maps)
<em class="rfc2119">MUST</em>
be <a href="#dfn-column-name">column names</a> that exist
in the term map's <a href="#dfn-logical-table">logical table</a>.
Furthermore, the columns carrying these names in the
logical table <em class="rfc2119">MUST</em> be of a SQL datatype
for which <a href="#dfn-conversion-to-string">conversion to string</a>
is defined.</p>
<p class="note"><a href="#dfn-conversion-to-string">Conversion
to string</a> is undefined in SQL 2008 for row types, array types,
user-defined datatypes that do not have a user-defined string
<code>CAST</code>, and a few other exotic types.</p>
<p>The following example shows a <a href="#dfn-triples-map">triples map</a>
including its logical table, subject map, and two predicate-object maps.</p>
<pre class="ex-mapping">
[]
rr:logicalTable [ rr:tableName "DEPT" ];
rr:subjectMap [ rr:template "http://data.example.com/department/{DEPTNO}" ];
rr:predicateObjectMap [
rr:predicate ex:name;
rr:objectMap [ rr:column "DNAME" ];
].
rr:predicateObjectMap [
rr:predicate ex:location;
rr:objectMap [ rr:column "LOC" ];
].</pre>
<p>The logical table may also be specified directly on the same
resource, without introducing an intermediate resource:</p>
<pre class="ex-mapping">
[]
rr:tableName "DEPT";
rr:subjectMap [ rr:template "http://data.example.com/department/{DEPTNO}" ];
# …
.</pre>
<h3 id="subject-map">6.1 Creating Resources with Subject Maps</h3>
<p>A <dfn id="dfn-subject-map">subject map</dfn> is a
<a href="#dfn-term-map">term map</a>. It specifies a rule
for generating the subjects of the
<a href="#dfn-rdf-triple">RDF triples</a> generated by a
<a href="#dfn-triples-map">triples map</a>.</p>
<h3 id="typing">6.2 Typing Resources (<code>rr:class</code>)</h3>
<p>A <a href="#dfn-subject-map">subject map</a> <em class="rfc2119">MAY</em>
have one or more <dfn id="dfn-class-iri">class IRIs</dfn>. They are
represented by the <code>rr:class</code> property. The values
of the <code>rr:class</code> property
<em class="rfc2119">MUST</em> be <a href="#dfn-iri">IRIs</a>.
For each <a href="#dfn-rdf-term">RDF term</a> generated by the subject map,
<a href="#dfn-rdf-triple">RDF triples</a> with predicate
<code>rdf:type</code> and the class IRI as object will be generated.</p>
<p class="note">This property is merely a shortcut for specifying an
<code>rr:predicateObjectMap</code> with predicate <code>rdf:type</code>
and the <code>rr:class</code> IRI as a constant object.
Mappings where the class IRI is not constant, but needs to be computed
based on the contents of the database, can be achieved by defining
such a <code>rr:predicateObjectMap</code> with a non-constant object.</p>
<p>In the following example, the generated subject will be asserted
as an instance of the <code>ex:Employee</code> class.</p>
<pre class="ex-mapping">
[] rr:template "http://data.example.com/employee/{EMPNO}";
rr:class ex:Employee.
</pre>
<p>Using the example <a href="#ex_EMP"><code>EMP</code> table</a>,
the following RDF triple will be generated:</p>
<pre class="ex-output">
<http://data.example.com/emp/7369> rdf:type ex:Employee.
</pre>
<h3 id="predicate-object-map">6.3 Creating Properties and Values with Predicate-Object Maps</h3>
<p>A <dfn id="dfn-predicate-object-map">predicate-object map</dfn> is
a function that creates predicate-object pairs from
<a href="#dfn-logical-table-row">logical table rows</a>. It is
used in conjunction with a <a href="#dfn-subject-map">subject map</a>
to generate <a href="#dfn-rdf-triple">RDF triples</a> in a
<a href="#dfn-triples-map">triples map</a>.</p>
<p>A <a href="#dfn-predicate-object-map">predicate-object map</a>
is represented by a resource that references the following
other resources:</p>
<ul>
<li>Exactly one <a href="#dfn-predicate-map">predicate map</a>. It may be
specified in two ways:
<ol>
<li>using the <code>rr:predicateMap</code> property, whose value
<em class="rfc2119">MUST</em> be a
<a href="#dfn-predicate-map">predicate map</a>, or</li>
<li>using the <a href="#dfn-constant-shortcut-property">constant
shortcut property</a> <code>rr:predicate</code>.</li>
</ol>
</li>
<li>Exactly one <a href="#dfn-object-map">object map</a>. It may be
specified in one of two ways:
<ol>
<li>using the <code>rr:objectMap</code> property, whose value
<em class="rfc2119">MUST</em> be either an
<a href="#dfn-object-map">object map</a>, or a
<a href="#dfn-referencing-object-map">referencing object map</a>.</li>
<li>using the <a href="#dfn-constant-shortcut-property">constant
shortcut property</a> <code>rr:object</code>.</li>
</ol>
</li>
</ul>
<p>A <dfn id="dfn-predicate-map">predicate map</dfn> is a
<a href="#dfn-term-map">term map</a>.</p>
<p>An <dfn id="dfn-object-map">object map</dfn>
is a <a href="#dfn-term-map">term map</a>.</p>
<h2 id="term-map">7 Creating RDF Terms with Term Maps</h2>
<div class="figure">
<img src="images/term-map.png" alt="Diagram: The properties of term maps"/>
<br /><br />
Figure 4: The properties of term maps
</div>
<p>An <dfn id="dfn-rdf-term">RDF term</dfn> is either an
<a href="#dfn-iri">IRI</a>, or a <a href="#dfn-blank-node">blank node</a>,
or a <a href="#dfn-literal">literal</a>.</p>
<p>A <dfn id="dfn-term-map">term map</dfn> is a function that generates
an <a href="#dfn-rdf-term">RDF term</a> from a
<a href="#dfn-logical-table-row">logical table row</a>. The result of
that function is known as the term map's
<a href="#dfn-generated-rdf-terms">generated RDF term</a>.</p>
<p>Term maps
are used to generate the subjects, predicates and objects of the
<a href="#dfn-rdf-triple">RDF triples</a> that are generated by
a <a href="#dfn-triples-map">triples map</a>. Consequently, there
are several kinds of <a href="#dfn-term-map">term maps</a>,
depending on where in the mapping they occur:
<a href="#dfn-subject-map">subject maps</a>,
<a href="#dfn-predicate-map">predicate maps</a>,
<a href="#dfn-object-map">object maps</a> and
<a href="#dfn-graph-map">graph maps</a>.</p>
<p>A <a href="#dfn-term-map">term map</a> <em class="rfc2119">MUST</em>
be exactly one of the following:</p>
<ul>
<li>a <a href="#dfn-constant-valued-term-map">constant-valued term map</a>,</li>
<li>a <a href="#dfn-column-valued-term-map">column-valued term map</a>,</li>
<li>a <a href="#dfn-template-valued-term-map">template-valued term map</a>.</li>
</ul>
<p>The <dfn id="dfn-referenced-columns">referenced columns</dfn> of a
<a href="#dfn-term-map">term map</a> are the set of
<a href="#dfn-column-name">column names</a> referenced
in the term map and depend on the type of term map.</p>
<h3 id="constant">7.1 Constant RDF Terms (<code>rr:constant</code>)</h3>
<p>A <dfn id="dfn-constant-valued-term-map">constant-valued term map</dfn>
is a <a href="#dfn-term-map">term map</a> that ignores the
<a href="#dfn-logical-table-row">logical table row</a> and always generates
the same RDF term. A constant-valued term map is represented by a
resource that has exactly one <code>rr:constant</code>
property.</p>
<p>The <dfn id="dfn-constant-value">constant value</dfn> of a
<a href="#dfn-constant-valued-term-map">constant-valued term map</a>
is the RDF term that is the value of its <code>rr:constant</code>
property.</p>
<p>If the
<a href="#dfn-constant-valued-term-map">constant-valued term map</a>
is a <a href="#dfn-subject-map">subject map</a>,
<a href="#dfn-predicate-map">predicate map</a> or
<a href="#dfn-graph-map">graph map</a>, then its
<a href="#dfn-constant-value">constant value</a>
<em class="rfc2119">MUST</em> be an <a href="#dfn-iri">IRI</a>.</p>
<p>If the
<a href="#dfn-constant-valued-term-map">constant-valued term map</a>
is an <a href="#dfn-object-map">object map</a>, then its
<a href="#dfn-constant-value">constant value</a>
<em class="rfc2119">MUST</em> be an
<a href="#dfn-iri">IRI</a> or <a href="#dfn-literal">literal</a>.</p>
<p>The <a href="#dfn-referenced-columns">referenced columns</a> of
a <a href="#dfn-constant-valued-term-map">constant-valued term map</a>
is the empty set.</p>
<p>Constant-valued term maps can be expressed more concisely using the
<dfn id="dfn-constant-shortcut-property">constant shortcut properties</dfn>
<code>rr:subject</code>, <code>rr:predicate</code>,
<code>rr:object</code> and <code>rr:graph</code>.
Occurrances of these properties <em class="rfc2119">MUST</em> be
treated exactly as if the following triples were present in the
mapping graph instead:</p>
<table rules="all" summary="Constant shortcut properties and their replacements">
<tr>
<th>Triple involving constant shortcut property</th>
<th>Replacement triples</th>
</tr>
<tr>
<td><code><em>aaa</em> rr:subject <em>bbb</em>.</code></td>
<td><code><em>aaa</em> rr:subjectMap [ rr:constant <em>bbb</em> ].</code></td>
</tr>
<tr>
<td><code><em>aaa</em> rr:predicate <em>bbb</em>.</code></td>
<td><code><em>aaa</em> rr:predicateMap [ rr:constant <em>bbb</em> ].</code></td>
</tr>
<tr>
<td><code><em>aaa</em> rr:object <em>bbb</em>.</code></td>
<td><code><em>aaa</em> rr:objectMap [ rr:constant <em>bbb</em> ].</code></td>
</tr>
<tr>
<td><code><em>aaa</em> rr:graph <em>bbb</em>.</code></td>
<td><code><em>aaa</em> rr:graphMap [ rr:constant <em>bbb</em> ].</code></td>
</tr>
</table>
<p>The following example shows a
<a href="#dfn-predicate-object-map">predicate-object map</a> that
uses a constant-valued term map both for its predicate and for its
object.</p>
<pre class="ex-mapping">
[] rr:predicateMap [ rr:constant rdf:type ];
rr:objectMap [ rr:constant ex:Employee ].</pre>
<p>If added to a <a href="#dfn-triples-map">triples map</a>,
this predicate-object map would add the following triple to
all resources <code>?x</code> generated by the triples map:</p>
<pre class="ex-output">
?x rdf:type ex:Employee.</pre>
<p>The following example uses
<a href="#dfn-constant-shortcut-property">constant shortcut properties</a>
and is equivalent to the example above:</p>
<pre class="ex-mapping">
[] rr:predicate rdf:type;
rr:object ex:Employee.</pre>
<h3 id="from-column">7.2 From a Column (<code>rr:column</code>)</h3>
<p>A <dfn id="dfn-column-valued-term-map">column-valued term map</dfn>
is a <a href="#dfn-term-map">term map</a> that is represented by
a resource that has exactly one <code>rr:column</code> property.</p>
<p>The value of the <code>rr:column</code> property
<em class="rfc2119">MUST</em> be a valid
<a href="#dfn-column-name">column name</a>. The
<dfn id="dfn-column-value">column value</dfn> of the term map
is the data value of that column in a given
<a href="#dfn-logical-table-row">logical table row</a>.</p>
<p>The <a href="#dfn-referenced-columns">referenced columns</a> of
a <a href="#dfn-column-valued-term-map">column-valued term map</a>
is the singleton set containing the value of <code>rr:column</code>.</p>
<p>The following example defines an <a href="#dfn-object-map">object map</a>
that generates <a href="#dfn-literal">literals</a> from the
<code>DNAME</code> column of some logical table.</p>
<pre class="ex-mapping">
[] rr:objectMap [ rr:column "DNAME" ].</pre>
<p>Using the sample row from the
<a href="#ex_DEPT"><code>DEPT</code> table</a> as a logical table
row, the <a href="#dfn-column-value">column value</a> of the object map
would be “<code>APPSERVER</code>”.</p>
<h3 id="from-template">7.3 From a Template (<code>rr:template</code>)</h3>
<p>A <dfn id="dfn-template-valued-term-map">template-valued term map</dfn>
is a <a href="#dfn-term-map">term map</a> that is represented by
a resource that has exactly one <code>rr:template</code> property.
The value of the <code>rr:template</code> property
<em class="rfc2119">MUST</em> be a valid
<a href="#dfn-string-template">string template</a>.</p>
<p>A <dfn id="dfn-string-template">string template</dfn> is a
format string that can be used to build strings from multiple
components. It can reference
<a href="#dfn-column-name">column names</a> by enclosing
them in curly braces. The following syntax rules apply to valid
string templates:</p>
<ul>
<li>Pairs of unescaped curly braces <em class="rfc2119">MUST</em> enclose
valid <a href="#dfn-column-name">column names</a>.</li>
<li>Curly braces that do not enclose column names
<em class="rfc2119">MUST</em> be escaped by a backslash character.
This includes curly braces within column names.</li>
<li>Backslash characters <em class="rfc2119">MUST</em> be escaped by
doubling them with another backslash character. This includes
backslashes within column names.</li>
<li>If a template contains multiple pairs of unescaped curly braces,
then adjacent pairs <em class="rfc2119">SHOULD</em> be separated by
a character or string that does not occur anywhere in the data values
of either column.</li>
</ul>
<p>The <dfn id="dfn-template-value">template value</dfn> of the term map
for a given <a href="#dfn-logical-table-row">logical table row</a>
is determined as follows:</p>
<ol>
<li>Let <code><em>result</em></code> be the
<a href="#dfn-string-template">template string</a></li>
<li>For each pair of unescaped curly braces in
<code><em>result</em></code>:
<ol>
<li>Let <code><em>value</em></code> be the data value of the
column whose name is enclosed in the curly braces</li>
<li>If <code><em>value</em></code> is <code>NULL</code>,
then return <code>NULL</code></li>
<li>Apply <a href="#dfn-conversion-to-string">conversion to string</a>
to <code><em>value</em></code></li>
<li>If the <a href="#dfn-term-type">term type</a> is
<code>rr:IRI</code>, then replace the pair of curly braces
with an <a href="#dfn-iri-safe">IRI-safe</a> version of
<code><em>value</em></code>; otherwise, replace the pair
of curly braces with <code><em>value</em></code></li>
</ol>
</li>
<li>Return <code><em>result</em></code></li>
</ol>
<p>The <dfn id="dfn-iri-safe">IRI-safe version</dfn> of a string
is obtained by applying the following transformation to any character
that is not in the
<cite><a class="norm" href="http://tools.ietf.org/html/rfc3987#section-2.2">
<code>iunreserved</code> production</a></cite> in
[<cite><a href="#RFC3987">RFC3987</a></cite>]:</p>
<ol>
<li>Convert the character to a sequence of one or more octets
using <cite><a class="norm" href="http://tools.ietf.org/html/rfc3629">UTF-8</a></cite>
[<cite><a href="#RFC3629">RFC3629</a></cite>]</li>
<li><cite><a class="norm" href="http://tools.ietf.org/html/rfc3986#section-2.1">Percent-encode</a></cite>
each octet [<cite><a href="#RFC3986">RFC3986</a></cite>]</li>
</ol>
<p>The <a href="#dfn-referenced-columns">referenced columns</a> of
a <a href="#dfn-template-valued-term-map">template-valued term map</a>
is the set of <a href="#dfn-column-name">column names</a> enclosed
in unescaped curly braces in the
<a href="#dfn-string-template">template string</a>.</p>
<p>The following example defines a
<a href="#dfn-subject-map">subject map</a> that generates
<a href="#dfn-iri">IRIs</a> from the
<code>DEPTNO</code> column of a logical table.</p>
<pre class="ex-mapping">
[] rr:subjectMap [ rr:template "http://data.example.com/department/{DEPTNO}" ].</pre>
<p>Using the sample row from the
<a href="#ex_DEPT"><code>DEPT</code> table</a> as a logical table
row, the <a href="#dfn-template-value">template value</a> of the subject map
would be:</p>
<pre class="ex-output">http://data.example.com/department/10</pre>
<p>The following example shows how an <a href="#dfn-iri-safe">IRI-safe</a>
template value is created:</p>
<pre class="ex-mapping">
[] rr:subjectMap [ rr:template "http://data.example.com/site/{LOC}" ].</pre>
<p>Using the sample row from the
<a href="#ex_DEPT"><code>DEPT</code> table</a> as a logical table
row, the <a href="#dfn-template-value">template value</a> of the subject map
would be:</p>
<pre class="ex-output">http://data.example.com/site/NEW%20YORK</pre>
<p>The space character is not in the <code>iunreserved</code> set,
and therefore percent-encoding is applied to the character, yielding
“<code>%20</code>”.</p>
<p>The following example shows the use of backslash escapes in string
templates. The template will generate a fancy title such as</p>
<pre>{{{ Hello World! }}}</pre>
<p>from a string “<code>Hello World!</code>” in the <code>TITLE</code> column.</p>
<pre class="ex-mapping">
[] rr:objectMap [ rr:template "\\{\\{\\{ {TITLE} \\}\\}\\}" ].</pre>
<p>Note that because <a class="norm" href=
"http://www.w3.org/TeamSubmission/2008/SUBM-turtle-20080114/#sec-strings">
backslashes need to be escaped by a second backslash
in the Turtle syntax</a>
[<cite><a href="#TURTLE">TURTLE</a></cite>],
a double backslash is needed to escape each curly brace.</p>
<h3 id="termtype">7.4 IRIs, Literal, Blank Nodes (<code>rr:termType</code>)</h3>
<p>The <dfn id="dfn-term-type">term type</dfn> of a
<a href="#dfn-column-valued-term-map">column-valued term map</a> or
<a href="#dfn-template-valued-term-map">template-valued term map</a>
determines the kind of
<a href="#dfn-generated-rdf-terms">generated RDF term</a>
(<a href="#dfn-iri">IRIs</a>, <a href="#dfn-blank-node">blank nodes</a> or
<a href="#dfn-literal">literals</a>).</p>
<p>If the term map has an optional <code>rr:termType</code> property,
then its <a href="#dfn-term-type">term type</a>
is the value of that property. The value <em class="rfc2119">MUST</em>
be an IRI and <em class="rfc2119">MUST</em> be
one of the following options:</p>
<ul>
<li>If the term map is a <a href="#dfn-subject-map">subject map</a>:
<code>rr:IRI</code> or <code>rr:BlankNode</code></li>
<li>If the term map is a <a href="#dfn-predicate-map">predicate map</a>:
<code>rr:IRI</code></li>
<li>If the term map is an <a href="#dfn-object-map">object map</a>:
<code>rr:IRI</code>, <code>rr:BlankNode</code>, or <code>rr:Literal</code></li>
<li>If the term map is a <a href="#dfn-graph-map">graph map</a>:
<code>rr:IRI</code></li>
</ul>
<p>If the term map does not have a <code>rr:termType</code> property,
then its <a href="#dfn-term-type">term type</a> is:</p>
<ul>
<li>If the term map is an <a href="#dfn-object-map">object map</a>
and a <a href="#dfn-column-valued-term-map">column-based term map</a>:
<code>rr:Literal</code></li>
<li>Otherwise: <code>rr:IRI</code></li>
</ul>
<p class="note">Term maps with term type <code>rr:IRI</code>
cause <a href="#dfn-data-error">data errors</a> if the value is not a
valid <a href="#dfn-iri">IRI</a>
(see <a href="#dfn-generated-rdf-terms">generated RDF term</a> for details).
Data values from the input database may require percent-encoding before
they can be used in IRIs.
<a href="#dfn-template-valued-term-map">Template-valued term maps</a>
are a convenient way of percent-encoding data values.</p>
<h3 id="language-tags">7.5 Language Tags (<code>rr:language</code>)</h3>
<p>A <a href="#dfn-term-map">term map</a> with a
<a href="#dfn-term-type">term type</a> of <code>rr:Literal</code>
<em class="rfc2119">MAY</em> have a
<dfn id="dfn-specified-language-tag">specified language tag</dfn>.
It is represented by the <code>rr:language</code> property on a term map.
If present, its value <em class="rfc2119">MUST</em> be
a valid <a href="#dfn-language-tag">language tag</a>.</p>
<p>A specified language tag causes generated literals to be
language-tagged plain literals. In the following example, plain
literals with language tag “<code>en-us</code>” (U.S. English)
will be generated for the data values in the <code>DNAME</code>
column.</p>
<pre class="ex-mapping">
[] rr:objectMap [ rr:column "DNAME"; rr:language "en-us" ].
</pre>
<h3 id="typed-literals">7.6 Typed Literals (<code>rr:datatype</code>)</h3>
<p>A <dfn id="dfn-typeable-term-map">typeable term map</dfn> is a
<a href="#dfn-term-map">term map</a> with a
<a href="#dfn-term-type">term type</a> of <code>rr:Literal</code>
that does not have a
<a href="#dfn-specified-language-tag">specified langauge tag</a>.</p>
<p>Typeable term maps may generate
<a href="#dfn-typed-literal">typed literals</a>. The datatype
of these literals can be explicitly specified using
<code>rr:datatype</code>, or
<a href="#dfn-corresponding-rdf-datatype">automatically determined</a>
based on the SQL datatype of the underlying logical table column.</p>
<p>A <a href="#dfn-typeable-term-map">typeable term map</a>
<em class="rfc2119">MAY</em> have a <code>rr:datatype</code> property.
Its value <em class="rfc2119">MUST</em> be an <a href="#dfn-iri">IRI</a>.
This IRI is the <dfn id="dfn-specified-datatype">specified datatype</dfn>
of the term map.</p>
<p>A term map <em class="rfc2119">MUST NOT</em> have more than one
<code>rr:datatype</code> value.</p>
<p>A term map that is not a
<a href="#dfn-typeable-term-map">typeable term map</a>
<em class="rfc2119">MUST NOT</em> have an <code>rr:datatype</code>
property.</p>
<p>A <a href="#dfn-typeable-term-map">typeable term map</a>
has an <dfn id="dfn-implicit-datatype">implicit datatype</dfn>
and an <dfn id="dfn-implicit-transform">implicit transform</dfn>.
They are determined as follows:</p>
<ul>
<li>If the term map is a
<a href="#dfn-column-valued-term-map">column-valued term map</a>,
then the implicit datatype is the
<a href="#dfn-corresponding-rdf-datatype">corresponding RDF datatype</a>
of the respective column in
the <a href="#dfn-logical-table-row">logical table row</a>, and
the implicit transform is the <a href="#dfn-rdf-transformation">RDF
transformation</a> of the column.</li>
<li>Otherwise, the term map must be a
<a href="#dfn-template-valued-term-map">template-valued term map</a>
and its implicit datatype is <code>empty</code>, and
its implicit transform is the identity transform.</li>
</ul>
<p>A <dfn id="dfn-datatype-override">datatype override</dfn>
is in effect on a <a href="#dfn-typeable-term-map">typeable term map</a>
if it has a <a href="#dfn-specified-datatype">specified datatype</a>,
and the specified datatype is different from its
<a href="#dfn-implicit-datatype">implicit datatype</a>.</p>
<p>See <a href="#dfn-generated-rdf-terms">generated RDF term</a>
for further details.</p>
<p class="note">R2RML does not allow generating
<a href="#dfn-plain-literal">plain literals</a> without
<a href="#dfn-language-tag">language tag</a> from non-string
columns. One can use a derived column that uses a SQL
<code>CAST</code> expression instead.</p>
<p>The following example shows an <a href="#dfn-object-map">object map</a>
that overrides the default datatype of the logical table with
an explicitly specified <code>xsd:positiveInteger</code> type.
Whatever is in the <code>EMPNO</code> column will be subjected
to <a href="#dfn-conversion-to-string">conversion to string</a>,
and turned into a literal of that type.</p>
<pre class="ex-mapping">
[] rr:objectMap [ rr:column "EMPNO"; rr:datatype xsd:positiveInteger ].
</pre>
<h3 id="inverse">7.7 Inverse Expressions (<code>rr:inverseExpression</code>)</h3>
<p>An <dfn id="dfn-inverse-expression">inverse expression</dfn> is a
<a href="#dfn-string-template">string template</a> associated with
a <a href="#dfn-column-valued-term-map">column-valued term map</a> or
<a href="#dfn-template-valued-term-map">template-value term map</a>.
It is represented by the value of the <code>rr:inverseExpression</code>
property. This property is <em class="rfc2119">OPTIONAL</em> and there
<em class="rfc2119">MUST NOT</em> be more than one for a term map.</p>
<p>Inverse expressions are useful for optimizing
<a href="#dfn-term-map">term maps</a>
that reference derived columns in
<a href="#dfn-r2rml-view">R2RML views</a>.
An inverse expression specifies an expression that
allows “reversing” of a <a href="#dfn-generated-rdf-terms">generated RDF term</a>
and the construction of a SQL query that efficiently retrieves the
<a href="#dfn-logical-table-row">logical table row</a> from which the
term was generated. In particular, it allows the use of indexes
on the underlying relational tables.</p>
<p>Every pair of unescaped curly braces in the inverse expression is a
<dfn id="dfn-column-reference">column reference in an inverse expression</dfn>.
The string between the braces <em class="rfc2119">MUST</em> be a valid
<a href="#dfn-column-name">column name</a>.</p>
<p>An <a href="#dfn-inverse-expression">inverse expression</a>
<em class="rfc2119">MUST</em> satisfy the following condition:</p>
<ul>
<li>Let <em>t</em> be the <a href="#dfn-logical-table">logical table</a>
associated with this <a href="#dfn-term-map">term map</a></li>
<li>Every <a href="#dfn-column-reference">column reference</a> in the
inverse expression <em class="rfc2119">MUST</em> be an existing column
in <em>t</em></li>
<li>Given a <a href="#dfn-logical-table-row">logical table row</a>
<em>r</em> in <em>t</em>, let <em>instantiation(r)</em> be the result of
replacing each <a href="#dfn-column-reference">column reference</a>
<em>c</em> in the inverse expression with:
<ul>
<li>the <a href="#dfn-quoted-data-value">quoted and escaped data value</a>
of column
<em>c</em> in <em>r</em>, if <em>c</em> is a
<a href="#dfn-referenced-columns">referenced column</a>
in the <a href="#dfn-term-map">term map</a></li>
<li>the <a href="#dfn-column-name">column name</a>
of column <em>c</em>, otherwise</li>
</ul>
</li>
<li>Given a <a href="#dfn-logical-table-row">logical table row</a>
<em>r</em> in <em>t</em>, let <em>same-term(r)</em>
be the set of logical table rows in <em>t</em> that are the
result of executing the following SQL query over the
<a href="#dfn-sql-connection">SQL connection</a>:
<pre>SELECT * FROM (<em>{query}</em>) AS tmp WHERE <em>{expr}</em></pre>
where <code><em>{query}</em></code> is the
<a href="#dfn-effective-sql-query">effective SQL query</a>
of <em>t</em>, and <code><em>{expr}</em></code> is
<em>instantiation(r)</em></li>
<li>For every <a href="#dfn-logical-table-row">logical table row</a>
<em>r</em> in <em>t</em> whose
<a href="#dfn-generated-rdf-terms">generated RDF term</a> <em>g</em>
is not <code>NULL</code>, <em>same-term(r)</em>
<em class="rfc2119">MUST</em> be exactly the set of logical table rows
in <em>t</em> whose
<a href="#dfn-generated-rdf-terms">generated RDF term</a> is
also <em>g</em>.</li>
</ul>
<p>For example, for the <code>DEPTID</code> column in the
<a href="#dfn-logical-table">logical table</a> used for
mapping the <code>DEPT</code> table in
<a href="#example-r2rml-view">this example mapping</a>,
an inverse expression could be defined as follows:</p>
<pre class="ex-mapping">
[] rr:column "DEPTID";
rr:inverseExpression "{DEPTNO} = substr({DEPTID},length('Department')+1)";
</pre>
<p>This facilitates the use of an existing index on the <code>DEPTNO</code>
column of the <a href="#ex_DEPT">DEPT table</a>.</p>
<p>A <dfn id="dfn-quoted-data-value">quoted and escaped data value</dfn>
is a SQL literal that can be used in a SQL query, such as:</p>
<ul>
<li><code>27</code></li>
<li><code>'foo'</code></li>
<li><code>'foo''bar'</code></li>
</ul>
<h2 id="foreign-key">8 Foreign Key Relationships among Logical Tables (<code>rr:parentTriplesMap</code>, <code>rr:joinCondition</code>, <code>rr:child</code> and <code>rr:parent</code>)</h2>
<div class="figure">
<img src="images/ref-object-map.png" alt="Diagram: The properties of referencing object maps"/>
<br /><br />
Figure 5: The properties of referencing object maps
</div>
<p>A <dfn id="dfn-referencing-object-map">referencing object map</dfn>
allows using the subjects of another
<a href="#dfn-triples-map">triples map</a> as the objects generated
by a <a href="#dfn-predicate-object-map">predicate-object map</a>.
Since both triples maps may be based on different
<a href="#dfn-logical-table">logical tables</a>, this may require
a join between the logical tables. A referencing object map is represented
by a resource that:</p>
<ul>
<li>has exactly one <code>rr:parentTriplesMap</code> property, whose value
<em class="rfc2119">MUST</em> be a
<a href="#dfn-triples-map">triples map</a>, known as the
referencing object map's <dfn id="dfn-parent-triples-map">parent
triples map</dfn>.</li>
<li><em class="rfc2119">MAY</em> have one or more
<code>rr:joinCondition</code> properties, whose values
<em class="rfc2119">MUST</em> be
<a href="#dfn-join-condition">join conditions</a>.</li>
</ul>
<p>A <dfn id="dfn-join-condition">join condition</dfn> is a resource that
has exactly two properties:</p>
<ul>
<li><code>rr:child</code>, whose value is known as the join condition's
<dfn id="dfn-child-column">child column</dfn> and
<em class="rfc2119">MUST</em> be a
<a href="#dfn-column-name">column name</a> that exists in the
<a href="#dfn-logical-table">logical table</a> of the
<a href="#dfn-triples-map">triples map</a> that contains the
referencing object map</li>
<li><code>rr:parent</code>, whose value is known as the join condition's
<dfn id="dfn-parent-column">parent column</dfn> and
<em class="rfc2119">MUST</em> be a
<a href="#dfn-column-name">column name</a> that exists in the
<a href="#dfn-logical-table">logical table</a> of the
referencing object map's
<a href="#dfn-parent-triples-map">parent triples map</a>.</li>
</ul>
<p>The <dfn id="dfn-child-query">child query</dfn> of a
<a href="#dfn-referencing-object-map">referencing object map</a>
is the <a href="#dfn-effective-sql-query">effective SQL query</a>
of the <a href="#dfn-logical-table">logical table</a> containing
the referencing object map.</p>
<p>The <dfn id="dfn-parent-query">parent query</dfn> of a
<a href="#dfn-referencing-object-map">referencing object map</a>
is the <a href="#dfn-effective-sql-query">effective SQL query</a>
of the <a href="#dfn-logical-table">logical table</a> of its
<a href="#dfn-parent-triples-map">parent triples map</a>.</p>
<p>If the <a href="#dfn-child-query">child query</a> and
<a href="#dfn-parent-query">parent query</a> of a
<a href="#dfn-referencing-object-map">referencing object map</a>
are not identical, then the referencing object map
<em class="rfc2119">MUST</em> have at least one
<a href="#dfn-join-condition">join condition</a>.</p>
<p>The <dfn id="dfn-joint-sql-query">joint SQL query</dfn> of a
<a href="#dfn-referencing-object-map">referencing object map</a>
is:</p>
<ul>
<li>If the referencing object map has no
<a href="#dfn-join-condition">join condition</a>:
<pre>SELECT * FROM (<em>{child-query}</em>) AS tmp</pre></li>
<li>If the referencing object map has at least one join condition:
<pre>
SELECT * FROM (<em>{child-query}</em>) AS child,
(<em>{parent-query}</em>) AS parent
WHERE child.<em>{child-column1}</em>=parent.<em>{parent-column1}</em>
AND child.<em>{child-column2}</em>=parent.<em>{parent-column2}</em>
AND ...</pre>
where <code><em>{child-query}</em></code> is the referencing object map's
<a href="#dfn-child-query">child query</a>,
<code><em>{parent-query}</em></code> is its
<a href="#dfn-parent-query">parent query</a>,
<code><em>{child-column1}</em></code> and
<code><em>{parent-column1}</em></code> are the
<a href="#dfn-child-column">child column</a> and
<a href="#dfn-parent-column">parent column</a> of its first
<a href="#dfn-join-condition">join condition</a>, and so on.
The order of the join conditions is chosen arbitrarily.</li>
</ul>
<p>The following example shows a referencing object map as
part of a <a href="#dfn-predicate-object-map">predicate-object map</a>:</p>
<pre class="ex-mapping" id="ex-mapping">
[] rr:predicateObjectMap [
rr:predicate ex:department;
rr:refObjectMap [
rr:parentTriplesMap <#TriplesMap2>;
rr:joinCondition [
rr:child "DEPTNO";
rr:parent "DEPTNO";
];
];
].</pre>
<p>If the logical table of the surrounding
triples map is <code>EMP</code>, and the logical table
of <code><#TriplesMap2></code> is <code>DEPT</code>,
this would result in a join between these two tables
with the condition</p>
<pre>EMP.DEPTNO = DEPT.DEPTNO</pre>
<p>and the objects of the triples would be generated using
the subject map of <code><#TriplesMap2></code>.</p>
<p>Given the two <a href="#example-input-database">example
tables</a>, and subject maps as defined in the
<a href="#ex-mapping">example mapping</a>, this would
result in a triple:</p>
<pre class="ex-output"><http://data.example.com/employee/7369> ex:department <http://data.example.com/department/10>.</pre>
<h2 id="named-graphs">9 Assigning Triples to Named Graphs</h2>
<div class="figure">
<img src="images/graph-map.png" alt="Diagram: The properties of graph maps"/>
<br /><br />
Figure 6: The properties of graph maps
</div>
<p>Each triple generated from an <a href="#dfn-r2rml-mapping">R2RML
mapping</a> is placed into one or
more graphs of the <a href="#dfn-output-dataset">output dataset</a>.
Possible target graphs are the unnamed
<a href="#dfn-default-graph">default graph</a>, and the
<a href="#dfn-iri">IRI</a>-named <a href="#dfn-named-graph">named
graphs</a>.</p>
<p>Any <a href="#dfn-subject-map">subject map</a>
or <a href="#dfn-predicate-object-map">predicate-object map</a> <em class="rfc2119">MAY</em>
have one or more associated <dfn id="dfn-graph-map">graph maps</dfn>.
They are specified in one of two ways:</p>
<ol>
<li>using the <code>rr:graphMap</code> property, whose value
<em class="rfc2119">MUST</em> be a
<a href="#dfn-graph-map">graph map</a>,</li>
<li>using the <a href="#dfn-constant-shortcut-property">constant
shortcut property</a> <code>rr:graph</code>.</li>
</ol>
<p>Graph maps are themselves <a href="#dfn-term-map">term maps</a>.
When <a href="#dfn-generating-rdf-triples">RDF
triples are generated</a>, the set of target graphs is determined by
taking into account any graph maps associated with the subject map
or predicate-object map.</p>
<p>If a <a href="#dfn-graph-map">graph map</a> generates the special
IRI <code>rr:defaultGraph</code>, then the target graph is the
<a href="#dfn-default-graph">default graph</a> of the
<a href="#dfn-output-dataset">output dataset</a>.</p>
<p>In the following <a href="#dfn-subject-map">subject map</a> example,
all generated RDF triples will be stored in the named graph
<code>ex:DepartmentGraph</code>.</p>
<pre class="ex-mapping">
[] rr:subjectMap [
rr:template "http://data.example.com/department/{DEPTNO}";
rr:graphMap [ rr:graph ex:DepartmentGraph ];
].</pre>
<p>This is equivalent to the following example, which uses a
<a href="#dfn-constant-shortcut-property">constant shortcut property</a>:</p>
<pre class="ex-mapping">
[] rr:subjectMap [
rr:template "http://data.example.com/department/{DEPTNO}";
rr:graph ex:DepartmentGraph;
].</pre>
<p>In the following example, RDF triples are placed into named graphs
according to the job title of employees:</p>
<pre class="ex-mapping">
[] rr:subjectMap [
rr:template "http://data.example.com/employee/{EMPNO}";
rr:graphMap [ rr:template "http://data.example.com/jobgraph/{JOB}" ];
].</pre>
<p>The triples generated from the <a href="#ex_EMP"><code>EMP</code>
table</a> would be placed in the named graph with the following IRI:</p>
<pre class="ex-output">
<http://data.example.com/jobgraph/CLERK></pre>
<h3 id="blank-nodes">9.1 Scope of Blank Nodes</h3>
<p><a href="#dfn-blank-node">Blank nodes</a> in the
<a href="#dfn-output-dataset">output dataset</a> are
scoped to a single <a href="#dfn-rdf-graph">RDF graph</a>.
If the same <a href="#dfn-blank-node-identifier">blank node identifier</a>
occurs in multiple <a href="#dfn-rdf-triple">RDF triples</a>
that are in the same graph, then the triples will share the
same single blank node.
If, however, the same blank node identifier occurs in multiple graphs,
then a distinct blank node is created for each graph. An R2RML-generated
blank node can never be shared by two triples in two different graphs.</p>
<p>This implies that triples generated from a single logical table row
will have different subjects if the subjects are blank nodes and the
triples are placed into different graphs.</p>
<h2 id="datatype-conversions">10 Datatype Conversions</h2>
<p>This section defines various conversion rules applicable
to data values. The rules are invoked in various places
throughout this specification, in particular around
<a href="#typed-literals"><code>rr:datatype</code></a>
and in hte <a href="#dfn-term-generation-rules">term generation rules</a>.</p>
<p>A <a href="#dfn-typed-literal">typed literal</a> of a
<a href="#dfn-supported-rdf-datatype">supported RDF datatype</a> is
<dfn id="dfn-ill-typed">ill-typed</dfn> if its
<a href="#dfn-lexical-form">lexical form</a> is not in the
<a href="#dfn-lexical-space">lexical space</a> of the RDF datatype
identified by its <a href="#dfn-datatype-iri">datatype IRI</a>.</p>
<p>For example, <code>"X"^^xsd:boolean</code> is ill-typed because
“<code>X</code>” is not in the
<a href="http://www.w3.org/TR/xmlschema-2/#boolean">lexical space of
<code>xsd:boolean</code></a>
[<cite><a href="#XMLSCHEMA2">XMLSCHEMA2</a></cite>].</p>
<h3 id="datatype-table">10.1 Table of Corresponding Datatypes</h3>
<p>The <dfn id="dfn-corresponding-rdf-datatype">corresponding RDF
datatype</dfn> of a SQL datatype is given in the table below, or
<code>empty</code> if the SQL datatype does not occur in the table.</p>
<p>The <dfn id="dfn-rdf-transformation">RDF transformation</dfn> of a
SQL datatype is a transformation rule given in the table below, or
<em><a href="#dfn-conversion-to-string">conversion to string</a></em>
if the SQL datatype does not occur in the table.</p>
<p>The <dfn id="dfn-supported-rdf-datatype">supported RDF datatypes</dfn>
are the datatypes for which an implementation can detect
<a href="#dfn-ill-typed">ill-typed</a> literals. This set
<em class="rfc2119">MUST</em> include all datatypes mentioned
in the table below in the column “Corresponding RDF datatype”,
according to their definitions in
[<cite><a href="#XMLSCHEMA2">XMLSCHEMA2</a></cite>].
This set <em class="rfc2119">MAY</em> include arbitrary further
datatypes.</p>
<table rules="all" summary="The RDF datatypes and transformations corresponding to SQL datatypes">
<tr>
<th>SQL datatype</th>
<th>Corresponding RDF datatype</th>
<th>Transformation</th>
</tr>
<tr>
<td><code>BINARY</code>, <code>BINARY VARYING</code>, <code>BINARY LARGE OBJECT</code></td>
<td><code>xsd:base64Binary</code></td>
<td><a href="#dfn-base64-encoding">base64 encoding</a></td>
</tr>
<tr>
<td><code>NUMERIC</code>, <code>DECIMAL</code></td>
<td><code>xsd:decimal</code></td>
<td><a href="#dfn-conversion-to-string">conversion to string</a></td>
</tr>
<tr>
<td><code>SMALLINT</code>, <code>INTEGER</code>, <code>BIGINT</code></td>
<td><code>xsd:integer</code></td>
<td><a href="#dfn-conversion-to-string">conversion to string</a></td>
</tr>
<tr>
<td><code>FLOAT</code>, <code>REAL</code>, <code>DOUBLE PRECISION</code></td>
<td><code>xsd:double</code></td>
<td><a href="#dfn-conversion-to-string">conversion to string</a></td>
</tr>
<tr>
<td><code>BOOLEAN</code></td>
<td><code>xsd:boolean</code></td>
<td><a href="#dfn-conversion-to-boolean">conversion to boolean</a></td>
</tr>
<tr>
<td><code>DATE</code></td>
<td><code>xsd:date</code></td>
<td><a href="#dfn-conversion-to-datetime">conversion to datetime</a></td>
</tr>
<tr>
<td><code>TIME</code></td>
<td><code>xsd:time</code></td>
<td><a href="#dfn-conversion-to-datetime">conversion to datetime</a></td>
</tr>
<tr>
<td><code>TIMESTAMP</code></td>
<td><code>xsd:dateTime</code></td>
<td><a href="#dfn-conversion-to-datetime">conversion to datetime</a></td>
</tr>
<tr>
<td><code>INTERVAL</code></td>
<td>undefined</td>
<td>undefined</td>
</tr>
</table>
<div class="note">
<p>Any types not appearing in the table, including all character
string types and vendor-specific types, will default to producing RDF
<a href="#dfn-plain-literal">plain literals</a> by using
<a href="#dfn-conversion-to-string">conversion to string</a>.</p>
<p><a href="#dfn-r2rml-processor">R2RML processor</a> implementations
are expected to augment the table with additional rows for mapping
vendor-specific datatypes to appropriate XSD types.</p>
</div>
<p class="note">The translation of <code>INTERVAL</code> is left
undefined due to the complexity of the translation.
[<cite><a href="#SQL14">SQL14</a></cite>] describes a translation of
<code>INTERVAL</code> to <code>xdt:yearMonthDuration</code> and
<code>xdt:dayTimeDuration</code>.</p>
<p id="datatype-examples">The following table shows examples
of various SQL data values after
<a href="#dfn-conversion-to-string">conversion to string</a>, and a
<a href="#dfn-typed-literal">typed literal</a> of the
<a href="#dfn-corresponding-rdf-datatype">corresponding RDF datatype</a>,
derived by applying the SQL datatype's
<a href="#dfn-rdf-transformation">RDF transformation</a>:</p>
<table rules="all" summary="Examples of SQL data values converted to string and to typed literals">
<tr>
<th>SQL datatype</th>
<th>Conversion to string example</th>
<th>Typed literal example</th>
</tr>
<tr>
<td><code>DECIMAL</code></td>
<td><code>2000000000005.9</code></td>
<td><code>"2000000000005.9"^^xsd:decimal</code></td>
</tr>
<tr>
<td><code>DECIMAL</code></td>
<td><code>2000000000000</code></td>
<td><code>"2000000000000"^^xsd:decimal</code></td>
</tr>
<tr>
<td><code>INTEGER</code></td>
<td><code>-1</code></td>
<td><code>"-1"^^xsd:integer</code></td>
</tr>
<tr>
<td><code>REAL</code></td>
<td><code>5.0E-1</code></td>
<td><code>"5.0E-1"^^xsd:double</code></td>
</tr>
<tr>
<td><code>REAL</code></td>
<td><code>0E0</code></td>
<td><code>"0E0"^^xsd:double</code></td>
</tr>
<tr>
<td><code>DATE</code></td>
<td><code>DATE 2011-08-23</code></td>
<td><code>"2011-08-23"^^xsd:date</code></td>
</tr>
<tr>
<td><code>TIME</code></td>
<td><code>TIME 22:17:00</code></td>
<td><code>"22:17:00"^^xsd:time</code></td>
</tr>
<tr>
<td><code>TIME</code></td>
<td><code>TIME 22:17:00.0000</code></td>
<td><code>"22:17:00.0000"^^xsd:time</code></td>
</tr>
<tr>
<td><code>TIME</code></td>
<td><code>TIME 22:17:00+01:00</code></td>
<td><code>"22:17:00+01:00"^^xsd:time</code></td>
</tr>
<tr>
<td><code>TIMESTAMP</code></td>
<td><code>TIMESTAMP 2011-08-23 22:17:00</code></td>
<td><code>"2011-08-23T22:17:00"^^xsd:dateTime</code></td>
</tr>
</table>
<h3 id="to-string">10.2 Conversion to string</h3>
<p><dfn id="dfn-conversion-to-string">Conversion to string</dfn> is the process
of transforming a SQL data value to a Unicode string. Its result
<em class="rfc2119">MUST</em> be the same as evaluating the following
SQL expression, as defined in [<cite><a href="#SQL2">SQL2</a></cite>]:</p>
<pre>CAST(<em>value</em> AS CHARACTER VARYING(<em>max</em>))</pre>
<p>where <code><em>value</em></code> is the
<a href="#dfn-quoted-data-value">quoted and escaped form</a> of the
SQL data value, and <code><em>max</em></code> is the
implementation-dependent maximum length of a
variable-length character string.</p>
<div class="note">
<p>An informative summary of the rules for casting standard SQL 2008
datatypes to string follows. The right column of the table contains a
<a href="http://www.w3.org/TR/xmlschema-2/#regexs">regular expression</a>
that is matched by the string-converted form of all SQL data values of
the types in the left column:</p>
<table rules="all" summary="">
<tr><th>Type</th><th>Pattern</th></tr>
<tr><td><code>DECIMAL</code>, <code>NUMERIC</code></td><td><code>-?(\.\d+|\d+(\.\d+)?)</code></td></tr>
<tr><td><code>SMALLINT</code>, <code>INTEGER</code>, <code>BIGINT</code></td><td><code>-?\d+</code></td></tr>
<tr><td><code>FLOAT</code>, <code>REAL</code>, <code>DOUBLE PRECISION</code></td><td><code>0E0|-?[1-9]\.\d+</code></td></tr>
<tr><td><code>DATE</code></td><td><code>\d\d\d\d-\d\d-\d\d</code></td></tr>
<tr><td><code>TIME</code></td><td><code>\d\d:\d\d:\d\d(.\d+)?([+-]\d\d:\d\d)?</code></td></tr>
<tr><td><code>TIMESTAMP</code></td><td><code>\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d(.\d+)?([+-]\d\d:\d\d)?</code></td></tr>
<tr><td><code>BOOLEAN</code></td><td><code>TRUE|FALSE</code></td></tr>
</table>
<p>The result of conversion to string is always the shortest possible
string that, if interpreted as a SQL literal of the original SQL datatype,
has the same value as the original SQL data value. For example,
converting the <code>DECIMAL</code> value 1 to string yields <code>1</code>,
not the longer equal-valued strings <code>01</code> or <code>1.0</code>.</p>
</div>
<h3 id="to-boolean">10.3 Conversion to <code>xsd:boolean</code></h3>
<p><dfn id="dfn-conversion-to-boolean">Conversion to boolean</dfn>
is the process of transforming a SQL data value of datatype
<code>BOOLEAN</code> to a string that is compatible with the
<code>xsd:boolean</code> datatype. It consists of the following
steps:</p>
<ol>
<li>Apply <a href="#dfn-conversion-to-string">conversion to string</a>
to the SQL data value,</li>
<li>convert the resulting string to lowercase.</li>
</ol>
<p>Example: The result of converting a <code>BOOLEAN</code>
SQL data value to string is either <code>TRUE</code> or <code>FALSE</code>.
The resulting typed literal is either <code>"true"^^xsd:boolean</code> or
<code>"false"^^xsd:boolean</code>.</p>
<h3 id="datetime">10.4 Conversion to Datetime</h3>
<p><dfn id="dfn-conversion-to-datetime">Conversion to datetime</dfn>
is the process of transforming a SQL data value of datatype
<code>DATE</code>, <code>TIME</code> or <code>TIMESTAMP</code>
to a string that is compatible with the corresponding XSD datatype.
It consists of the following steps:</p>
<ol>
<li>Apply <a href="#dfn-conversion-to-string">conversion to string</a>
to the SQL data value.</li>
<li>Remove any initial string “<code>DATE</code>”,
“<code>TIME</code>” or “<code>TIMESTAMP</code>” and any leading spaces
from the resulting string.</li>
<li>If the SQL data value is of datatype <code>TIMESTAMP</code>,
then replace the 11th character of the string (a space) with an
upper-case “<code>T</code>”.</li>
</ol>
<p>Any fractional seconds and/or time zone interval present after
conversion to string is included in the resulting string.</p>
<p><a href="#datatype-examples">Examples for conversion to datetime</a>
can be found in the table above.</p>
<h3 id="binary">10.5 Conversion to <code>xsd:base64Binary</code></h3>
<p><dfn id="dfn-base64-encoding">Base64 encoding</dfn> is the process
of transforming a binary SQL data value to a string that is compatible with
the <code>xsd:base64Binary</code> datatype, by applying
<a href="http://www.w3.org/TR/xmlschema-2/#base64Binary">base64
encoding as restricted for <code>xsd:base64Binary</code></a>
[<cite><a href="#XMLSCHEMA2">XMLSCHEMA2</a></cite>] on the binary
value.</p>
<h2 id="generated-rdf">11 The Output Dataset</h2>
<p>The <dfn id="dfn-output-dataset">output dataset</dfn> of an
R2RML mapping is an <a href="#dfn-rdf-dataset">RDF dataset</a>
that contains the
<a href="#dfn-generating-rdf-triples">generated RDF triples</a>
for each of the <a href="#dfn-triples-map">triples maps</a> of
the R2RML mapping. The output dataset <em class="rfc2119">MUST NOT</em>
contain any other <a href="#dfn-rdf-triple">RDF triples</a> or
<a href="#dfn-named-graph">named graphs</a> besides these.</p>
<p>If a table or column is not explicitly referenced in a
<a href="#dfn-triples-map">triples map</a>,
then no <a href="#dfn-rdf-triple">RDF triples</a>
will be generated for that table or column.</p>
<p>Conforming <a href="#dfn-r2rml-processor">R2RML processors</a>
<em class="rfc2119">MAY</em> rename
<a href="#dfn-blank-node">blank nodes</a> when providing
access to the <a href="#dfn-output-dataset">output dataset</a>.
This means that client applications may see actual
<a href="#dfn-blank-node-identifier">blank node identifiers</a>
that differ from those produced by the
<a href="#dfn-r2rml-mapping">R2RML mapping</a>. Client applications
<em class="rfc2119">SHOULD NOT</em>
rely on the specific text of the blank node identifier for any purpose.</p>
<p class="note"><a href="#dfn-rdf-dataset">RDF datasets</a> may
contain empty <a href="#dfn-named-graph">named graphs</a>.
R2RML cannot generate such output datasets.</p>
<h3 id="generated-triples">11.1 The Generated RDF Triples of a Triples Map</h3>
<p>This subsection describes the process of
<dfn id="dfn-generating-rdf-triples">generating RDF triples</dfn>
from a <a href="#dfn-triples-map">triples map</a>. This process adds
<a href="#dfn-rdf-triple">RDF triples</a> to the
<a href="#dfn-output-dataset">output dataset</a>. Each generated triple
is placed into one or more particular graphs of the output dataset.</p>
<p>The generated RDF triples are determined by the following algorithm.
R2RML processors <em class="rfc2119">MAY</em> use other means than
implementing this algorithm to compute the generated RDF triples,
as long as the result is the same.</p>
<ol>
<li>Let <code><em>sm</em></code> be the
<a href="#dfn-subject-map">subject map</a> of the triples map</li>
<li>Let <code><em>rows</em></code> be the result of evaluating the
<a href="#dfn-effective-sql-query">effective SQL query</a>
of the <a href="#dfn-triples-map">triples map</a>'s
<a href="#dfn-logical-table">logical table</a> using the
<a href="#dfn-sql-connection">SQL connection</a></li>
<li>Let <code><em>classes</em></code> be the
<a href="#dfn-class-iri">class IRIs</a> of <code><em>sm</em></code></li>
<li>Let <code><em>sgm</em></code> be the set of
<a href="#dfn-graph-map">graph maps</a> of <code><em>sm</em></code></li>
<li>For each <a href="#dfn-logical-table-row">logical table row</a>
<code><em>row</em></code> in <code><em>rows</em></code>,
apply the following steps:
<ol>
<li>Let <code><em>subject</em></code> be the
<a href="#dfn-generated-rdf-terms">generated RDF term</a> that results
from applying <code><em>sm</em></code> to
<code><em>row</em></code></li>
<li>Let <code><em>subject_graphs</em></code> be the union of
the <a href="#dfn-generated-rdf-terms">generated RDF terms</a>
that result from applying any term maps in <code><em>sgm</em></code>
to <code><em>row</em></code></li>
<li>If <code><em>classes</em></code> is not empty, then for each
<a href="#dfn-iri">IRI</a> in <code><em>classes</em></code>,
<a href="#dfn-adding-triples">add the following triples</a> to the
output dataset:
<p>
<strong>Subject:</strong> <code><em>subject</em></code><br />
<strong>Predicate:</strong> <code>rdf:type</code><br />
<strong>Object:</strong> <code><em>classes</em></code><br />
<strong>Target graphs:</strong> If <code><em>sgm</em></code> is empty:
<code>rr:defaultgraph</code>;
otherwise: <code><em>subject_graphs</em></code>
</p>
</li>
<li>For each <a href="#dfn-predicate-object-map">predicate-object map</a>
of the <a href="#dfn-triples-map">triples map</a>, apply the following
steps:
<ol>
<li>If the predicate-object map has no
<a href="#dfn-object-map">object map</a> (but a
<a href="#dfn-referencing-object-map">referencing object map</a>), then
skip these substeps for this predicate-object map</li>
<li>Let <code><em>predicate</em></code> be the
<a href="#dfn-generated-rdf-terms">generated RDF term</a> that results
from applying the predicate-object map's
<a href="#dfn-predicate-map">predicate map</a>
to <code><em>row</em></code></li>
<li>Let <code><em>object</em></code> be the
<a href="#dfn-generated-rdf-terms">generated RDF term</a> that results
from applying the predicate-object map's
<a href="#dfn-object-map">object map</a>
to <code><em>row</em></code></li>
<li>Let <code><em>pogm</em></code> be the set of
<a href="#dfn-graph-map">graph maps</a> of the predicate-object map</li>
<li>Let <code><em>predicate-object_graphs</em></code> be the union of
the <a href="#dfn-generated-rdf-terms">generated RDF terms</a>
that result from applying any <a href="#dfn-graph-map">graph maps</a> in <code><em>pogm</em></code>
to <code><em>row</em></code></li>
<li><a href="#dfn-adding-triples">Add the following triples</a>
to the output dataset:
<p>
<strong>Subject:</strong> <code><em>subject</em></code><br />
<strong>Predicate:</strong> <code><em>predicate</em></code><br />
<strong>Object:</strong> <code><em>object</em></code><br />
<strong>Target graphs:</strong> If <code><em>sgm</em></code> and
<code><em>pogm</em></code> are empty: <code>rr:defaultGraph</code>;
otherwise: union of <code><em>subject_graphs</em></code>
and <code><em>predicate-object_graphs</em></code>
</p>
</li>
</ol>
</li>
</ol>
</li>
<li>For each <a href="#dfn-predicate-object-map">predicate-object map</a>
of the <a href="#dfn-triples-map">triples map</a>, apply the following
steps:
<ol>
<li>If the predicate-object map has no
<a href="#dfn-referencing-object-map">referencing object map</a> (but a
normal <a href="#dfn-object-map">object map</a>), then
skip these substeps for this predicate-object map</li>
<li>Let <code><em>psm</em></code> be the
<a href="#dfn-subject-map">subject map</a> of the
<a href="#dfn-parent-triples-map">parent triples map</a> of the
referencing object map</li>
<li>Let <code><em>pogm</em></code> be the set of
<a href="#dfn-graph-map">graph maps</a> of the predicate-object map</li>
<li>Let <code><em>rows</em></code> be the result of evaluating the
<a href="#dfn-joint-sql-query">joint SQL query</a>
of the referencing object map</li>
<li>For each <code><em>row</em></code> in <code><em>rows</em></code>,
apply the following steps:
<ol>
<li>Let <code><em>child_row</em></code> be the subset of
<code><em>row</em></code> whose columns are present in
the referencing object map's
<a href="#dfn-child-query">child query</a></li>
<li>Let <code><em>parent_row</em></code> be the subset of
<code><em>row</em></code> whose columns are present in
the referencing object map's
<a href="#dfn-parent-query">parent query</a></li>
<li>Let <code><em>subject</em></code> be the
<a href="#dfn-generated-rdf-terms">generated RDF term</a> that results
from applying <code><em>sm</em></code> to
<code><em>child_row</em></code></li>
<li>Let <code><em>predicate</em></code> be the
<a href="#dfn-generated-rdf-terms">generated RDF term</a> that results
from applying the predicate-object map's
<a href="#dfn-predicate-map">predicate map</a>
to <code><em>child_row</em></code></li>
<li>Let <code><em>object</em></code> be the
<a href="#dfn-generated-rdf-terms">generated RDF term</a> that results
from applying <code><em>psm</em></code> to
<code><em>parent_row</em></code></li>
<li>Let <code><em>subject_graphs</em></code> be the union of the
<a href="#dfn-generated-rdf-terms">generated RDF terms</a>
that result from applying any
<a href="#dfn-graph-map">graph maps</a> of <code><em>sgm</em></code>
to <code><em>child_row</em></code></li>
<li>Let <code><em>predicate-object_graphs</em></code> be the union of the
<a href="#dfn-generated-rdf-terms">generated RDF terms</a>
that result from applying any
<a href="#dfn-graph-map">graph maps</a> in <code><em>pogm</em></code>
to <code><em>child_row</em></code></li>
<li><a href="#dfn-adding-triples">Add the following triples</a>
to the output dataset:
<p>
<strong>Subject:</strong> <code><em>subject</em></code><br />
<strong>Predicate:</strong> <code><em>predicate</em></code><br />
<strong>Object:</strong> <code><em>object</em></code><br />
<strong>Target graphs:</strong> If neither <code><em>sgm</em></code>
nor <code><em>pogm</em></code> has any <a href="#dfn-graph-map">graph
maps</a>: <code>rr:defaultGraph</code>; otherwise: union of
<code><em>subject_graphs</em></code>
and <code><em>predicate-object_graphs</em></code>
</p>
</li>
</ol>
</li>
</ol>
</li>
</ol>
<p>The process of <dfn id="dfn-adding-triples">adding triples
to the output dataset</dfn> takes as its input:</p>
<ul>
<li><strong>Subjects</strong>, a set of zero or more
<a href="#dfn-iri">IRIs</a> or
<a href="#dfn-blank-node">blank nodes</a></li>
<li><strong>Predicates</strong>, a set of zero or more
<a href="#dfn-iri">IRIs</a></li>
<li><strong>Objects</strong>, a set of zero or more
<a href="#dfn-rdf-term">RDF terms</a></li>
<li><strong>Target graphs</strong>, a set of zero or more
<a href="#dfn-iri">IRIs</a></li>
</ul>
<p>For each possible combination <<em>s</em>, <em>p</em>, <em>o</em>>,
where <em>s</em> is a member of <em>Subjects</em>, <em>p</em> a member
of <em>Predicates</em> and <em>o</em> a member of <em>Objects</em>:</p>
<ol>
<li>Generate an <a href="#dfn-rdf-triple">RDF triple</a> <<em>s</em>, <em>p</em>,
<em>o</em>></li>
<li>If the set of target graphs includes <code>rr:defaultGraph</code>,
add the triple to the <a href="#dfn-default-graph">default graph</a>
of the <a href="#dfn-output-dataset">output dataset</a>.</li>
<li>For each <a href="#dfn-iri">IRI</a> in the set of target
graphs that is not equal to <code>rr:defaultGraph</code>,
add the triple to a <a href="#dfn-default-graph">named graph</a>
of that name in the <a href="#dfn-output-dataset">output dataset</a>.
If the output dataset does not contain a named graph with that IRI,
create it first.</li>
</ol>
<p><a href="#dfn-rdf-graph">RDF graphs</a> cannot contain duplicate
<a href="#dfn-rdf-triple">RDF triples</a>. Placing multiple equal
triples into the same graph has the same effect as placing it into
the graph only once.</p>
<h3 id="generated-rdf-terms">11.2 The Generated RDF Terms of a Term Map</h3>
<p>A <a href="#dfn-term-map">term map</a> is a function that generates
a set of <a href="#dfn-rdf-term">RDF terms</a> from a
<a href="#dfn-logical-table-row">logical table row</a>. The result of that
function can be:</p>
<ul>
<li>The empty set – if the term map references a <code>NULL</code> value,</li>
<li>A singleton set of one RDF term – the common case,</li>
<li>A <a href="#dfn-data-error">data error</a>.</li>
</ul>
<p>The <dfn id="dfn-generated-rdf-terms">generated RDF terms</dfn>
of a term map for a given logical table row are determined as follows:</p>
<ul>
<li>If the term map is a
<a href="#dfn-constant-valued-term-map">constant-valued term map</a>,
then the generated RDF terms are a singleton set containing
the term map's <a href="#dfn-constant-value">constant value</a>.</li>
<li>If the term map is a
<a href="#dfn-column-valued-term-map">column-valued term map</a>, then
the generated RDF terms are determined by applying the
<a href="#dfn-term-generation-rules">term generation rules</a> to its
<a href="#dfn-column-value">column value</a>.</li>
<li>If the term map is a
<a href="#dfn-template-valued-term-map">template-valued term map</a>, then
the generated RDF terms are determined by applying the
<a href="#dfn-term-generation-rules">term generation rules</a> to its
<a href="#dfn-template-value">template value</a>.</li>
</ul>
<p>The <dfn id="dfn-term-generation-rules">term generation rules</dfn>
are as follows:</p>
<ol>
<li>If the value is <code>NULL</code>, then no RDF term is generated.</li>
<li>Otherwise, if the <a href="#dfn-term-map">term map</a>'s
<a href="#dfn-term-type">term type</a> is <code>rr:IRI</code>:
<ol>
<li>Apply <a href="#dfn-conversion-to-string">conversion to string</a>
to the value.</li>
<li>If the value is a valid
<cite><a href="http://tools.ietf.org/html/rfc3987#section-2.2">
absolute IRI</a></cite> [<cite><a href="#RFC3987">RFC3987</a></cite>],
then generate an <a href="#dfn-iri">IRI</a>.</li>
<li>Otherwise, prepend the value with the
<a href="#dfn-base-iri">base IRI</a>. If the result is a valid
<cite><a href="http://tools.ietf.org/html/rfc3987#section-2.2">
absolute IRI</a></cite> [<cite><a href="#RFC3987">RFC3987</a></cite>],
then generate an <a href="#dfn-iri">IRI</a> from the result.</li>
<li>Otherwise, raise a <a href="#dfn-data-error">data error</a>.</li>
</ol>
</li>
<li>Otherwise, if the term type is <code>rr:BlankNode</code>:
<ol>
<li>Apply <a href="#dfn-conversion-to-string">conversion to string</a>
to the value.</li>
<li>Generate
a <a href="#dfn-blank-node-identifier">blank node</a> whose
<a href="#dfn-blank-node-identifier">blank node identifier</a>
is the value.</li>
</ol>
</li>
<li>Otherwise, if the term type is <code>rr:Literal</code>:
<ol>
<li>If the term map has a <a href="#dfn-specified-language-tag">specified
language tag</a>, then apply
<a href="#dfn-conversion-to-string">conversion to string</a>
to the value, and generate a
<a href="#dfn-plain-literal">plain literal</a> with that
language tag.</li>
<li>Otherwise, if a <a href="#dfn-datatype-override">datatype override</a>
is in effect on the term map:
<ol>
<li>Apply <a href="#dfn-conversion-to-string">conversion to string</a>
to the value.</li>
<li>Generate a <a href="#dfn-typed-literal">typed literal</a> whose
<a href="#dfn-datatype-iri">datatype IRI</a> is the
<a href="#dfn-specified-datatype">specified datatype</a>.</li>
<li>If the specified datatype is a
<a href="#dfn-supported-rdf-datatype">supported RDF datatype</a>
and the generated typed literal is
<a href="#dfn-ill-typed">ill-typed</a>, then raise a
<a href="#dfn-data-error">data error</a>.</li>
</ol>
</li>
<li>Otherwise, if the term map's
<a href="#dfn-implicit-datatype">implicit datatype</a> is
<code>empty</code>, then apply
<a href="#dfn-conversion-to-string">conversion to string</a>
to the value, and generate a
<a href="#dfn-plain-literal">plain literal</a> without
language tag.</li>
<li>Otherwise, apply the term map's
<a href="#dfn-implicit-transform">implicit transform</a>
to the value, and generate a
<a href="#dfn-typed-literal">typed literal</a> whose
<a href="#dfn-datatype-iri">datatype IRI</a> is the
<a href="#dfn-implicit-datatype">implicit datatype</a>.</li>
</ol>
</li>
</ol>
<p class="note">The algorithm uses simple string concatenation for
obtaining an absolute IRI from a relative IRI, rather than the more complex
algorithm defined in RFC 3986. This ensures that the original database
value can be reconstructed from the generated IRI.</p>
<h2 id="terminology">A. RDF Terminology (Informative)</h2>
<p>This section lists some terms normatively defined in other specifications.</p>
<p>The following terms are defined in <cite><em><a class="norm" href=
"http://www.w3.org/TR/2004/REC-rdf-concepts-20040210/">RDF Concepts and Abstract
Syntax</a></em></cite> [<cite><a href="#RDF">RDF</a></cite>] and used in R2RML:</p>
<ul>
<li><dfn id="dfn-rdf-graph"><a class="type rdfGraph" href=
"http://www.w3.org/TR/2004/REC-rdf-concepts-20040210/#dfn-rdf-graph">RDF
graph</a></dfn></li>
<li><dfn id="dfn-rdf-triple"><a href=
"http://www.w3.org/TR/2004/REC-rdf-concepts-20040210/#dfn-rdf-triple">RDF
triple</a></dfn></li>
<li><dfn id="dfn-iri"><a class="type IRI" href=
"http://www.w3.org/TR/2004/REC-rdf-concepts-20040210/#section-rdf-graph">IRI</a></dfn>
(corresponds to the Concepts and Abstract Syntax term <em>RDF URI
reference</em>)</li>
<li><dfn id="dfn-literal"><a class="type literal" href=
"http://www.w3.org/TR/2004/REC-rdf-concepts-20040210/#dfn-literal">literal</a></dfn></li>
<li><dfn id="dfn-plain-literal"><a class="type plainLiteral" href=
"http://www.w3.org/TR/2004/REC-rdf-concepts-20040210/#dfn-plain-literal">plain
literal</a></dfn></li>
<li><dfn id="dfn-typed-literal"><a class="type typedLiteral" href=
"http://www.w3.org/TR/2004/REC-rdf-concepts-20040210/#dfn-typed-literal">typed
literal</a></dfn></li>
<li><dfn id="dfn-language-tag"><a class="type langTag" href=
"http://www.w3.org/TR/2004/REC-rdf-concepts-20040210/#dfn-language-identifier">language
tag</a></dfn></li>
<li><dfn id="dfn-lexical-form"><a class="type lexicalForm" href=
"http://www.w3.org/TR/rdf-concepts/#dfn-lexical-form">lexical form</a></dfn></li>
<li><dfn id="dfn-datatype-iri"><a class="type datatypeIRI" href=
"http://www.w3.org/TR/2004/REC-rdf-concepts-20040210/#dfn-datatype-URI">datatype
IRI</a></dfn> (corresponds to the Concepts and Abstract Syntax term <em>datatype
URI</em>)</li>
<li><dfn id="dfn-lexical-space"><a class="type lexicalSpace" href=
"http://www.w3.org/TR/rdf-concepts/#dfn-lexical-space">lexical space</a></dfn></li>
<li><dfn id="dfn-blank-node"><a class="type bNode" href=
"http://www.w3.org/TR/2004/REC-rdf-concepts-20040210/#dfn-blank-node">blank
node</a></dfn></li>
<li><dfn id="dfn-blank-node-identifier"><a href=
"http://www.w3.org/TR/2004/REC-rdf-concepts-20040210/#dfn-blank-node-id">
blank node identifier</a></dfn></li>
</ul>
<p>The following terms are defined in <cite><em><a class="norm" href=
"http://www.w3.org/TR/2008/REC-rdf-sparql-query-20080115/">SPARQL Query Language for
RDF</a></em></cite> [<cite><a href="#SPARQL">SPARQL</a></cite>] and used in
R2RML:</p>
<ul>
<li><dfn id="dfn-rdf-dataset"><a href=
"http://www.w3.org/TR/2008/REC-rdf-sparql-query-20080115/#rdfDataset">RDF
dataset</a></dfn></li>
<li><dfn id="dfn-default-graph"><a href=
"http://www.w3.org/TR/2008/REC-rdf-sparql-query-20080115/#rdfDataset">default
graph</a></dfn></li>
<li><dfn id="dfn-named-graph"><a href=
"http://www.w3.org/TR/2008/REC-rdf-sparql-query-20080115/#rdfDataset">named
graph</a></dfn></li>
</ul>
<h2 id="index">B. Index of R2RML Vocabulary Terms (Informative)</h2>
<p>This appendix lists all the classes, properties and other terms
defined by this specification within the
<a href="#dfn-r2rml-vocabulary">R2RML vocabulary</a>.</p>
<p>An RDFS representation of the vocabulary is available from
the <a href="http://www.w3.org/ns/r2rml#">namespace IRI</a>.</p>
<h3 id="class-index">B.1 Classes</h3>
<table class="term-index">
<tr><th>Class</th><th>Represents</th></tr>
<tr><th><a href="http://www.w3.org/ns/r2rml#GraphMap"><code>rr:GraphMap</code></a></th>
<td><a href="#dfn-graph-map">graph map</a></td></tr>
<tr><th><a href="http://www.w3.org/ns/r2rml#Join"><code>rr:Join</code></a></th>
<td><a href="#dfn-join-condition">join condition</a></td></tr>
<tr><th><a href="http://www.w3.org/ns/r2rml#LogicalTable"><code>rr:LogicalTable</code></a></th>
<td><a href="#dfn-logical-table">logical table</a></td></tr>
<tr><th><a href="http://www.w3.org/ns/r2rml#ObjectMap"><code>rr:ObjectMap</code></a></th>
<td><a href="#dfn-object-map">object map</a></td></tr>
<tr><th><a href="http://www.w3.org/ns/r2rml#PredicateMap"><code>rr:PredicateMap</code></a></th>
<td><a href="#dfn-predicate-map">predicate map</a></td></tr>
<tr><th><a href="http://www.w3.org/ns/r2rml#PredicateObjectMap"><code>rr:PredicateObjectMap</code></a></th>
<td><a href="#dfn-predicate-object-map">predicate-object map</a></td></tr>
<tr><th><a href="http://www.w3.org/ns/r2rml#RefObjectMap"><code>rr:RefObjectMap</code></a></th>
<td><a href="#dfn-referencing-object-map">referencing object map</a></td></tr>
<tr><th><a href="http://www.w3.org/ns/r2rml#SubjectMap"><code>rr:SubjectMap</code></a></th>
<td><a href="#dfn-subject-map">subject map</a></td></tr>
<tr><th><a href="http://www.w3.org/ns/r2rml#TriplesMap"><code>rr:TriplesMap</code></a></th>
<td><a href="#dfn-triples-map">triples map</a></td></tr>
</table>
<h3 id="property-index">B.2 Properties</h3>
<p>The cardinality column indicates how often this property
occurs within its context. Note that additional constraints
not stated in this table might apply, and making a property
forbidden or required in certain situations.</p>
<table class="term-index">
<tr><th>Property</th><th>Represents</th><th>Context</th><th>Cardinality</th></tr>
<tr><th><a href="http://www.w3.org/ns/r2rml#child"><code>rr:child</code></a></th>
<td><a href="#dfn-child-column">child column</a></td>
<td><a href="#dfn-join-condition">join condition</a></td>
<td>1</td></tr>
<tr><th><a href="http://www.w3.org/ns/r2rml#class"><code>rr:class</code></a></th>
<td><a href="#dfn-class-iri">class IRI</a></td>
<td><a href="#dfn-subject-map">subject map</a></td>
<td>0…∞</td></tr>
<tr><th><a href="http://www.w3.org/ns/r2rml#column"><code>rr:column</code></a></th>
<td><a href="#dfn-column-valued-term-map">column name</a></td>
<td><a href="#dfn-column-valued-term-map">column-valued term map</a></td><td>1</td></tr>
<tr><th><a href="http://www.w3.org/ns/r2rml#datatype"><code>rr:datatype</code></a></th>
<td><a href="#dfn-specified-datatype">specified datatype</a></td>
<td><a href="#dfn-term-map">term map</a></td>
<td>0…1</td></tr>
<tr><th><a href="http://www.w3.org/ns/r2rml#constant"><code>rr:constant</code></a></th>
<td><a href="#dfn-constant-value">constant value</a></td>
<td><a href="#dfn-constant-valued-term-map">constant-valued term map</a></td>
<td>1</td></tr>
<tr><th><a href="http://www.w3.org/ns/r2rml#graph"><code>rr:graph</code></a></th>
<td><a href="#dfn-constant-shortcut-property">constant shortcut property</a></td>
<td><a href="#dfn-subject-map">subject map</a>, <a href="#dfn-predicate-object-map">predicate-object map</a></td>
<td>0…∞</td></tr>
<tr><th><a href="http://www.w3.org/ns/r2rml#graphMap"><code>rr:graphMap</code></a></th>
<td><a href="#dfn-graph-map">graph map</a></td>
<td><a href="#dfn-subject-map">subject map</a>, <a href="#dfn-predicate-object-map">predicate-object map</a></td>
<td>0…∞</td></tr>
<tr><th><a href="http://www.w3.org/ns/r2rml#inverseExpression"><code>rr:inverseExpression</code></a></th>
<td><a href="#dfn-inverse-expression">inverse-expression</a></td>
<td><a href="#dfn-term-map">term map</a></td>
<td>0…1</td></tr>
<tr><th><a href="http://www.w3.org/ns/r2rml#joinCondition"><code>rr:joinCondition</code></a></th>
<td><a href="#dfn-join-condition">join condition</a></td>
<td><a href="#dfn-referencing-object-map">referencing object map</a></td>
<td>0…∞</td></tr>
<tr><th><a href="http://www.w3.org/ns/r2rml#language"><code>rr:language</code></a></th>
<td><a href="#dfn-specified-language-tag">specified language tag</a></td>
<td><a href="#dfn-term-map">term map</a></td>
<td>0…1</td></tr>
<tr><th><a href="http://www.w3.org/ns/r2rml#logicalTable"><code>rr:logicalTable</code></a></th>
<td><a href="#dfn-triples-map">logical table</a></td>
<td><a href="#dfn-triples-map">triples map</a></td>
<td>1</td></tr>
<tr><th><a href="http://www.w3.org/ns/r2rml#object"><code>rr:object</code></a></th>
<td><a href="#dfn-constant-shortcut-property">constant shortcut property</a></td>
<td><a href="#dfn-predicate-object-map">predicate-object map</a></td>
<td>1</td></tr>
<tr><th><a href="http://www.w3.org/ns/r2rml#objectMap"><code>rr:objectMap</code></a></th>
<td><a href="#dfn-object-map">object map</a></td>
<td><a href="#dfn-predicate-object-map">predicate-object map</a></td>
<td>1</td></tr>
<tr><th><a href="http://www.w3.org/ns/r2rml#parent"><code>rr:parent</code></a></th>
<td><a href="#dfn-parent-column">parent column</a></td>
<td><a href="#dfn-join-condition">join condition</a></td>
<td>1</td></tr>
<tr><th><a href="http://www.w3.org/ns/r2rml#parentTriplesMap"><code>rr:parentTriplesMap</code></a></th>
<td><a href="#dfn-parent-triples-map">parent triples map</a></td>
<td><a href="#dfn-referencing-object-map">referencing object map</a></td>
<td>1</td></tr>
<tr><th><a href="http://www.w3.org/ns/r2rml#predicate"><code>rr:predicate</code></a></th>
<td><a href="#dfn-constant-shortcut-property">constant shortcut property</a></td>
<td><a href="#dfn-predicate-object-map">predicate-object map</a></td>
<td>1</td></tr>
<tr><th><a href="http://www.w3.org/ns/r2rml#predicateMap"><code>rr:predicateMap</code></a></th>
<td><a href="#dfn-predicate-map">predicate map</a></td>
<td><a href="#dfn-predicate-object-map">predicate-object map</a></td>
<td>1</td></tr>
<tr><th><a href="http://www.w3.org/ns/r2rml#predicateObjectMap"><code>rr:predicateObjectMap</code></a></th>
<td><a href="#dfn-triples-map">predicate-object map</a></td>
<td><a href="#dfn-triples-map">triples map</a></td>
<td>0…∞</td></tr>
<tr><th><a href="http://www.w3.org/ns/r2rml#sqlQuery"><code>rr:sqlQuery</code></a></th>
<td><a href="#dfn-sql-query">SQL query</a></td>
<td><a href="#dfn-r2rml-view">R2RML view</a></td>
<td>1</td></tr>
<tr><th><a href="http://www.w3.org/ns/r2rml#sqlVersion"><code>rr:sqlVersion</code></a></th>
<td><a href="#dfn-sql-version-identifier">SQL version identifier</a></td>
<td><a href="#dfn-r2rml-view">R2RML view</a></td>
<td>0…∞</td></tr>
<tr><th><a href="http://www.w3.org/ns/r2rml#subject"><code>rr:subject</code></a></th>
<td><a href="#dfn-constant-shortcut-property">constant shortcut property</a></td>
<td><a href="#dfn-triples-map">triples map</a></td>
<td>1</td></tr>
<tr><th><a href="http://www.w3.org/ns/r2rml#subjectMap"><code>rr:subjectMap</code></a></th>
<td><a href="#dfn-triples-map">subject map</a></td>
<td><a href="#dfn-triples-map">triples map</a></td>
<td>1</td></tr>
<tr><th><a href="http://www.w3.org/ns/r2rml#tableName"><code>rr:tableName</code></a></th>
<td><a href="#dfn-table-or-view-name">table or view name</a></td>
<td><a href="#dfn-sql-base-table-or-view">SQL base table or view</a></td>
<td>1</td></tr>
<tr><th><a href="http://www.w3.org/ns/r2rml#template"><code>rr:template</code></a></th>
<td><a href="#dfn-string-template">string template</a></td>
<td><a href="#dfn-template-valued-term-map">template-valued term map</a></td>
<td>1</td></tr>
<tr><th><a href="http://www.w3.org/ns/r2rml#termType"><code>rr:termType</code></a></th>
<td><a href="#dfn-term-type">term type</a></td>
<td><a href="#dfn-term-map">term map</a></td>
<td>0…1</td></tr>
</table>
<h3 id="other-index">B.3 Other Terms</h3>
<table class="term-index">
<tr><th>Term</th><th>Denotes</th><th>Used with property</th></tr>
<tr><th><a href="http://www.w3.org/ns/r2rml#defaultGraph"><code>rr:defaultGraph</code></a></th>
<td><a href="#dfn-default-graph">default graph</a></td>
<td><a href="#named-graphs"><code>rr:graph</code></a></td></tr>
<tr><th><a href="http://www.w3.org/ns/r2rml#SQL2008"><code>rr:SQL2008</code></a></th>
<td><a href="#conformance">Core SQL 2008</a></td>
<td><a href="#dfn-sql-version-identifier"><code>rr:sqlVersion</code></a></td></tr>
<tr><th><a href="http://www.w3.org/ns/r2rml#IRI"><code>rr:IRI</code></a></th>
<td><a href="#dfn-iri">IRI</a></td>
<td><a href="#dfn-term-type"><code>rr:termType</code></a></td></tr>
<tr><th><a href="http://www.w3.org/ns/r2rml#BlankNode"><code>rr:BlankNode</code></a></th>
<td><a href="#dfn-blank-node">blank node</a></td>
<td><a href="#dfn-term-type"><code>rr:termType</code></a></td></tr>
<tr><th><a href="http://www.w3.org/ns/r2rml#Literal"><code>rr:Literal</code></a></th>
<td><a href="#dfn-literal">literal</a></td>
<td><a href="#dfn-term-type"><code>rr:termType</code></a></td></tr>
</table>
<h2 id="references">C. References</h2>
<h3 id="normative-refs">C.1 Normative References</h3>
<dl>
<dt><a id="RDF" name="RDF">[RDF]</a></dt>
<dd><cite><a href="http://www.w3.org/TR/2004/REC-rdf-concepts-20040210/">Resource
Description Framework (RDF): Concepts and Abstract Syntax</a></cite>, Graham Klyne,
Jermey J. Carroll, Editors. World Wide Web Consortium, 10 February 2004. This
version is http://www.w3.org/TR/2004/REC-rdf-concepts-20040210/. The latest version
is http://www.w3.org/TR/rdf-concepts/.</dd>
<dt><a id="RFC2119" name="RFC2119">[RFC2119]</a></dt>
<dd><cite><a href="http://tools.ietf.org/html/rfc2119">Key words
for use in RFCs to Indicate Requirement Levels</a></cite>, S. Bradner,
March 1997.
Internet RFC 2119, http://tools.ietf.org/html/rfc2119.</dd>
<dt><a id="RFC3629" name="RFC3629">[RFC3629]</a></dt>
<dd><cite><a href="http://tools.ietf.org/html/rfc3629">UTF-8, a
transformation format of ISO 10646</a></cite>, F. Yergeau. November 2003.
Internet RFC 3629, http://tools.ietf.org/html/rfc3629.</dd>
<dt><a id="RFC3986" name="RFC3986">[RFC3986]</a></dt>
<dd><cite><a href="http://tools.ietf.org/html/rfc3986">Uniform Resource
Identifier (URI): Generic Syntax</a></cite>, T. Berners-Lee, R. Fielding,
L. Masinter. January 2005.
Internet RFC 3986, http://tools.ietf.org/html/rfc3986.</dd>
<dt><a id="RFC3987" name="RFC3987">[RFC3987]</a></dt>
<dd><cite><a href="http://tools.ietf.org/html/rfc3987">Internationalized
Resource Identifiers (IRIs)</a></cite>, M. Duerst, M. Suignard. January 2005.
Internet RFC 3987, http://tools.ietf.org/html/rfc3987.</dd>
<dt><a id="SPARQL" name="SPARQL">[SPARQL]</a></dt>
<dd><cite><a href="http://www.w3.org/TR/2008/REC-rdf-sparql-query-20080115/">SPARQL
Query Language for RDF</a></cite>, Eric Prud'hommeaux, Andy Seaborne, Editors.
World Wide Web Consortium, 15 January 2008. This version is
http://www.w3.org/TR/2008/REC-rdf-sparql-query-20080115/. The latest version is
http://www.w3.org/TR/rdf-sparql-query/.</dd>
<dt><a id="SQL1" name="SQL1">[SQL1]</a></dt>
<dd><cite>ISO/IEC 9075-1:2008 SQL - Part 1: Framework (SQL/Framework)</cite>.
International Organization for
Standardization, 27 January 2009.</dd>
<dt><a id="SQL2" name="SQL2">[SQL2]</a></dt>
<dd><cite>ISO/IEC 9075-2:2008 SQL - Part 2: Foundation (SQL/Foundation)</cite>.
International Organization for
Standardization, 27 January 2009.</dd>
<dt><a id="TURTLE" name="TURTLE">[TURTLE]</a></dt>
<dd><cite><a href=
"http://www.w3.org/TeamSubmission/2008/SUBM-turtle-20080114/">Turtle - Terse RDF
Triple Language</a></cite>, Dave Beckett, Tim Berners-Lee. World Wide Web
Consortium, 14 January 2008. This version is
http://www.w3.org/TeamSubmission/2008/SUBM-turtle-20080114/. The latest version is
http://www.w3.org/TeamSubmission/turtle/.</dd>
<dt><a id="XMLSCHEMA2" name="XMLSCHEMA2">[XMLSCHEMA2]</a></dt>
<dd><cite><a href="http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/">XML
Schema Part 2: Datatypes Second Edition</a></cite>,
Paul V. Biron, Ashok Malhotra. World Wide Web Consortium,
28 October 2004. This version is
http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/.
The latest version is http://www.w3.org/TR/xmlschema-2/.</dd>
</dl>
<h3 id="non-normative-refs">C.2 Other References</h3>
<dl>
<dt><a id="DM" name="DM">[DM]</a></dt>
<dd><cite><a href="http://www.w3.org/TR/2011/WD-rdb-direct-mapping-20110920/">A
Direct Mapping of Relational Data to RDF</a></cite>, Alexandre Bertails, Marcelo Arenas,
Eric Prud'hommeaux, Juan Sequeda, Editors. World Wide Web Consortium, 20 September 2011.
This version is http://www.w3.org/TR/2011/WD-rdb-direct-mapping-20110920/. The latest
version is http://www.w3.org/TR/rdb-direct-mapping/. This document is work in
progress.</dd>
<dt><a id="SQL14" name="SQL14">[SQL14]</a></dt>
<dd><cite>ISO/IEC 9075-14:2008 SQL - Part 14: XML-Related Specifications (SQL/XML)</cite>.
International Organization for Standardization, 27 January 2009.</dd>
<dt><a id="SQLIRIS" name="SQLIRIS">[SQLIRIS]</a></dt>
<dd><cite><a href="http://www.w3.org/2001/sw/rdb2rdf/wiki/SQL_Version_IRIs">SQL
Version IRIs</a></cite>, Members of the W3C RDB2RDF Working Group.
The latest version is http://www.w3.org/2001/sw/rdb2rdf/wiki/SQL_Version_IRIs.
This is a public wiki page.</dd>
<dt><a id="TC" name="TC">[TC]</a></dt>
<dd><cite><a href="http://www.w3.org/2001/sw/rdb2rdf/test-cases/">R2RML and Direct Mapping Test Cases (Editor's Draft)</a></cite>, Boris Villazón-Terrazas, Michael Hausenblas, Alexander de Leon, Editors. World Wide Web Consortium, 31 August 2011. The latest version is http://www.w3.org/2001/sw/rdb2rdf/test-cases/. This document is work in progress.</dd>
<dt><a id="UCNR" name="UCNR">[UCNR]</a></dt>
<dd><cite><a href="http://www.w3.org/TR/2010/WD-rdb2rdf-ucr-20100608/">Use Cases
and Requirements for Mapping Relational Databases to RDF</a></cite>, Eric
Prud'hommeaux, Michael Hausenblas, Editors. World Wide Web Consortium, 8 June 2010.
This version is http://www.w3.org/TR/2010/WD-rdb2rdf-ucr-20100608/. The latest
version is http://www.w3.org/TR/rdb2rdf-ucr/. This document is work in
progress.</dd>
</dl>
<h2 id="acknowledgements">D. Acknowledgements (Informative)</h2>
<p>The Editors would like to give special thanks to the following members: Nuno Lopes for help in designing the datatyping related text, David McNeil for raising many of the issues that needed addressing, Eric Prud'hommeaux for designing the SQL compatibility text, and Boris Villazón-Terrazas for drawing all the diagrams.
</p>
<p>In addition, the Editors gratefully acknowledge contributions from: Marcelo Arenas, Sören Auer, Samir Batla, Alexander de Leon, Orri Erling, Lee Feigenbaum, Enrico Franconi, Howard Greenblatt, Wolfgang Halb, Harry Halpin, Michael Hausenblas, Patrick Hayes, Ivan Herman, Nophadol Jekjantuk, Li Ma, Nan Ma, Ashok Malhotra, Ivan Mikhailov, Percy Enrique Rivera Salas, Juan Sequeda, Ben Szekely, Ted Thibodeau, and Edward Thomas.
</p>
</div>
</body>
</html>