frictionlessdata / datapackage

Data Package is a standard consisting of a set of simple yet extensible specifications to describe datasets, data files and tabular data. It is a data definition language (DDL) and data API that facilitates findability, accessibility, interoperability, and reusability (FAIR) of data.
https://datapackage.org
The Unlicense
481 stars 109 forks source link

Promote the Unique Constraints pattern to the Table Schema spec? #862

Closed roll closed 4 months ago

roll commented 6 months ago

Overview

Pattern - https://datapackage.org/patterns/unique-constraints/

Although, this pattern doesn't have known implementations, settings multi-column unique values are very vital part of tabular constraints in many systems (e.g. SQL)

nichtich commented 6 months ago

Agreed but https://datapackage.org/patterns/unique-constraints/ does not properly explain multi-column unique constraints. I guess these two schemas are equivalent (if so, is there a preferred form?):

{ "fields": [ { "name": "a", "unique": true } ] }
{ "fields": [ { "name": "a" } ],  "uniqueKeys": ["a" ] }

but how about these:

{
  "fields": [ { "name": "a", "unique": true }, { "name": "b", "unique": true } ],
  "uniqueKeys": ["a","b"]
}
{
  "fields": [ { "name": "a" }, { "name": "b" } ],
  "uniqueKeys": ["a","b"]
}

Maybe require uniqueKeys to have at least two elements?

roll commented 6 months ago

I agree I think we need to slightly improve the definition if adding to the specs. The main decision will be clarifying behavior in case of duplication as in above