-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve foreign keys API #155
Comments
@pwalsh |
@roll I like it :). Shall we get some API review comments from @amercader or @vitorbaptista too/first before merging? Are you good with this, as an enhancement on the first iteration, or .... ? |
@pwalsh May be we also could get some comment from @Stephen-Gates in addition to Adria's and Vitor's. It's related to his current work - frictionlessdata/tableschema-js#88 (comment) |
Here are my thoughts for foreign key use. From a data publisher perspective:
Thinking as a Data Package Tool Provider:
As a data consumer:
|
@Stephen-Gates |
It seems there are no objections and other opinions. So merging because anyway those changes include important internal improvements. I think we have a few days before v1 release for late call feedback. |
Proposed API
The library supports foreign keys described in the Table Schema specification. It means if your data package descriptor use
resources[].schema.foreignKeys
property for some resources a data integrity will be checked on reading operations.Consider we have a data package:
Let's check relations for a
teams
resource:As we could see there is a foreign key violation. That's because our lookup table
cities
doesn't have a city ofMunich
but we have a team from there. We need to fix it incities
resource:Fixed! But not only a check operation is available. We could use
relations
argument forresource.iter/read
methods to dereference a resource relations:Instead of plain city name we've got a dictionary containing a city data. These
resource.iter/read
methods will fail with the same error asresource.check_relations
does if there is an integrity issue. But only ifrelations=True
flag is passed.The text was updated successfully, but these errors were encountered: