- From: Gregg Kellogg <gregg@greggkellogg.net>
- Date: Mon, 12 Oct 2015 09:38:17 -0700
- To: Colin Maudry <colin@maudry.com>
- Cc: public-csv-wg@w3.org, Axel Haustant <axel.haustant@data.gouv.fr>
> On Oct 12, 2015, at 6:57 AM, Colin Maudry <colin@maudry.com> wrote:
>
> Hello,
>
> For a given column, we would like to be able to define a fixed list of values that this column is supposed to contain. In SQL terms that's an ENUM type.
>
> One of the solutions offered here [1] is to use the "format" property, followed by a regex:
>
> "format" : "value1|value2|value3"
>
> However, we see several problems with this solution:
>
> - it's not easy to reuse somewhere else as a reusable object
> - the value of "format" requires parsing
> - we can't document the values with comments
>
> A potential and cleaner solution would be to create schema:Enumeration objects. Problem: I don't know how to connect the csvw:Column object with the schema:Enumeration [2] object. Any idea?
You might consider the use of a foreign key constraint against another table, for which output may be suppressed. Check out example 27 in the csv-metadata for an example [1].
Following your suggestion, if the column value can easily be turned into a URI using valueUrl, then you could create something like `ex:Male` from the column value “Male” by setting valueUrl to something like “http://example.org/{col}” where “col” is the name of the column containing the values you want to map. You could add an annotation to define `ex:Genders` using a common property. This might look something like the following:
{
“@type”: “Table”,
“schema:valueReference”: [{
“@id”: “http://example.org/Genders”,
“rdfs:subClassOf”: “schema:Enumeration"
}, {
“@id”: “http://example.org/Female”,
“@type”: "http://example.org/Genders"
}, {
“@id”: “http://example.org/Male”,
“@type”: "http://example.org/Genders"
}, {
“@id”: “http://example.org/Other”,
“@type”: "http://example.org/Genders"
}],
“tableSchema”: {
“columns”: [{“name”: “col”, “valueUrl”: “http://example.org/{col}”}]
}
}
You could even combine the two, so that a validator would ensure that only URIs in the target vocabulary were used.
> The thread mentioned above [1] seems to end up recommending using XSD schema files to declare enumerations, but I'm not comfortable with doing so outside of the JSON-LD/RDF realm. I think it would make the validation script more complex because less web-friendly. I'd rather declare them in a separate JSON-LD file.
>
> FYI, values of an enumeration and their schema:Enumeration object are expressed this way:
>
> ex:Genders rdfs:subClassOf schema:Enumeration .
> ex:Female rdf:type ex:Genders .
> ex:Male rdf:type ex:Genders .
> ex:Other rdf:type ex:Genders .
Gregg Kellogg
[3] http://w3c.github.io/csvw/metadata/#foreign-key-reference-between-tables
> [1] https://github.com/w3c/csvw/issues/223
> [2] http://schema.org/Enumeration
>
> Thanks!
> Colin
Received on Monday, 12 October 2015 16:38:49 UTC