You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/docs/guides/csvw-data-package.md
+6-6Lines changed: 6 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -86,7 +86,7 @@ Data Package can define more than groups of tables. A [package](/standard/data-p
86
86
87
87
### Tables
88
88
89
-
| CSVW property | Data package support | Details |
89
+
| CSVW property | Data Package support | Details |
90
90
| ---- | ---- | ---- |
91
91
|[url](http://table-url)| Yes | As [resource.path](/standard/data-resource/#path-or-data)|
92
92
|[dialect](https://www.w3.org/TR/2015/REC-tabular-metadata-20151217/#table-dialect)| Yes | As [resource.dialect](/standard/data-resource/#dialect)|
@@ -104,7 +104,7 @@ Data Package can define more than groups of tables. A [package](/standard/data-p
104
104
Data Package [Table Schema](/standard/table-schema/) has features that CSVW schema does not, including [fieldMatch](/standard/table-schema/#fieldsMatch) for matching a schema with data, [missingValues](/standard/table-schema/#missingValues) for multiple (and labelled) missing values, and [uniqueKeys](/standard/table-schema/#uniqueKeys).
105
105
:::
106
106
107
-
| CSVW property | Data package support | Details |
107
+
| CSVW property | Data Package support | Details |
108
108
| ---- | ---- | ---- |
109
109
|[columns](https://www.w3.org/TR/2015/REC-tabular-metadata-20151217/#schema-columns)| Yes | As [schema.fields](/standard/table-schema/#fields)|
110
110
|[foreignKeys](https://www.w3.org/TR/2015/REC-tabular-metadata-20151217/#schema-foreignKeys)| Yes | As [schema.foreignKeys](/standard/table-schema/#foreignKeys)|
@@ -115,7 +115,7 @@ Data Package [Table Schema](/standard/table-schema/) has features that CSVW sche
115
115
116
116
### Columns
117
117
118
-
| CSVW property | Data package support | Details |
118
+
| CSVW property | Data Package support | Details |
119
119
| ---- | ---- | ---- |
120
120
|[name](https://www.w3.org/TR/2015/REC-tabular-metadata-20151217/#column-name)| Yes | As [field.name](/standard/table-schema/#name)|
121
121
|[suppressOutput](https://www.w3.org/TR/2015/REC-tabular-metadata-20151217/#column-suppressOutput)| No ||
@@ -128,7 +128,7 @@ Data Package [Table Schema](/standard/table-schema/) has features that CSVW sche
128
128
129
129
Data Package properties do not inherit from their parent, unless otherwise specified (e.g. [resource.sources](/standard/data-resource/#sources)). The properties listed below only exist at one level in Data Package, except for `missingValues`.
130
130
131
-
| CSVW property | Data package support | Details |
131
+
| CSVW property | Data Package support | Details |
|[datatype](http://cell-datatype)| Yes | As [field.type](/standard/table-schema/#type-and-format)|
@@ -152,7 +152,7 @@ Common properties can be added in Data Package as [custom properties](/standard/
152
152
Data Package [Table Dialect](/standard/table-dialect/) was used as inspiration for CSVW dialect. It has features that CSVW dialect does not, since it covers tabular data formats beyond delimited text files, such as spreadsheets and databases. For delimited text files it supports [headerJoin](/standard/table-dialect/#headerJoin), [doubleQuote](/standard/table-dialect/#doubleQuote), [escapeChar](/standard/table-dialect/#escapeChar), and [nullSequence](/standard/table-dialect/#nullSequence), which CSVW does not.
153
153
:::
154
154
155
-
| CSVW property | Data package support | Details |
155
+
| CSVW property | Data Package support | Details |
156
156
| ---- | ---- | ---- |
157
157
|[commentPrefix](https://www.w3.org/TR/2015/REC-tabular-metadata-20151217/#dialect-commentPrefix)| Yes | As [dialect.commentChar](/standard/table-dialect/#commentChar)|
158
158
|[delimiter](https://www.w3.org/TR/2015/REC-tabular-metadata-20151217/#dialect-delimiter)| Yes | As [dialect.delimiter](/standard/table-dialect/#delimiter)|
@@ -182,7 +182,7 @@ CSVW defines data types as built-in data types and derived data types. A derived
182
182
Data Package [Table Schema](/standard/table-schema/) supports data types that CSVW does not, such as (labelled) [categories](/standard/table-schema/#categories) and [geojson](/standard/table-schema/#geojson). It also supports a number of constraints that CSVW does not, such as [unique](/standard/table-schema/#unique) values, [pattern](/standard/table-schema/#pattern) for regex comparison and [enum](/standard/table-schema/#enum) for controlled values, which allow rigorous data validation.
183
183
:::
184
184
185
-
| CSVW property | Data package support | Details |
185
+
| CSVW property | Data Package support | Details |
186
186
| ---- | ---- | ---- |
187
187
|[base](https://www.w3.org/TR/2015/REC-tabular-metadata-20151217/#datatype-base)| No | All types are defined as [field.type](/standard/table-schema/#type-and-format)|
188
188
|[format](https://www.w3.org/TR/2015/REC-tabular-metadata-20151217/#datatype-format)| Yes | As [field.format](/standard/table-schema/#type-and-format)|
[MediaWiki](https://www.mediawiki.org/) is the software used to run Wikipedia and related projects of the Wikimedia Foundation, including the media file repository [Wikimedia Commons](https://commons.wikimedia.org/). Commons hosts mostly images but also some records with tabular data. The [MediaWiki Tabular Data Model](https://www.mediawiki.org/wiki/Help:Tabular_data) was inspired by Data Package version 1 but it slightly differs from current Data Package specification, as described below.
15
+
16
+
## Property Comparison
17
+
18
+
A [MediaWiki tabular data page](https://www.mediawiki.org/wiki/Help:Tabular_data) describes and contains an individual table of data similar to a [Data Resource](/standard/data-resource/) with inline tabular data. Both are serialized as JSON objects, but the former comes as a page with unique name in a MediaWiki instance (such as Wikimedia Commons).
19
+
20
+
### Top-level Properties
21
+
22
+
MediaWiki Tabular Data has three required and two optional top-level properties. Most of these properties map to corresponding properties of a Data Resource:
23
+
24
+
| MediaWiki Tabular Data | Data Package Table Schema |
| - (implied by page name) |[name](/standard/data-resource/#name) (required) is a string |
27
+
|[description](https://www.mediawiki.org/wiki/Help:Tabular_data#Top-level_fields) (optional) is a localized string |[description](/standard/data-resource/#description) (optional) is a CommonMark string |
|[license](https://www.mediawiki.org/wiki/Help:Tabular_data#Top-level_fields) (required) is the string `CC0-1.0` or another known identifier |[licenses](/standard/data-resource/#licenses) (optional) is an array |
30
+
|[schema](https://www.mediawiki.org/wiki/Help:Tabular_data#Top-level_fields) (required) as [described below](#schema-properties)|[schema](/standard/data-resource/#schema) (optional) can have multiple forms |
31
+
|[sources](https://www.mediawiki.org/wiki/Help:Tabular_data#Top-level_fields) (optional) is a string with Wiki markup |[sources](/standard/data-resource/#sources) (optional) is an array of objects |
32
+
33
+
The differences are:
34
+
35
+
- property `name` does not exist but can be implied from page name
36
+
- property `description` and `sources` have another format
37
+
- property `data` is always an array of arrays and [data types](#data-types) of individual values can differ
38
+
- property `schema` is required but it differs in definion of [schema properties](#schema-properties)
39
+
- there is no property `licenses` but `license` fixed to plain string value `CC0-1.0` (other license indicators may be possible)
40
+
41
+
### Data Types
42
+
43
+
Tabular Data supports four data types that overlap with [Table Schema data types](/standard/table-schema/#field-types):
44
+
45
+
-`number` subset of Table Schema [number](/standard/table-schema/#number) (no `NaN`, `INF`, or `-INF`)
46
+
-`boolean` same as Table Schema [boolean](/standard/table-schema/#boolean)
47
+
-`string` subset of Table Schema [string](/standard/table-schema/#string) (limited to 400 characters at most and must not include `\n` or `\t`)
48
+
-`localized ` refers to an object that maps language codes to strings with same limitations as `string` type.
49
+
This type is not supported in Table Schema.
50
+
51
+
Individual values in a MediaWiki Tabular Data table can always be `null`, while in Table Schema you need to explicitly list values that should be considered missing in [schema.missingValues](/standard/table-schema/#missingValues).
52
+
53
+
### Schema Properties
54
+
55
+
The `schema` property of MediaWiki tabular contains an object with property `fields` just like [Table Schema](/standard/table-schema/) but no other properties are allowed. Elements of this array are like Table Schema [field descriptors](/standard/table-schema/#field) limited to three properties and different value spaces:
56
+
57
+
| MediaWiki Tabular Data | Data Package Table Schema |
|[name](https://www.mediawiki.org/wiki/Help:Tabular_data#Top-level_fields) (required) must be a string matching `^[a-zA-Z_][a-zA-Z_0-9]*`|[name](/standard/table-schema/#name) (required) can be any string |
60
+
|[type](https://www.mediawiki.org/wiki/Help:Tabular_data#Top-level_fields) (required) is one of the [Data Types above](#data-types)|[type](/standard/table-schema/#type) (optional) with [different data types](#data-types)|
61
+
|[title](https://www.mediawiki.org/wiki/Help:Tabular_data#Top-level_fields) (optional) is a localized string |[title](/standard/table-schema/#title) (optional) is a plain string |
Copy file name to clipboardExpand all lines: content/docs/recipes/relationship-between-fields.md
+43-39Lines changed: 43 additions & 39 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,13 +5,13 @@ title: Relationship between Fields
5
5
<table>
6
6
<tr>
7
7
<th>Authors</th>
8
-
<td>Philippe Thomy, Peter Desmet</td>
8
+
<td>Philippe Thomy</td>
9
9
</tr>
10
10
</table>
11
11
12
-
The structure of tabular datasets is simple: a set of Fields grouped in a table.
12
+
The structure of tabular datasets is simple: a set of fields grouped in a table.
13
13
14
-
However, the data present is often complex and reflects an interdependence between Fields (see explanations in the Internet-Draft [NTV tabular format (NTV-TAB)](https://www.ietf.org/archive/id/draft-thomy-ntv-tab-00.html#section-2)).
14
+
However, the data present is often complex and reflects an interdependence between fields (see explanations in the Internet-Draft [NTV tabular format (NTV-TAB)](https://www.ietf.org/archive/id/draft-thomy-ntv-tab-00.html#section-2)).
15
15
16
16
Let's take the example of the following dataset:
17
17
@@ -22,15 +22,15 @@ Let's take the example of the following dataset:
22
22
| Estonia | European Union | ES | 449 |
23
23
| Nigeria | Africa | NI | 1460 |
24
24
25
-
The data schema for this dataset indicates in the Field Descriptor "description":
25
+
The data schema for this dataset has the following `description`:
26
26
27
-
- for the "code" Field : "country code alpha-2"
28
-
- for the "population" Field: "region population in 2022 (millions)"
27
+
- for the `code` field : "country code alpha-2"
28
+
- for the `population` field: "region population in 2022 (millions)"
29
29
30
30
If we now look at the data we see that this dataset is not consistent because it contains two structural errors:
31
31
32
-
- The value of the "code" Field must be unique for each country, we cannot therefore have "ES" for "Spain" and "Estonia",
33
-
- The value of the "population" Field of "European Union" cannot have two different values (449 and 48)
32
+
- The value of the `code` Ffeld must be unique for each country, we cannot therefore have "ES" for "Spain" and "Estonia",
33
+
- The value of the `population` field of "European Union" cannot have two different values (449 and 48)
34
34
35
35
These structural errors make the data unusable and yet they are not detected in the validation of the dataset (in the current version of Table Schema, there are no Descriptors to express this dependency between two fields).
36
36
@@ -70,92 +70,96 @@ Two aspects need to be addressed:
70
70
71
71
A relationship is defined by the following information:
72
72
73
-
- the two Fields involved (the order of the Fields is important with the "derived" link),
73
+
- the two fields involved (the order of the fields is important with the `derived` link),
74
74
- the textual representation of the relationship,
75
75
- the nature of the relationship
76
76
77
77
Three proposals for extending Table Schema are being considered:
78
78
79
-
- New Field Descriptor
80
-
- New Constraint Property
81
-
- New Table Descriptor
79
+
- New field descriptor
80
+
- New constraint property
81
+
- New table descriptor
82
82
83
-
After discussions only the third is retained (a relationship between fields associated to a Field) and presented below:
83
+
After discussions only the third is retained (a relationship between fields associated to a field) and presented below:
84
84
85
-
-**New Table Descriptor**:
85
+
-**New table descriptor**:
86
86
87
-
A `relationships`Table Descriptor is added.
88
-
The properties associated with this Descriptor could be:
87
+
A `relationships`table descriptor is added.
88
+
The properties associated with this descriptor could be:
89
89
90
-
-`fields`: array with the names of the two Fields involved
90
+
-`fields`: array with the names of the two fields involved
91
91
-`description`: description string (optional)
92
92
-`link`: nature of the relationship
93
93
94
94
Pros:
95
95
96
-
- No mixing with Fields descriptors
96
+
- No mixing with fields descriptors
97
97
98
98
Cons:
99
99
100
-
- Need to add a new Table Descriptor
101
-
- The order of the Fields in the array is important with the "derived" link
100
+
- Need to add a new table descriptor
101
+
- The order of the fields in the array is important with the `derived` link
102
102
103
103
Example:
104
104
105
105
```json
106
-
{ "fields": [ ],
106
+
{
107
+
"fields": [ ],
107
108
"relationships": [
108
-
{ "fields" : [ "country", "code"],
109
+
{
110
+
"fields" : ["country", "code"],
109
111
"description" : "is the country code alpha-2 of",
110
112
"link" : "coupled"
111
113
}
112
-
{ "fields" : [ "region", "population"],
114
+
{
115
+
"fields" : ["region", "population"],
113
116
"description" : "is the population of",
114
-
"link" : "derived"}
117
+
"link" : "derived"
118
+
}
115
119
]
116
120
}
117
121
```
118
122
119
123
## Specification
120
124
121
-
Assuming solution 3 (Table Descriptor), the specification could be as follows:
125
+
Assuming solution 3 (table descriptor), the specification could be as follows:
122
126
123
-
The `relationships`Descriptor MAY be used to define the dependency between fields.
127
+
The `relationships`descriptor MAY be used to define the dependency between fields.
124
128
125
-
The `relationships`Descriptor, if present, MUST be an array where each entry in the array is an object and MUST contain two required properties and one optional:
129
+
The `relationships`descriptor, if present, MUST be an array where each entry in the array is an object and MUST contain two required properties and one optional:
126
130
127
131
-`fields`: Array with the property `name` of the two fields linked (required)
128
132
-`link` : String with the nature of the relationship between them (required)
129
-
-`description` : String with the description of the relationship between the two Fields (optional)
133
+
-`description` : String with the description of the relationship between the two fields (optional)
130
134
131
135
The `link` property value MUST be one of the three following :
132
136
133
-
-`derived`:
137
+
-`derived`:
134
138
135
139
- The values of the child (second array element) field are dependant on the values of the parent (first array element) field (i.e. a value in the parent field is associated with a single value in the child field).
136
-
- e.g. The "name" field ["john", "paul", "leah", "paul"] and the "Nickname" field ["jock", "paulo", "lili", "paulo"] are derived,
137
-
- i.e. if a new entry "leah" is added, the corresponding "nickname" value must be "lili".
140
+
- e.g. The `name` field ["john", "paul", "leah", "paul"] and the `nickname` field ["jock", "paulo", "lili", "paulo"] are derived,
141
+
- i.e. if a new entry "leah" is added, the corresponding `nickname` value must be "lili".
138
142
139
-
-`coupled`:
143
+
-`coupled`:
140
144
141
145
- The values of one field are associated to the values of the other field.
142
-
- e.g. The "Country" field ["france", "spain", "estonia", "spain"] and the "code alpha-2" field ["FR", "ES", "EE", "ES"] are coupled,
143
-
- i.e. if a new entry "estonia" is added, the corresponding "code alpha-2" value must be "EE" just as if a new entry "EE" is added, the corresponding "Country" value must be "estonia".
146
+
- e.g. The `Country` field ["france", "spain", "estonia", "spain"] and the `code alpha-2` field ["FR", "ES", "EE", "ES"] are coupled,
147
+
- i.e. if a new entry "estonia" is added, the corresponding `code alpha-2` value must be "EE" just as if a new entry "EE" is added, the corresponding `Country` value must be "estonia".
144
148
145
-
-`crossed`:
149
+
-`crossed`:
146
150
147
151
- This relationship means that all the different values of one field are associated with all the different values of the other field.
148
-
- e.g. the "Year" Field [2020, 2020, 2021, 2021] and the "Population" Field[ "estonia", "spain", "estonia", "spain"] are crossed
152
+
- e.g. the `Year` field [2020, 2020, 2021, 2021] and the `Population` field[ "estonia", "spain", "estonia", "spain"] are crossed
149
153
- i.e the year 2020 is associated to population of "spain" and "estonia", just as the population of "estonia" is associated with years 2020 and 2021
150
154
151
155
## Implementations
152
156
153
-
The implementation of a new Descriptor is not discussed here (no particular point to address).
157
+
The implementation of a new descriptor is not discussed here (no particular point to address).
154
158
155
159
The control implementation is based on the following principles:
156
160
157
-
- calculation of the number of different values for the two Fields,
158
-
- calculation of the number of different values for the virtual Field composed of tuples of each of the values of the two Fields
161
+
- calculation of the number of different values for the two fields,
162
+
- calculation of the number of different values for the virtual field composed of tuples of each of the values of the two fields
159
163
- comparison of these three values to deduce the type of relationship
160
164
- comparison of the calculated relationship type with that defined in the data schema
0 commit comments