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.
As we could see there is a foreign key violation. That's because our lookup table cities doesn't have a city of Munich but we have a team from there. We need to fix it in cities resource:
package.descriptor['resources'][1]['data'].push(['Munich', 'Germany'])
package.commit()
teams = package.getResource('teams')
await teams.checkRelations()
// True
Fixed! But not only a check operation is available. We could use relations argument for resource.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 as resource.check_relations error if there is an integrity issue. But only if relations: true flag is passed.
It's just a mirror of https://github.com/frictionlessdata/datapackage-py/issues/155
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 asresource.check_relations
error if there is an integrity issue. But only ifrelations: true
flag is passed.