On Standard Mappings from SQL Data Types to XML Schema (XSD) Data Types
Part 14 of ISO's SQL:2008 specification, specifically ISO/IEC 9075-14:2008, also contains a normative mapping from SQL datatypes to XML Schema datatypes.
The purpose of this page is to document why the RDB2RDF Working Group decided to create a new mapping, instead of re-using the standard mapping defined in the official SQL specification.
This was done for the following reasons:
- The SQL specifications are not available free of charge. As R2RML should be implementable without paying for specifications (assuming availability of a SQL implementation), the W3C spec would need to duplicate part of the ISO spec, regardless of whether the same or a different mapping is used.
- ISO's mapping attempts to exactly capture the constraints that apply to various SQL datatypes, including maximum sizes and the like, by using XSD facets. But R2RML does not define a schema (RDFS vocabulary or OWL ontology) for the output RDF dataset. It is assumed that any such schema is pre-existing, or at any rate created using some mechanism outside of the scope of R2RML. R2RML only generates instance data. In RDF instance data, it makes little sense to capture information like the maximum length of a string or the maximum size of a number. In the RDF world, such custom XSD types are rarely used; it's almost always just the built-in XSD types. Therefore, R2RML maps SQL types only to built-in XSD types.
- Turtle and SPARQL, two core specs in the same ecosystem as R2RML, provide convenient syntactic sugar for xsd:integer and xsd:decimal. Therefore, these types were used when possible, even if a more precise derived type exists.
- The ISO mapping leaves some choices up to implementers, for example whether binary types should be mapped to xsd:hexBinary or xsd:base64Binary. To maximise compatibility, R2RML enforces a particular choice.