Skip to content
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

Forbid reference column pointing to unexpected table? #110

Open
Anaphory opened this issue May 5, 2021 · 2 comments
Open

Forbid reference column pointing to unexpected table? #110

Anaphory opened this issue May 5, 2021 · 2 comments
Milestone

Comments

@Anaphory
Copy link
Contributor

Anaphory commented May 5, 2021

In looking at the new get_foreign_key_target Method in pycldf, I noticed that it makes sense to always return and heed the referenced table of a foreign key – but that also suggests that a formReference might have a foreign key pointing to a table that is not a FormTable. What would that mean?

I think that the CLDF specs should specify that an xxxReference column SHOULD be a foreign key to the XxxTable, and that doing it differently MAY lead to undefined behaviour in software. CLDF software SHOULD use the referenced table and check it for the columns needed.

For example, my code that looks for the segments of a form referenced in a CognateTable will look for

dataset[dataset.get_foreign_key_target("CognateTable", "formReference")[0], "segments"]

instead of

dataset["FormTable", "segments"]

If that fails with a KeyError, it would be allowed to add a segments column to the FormTable, though, and expect everything to be fine, because my segmenter functionality can't be expected to work on weird arbitrary tables.

@Anaphory
Copy link
Contributor Author

All these reference properties already have an entry <dc:references rdf:resource="#LanguageTable"/> or equivalent, and the comments read something like

An identifier referencing a language either

  • by providing a foreign key into the LanguageTable or
  • by using a known encoding scheme.

Can – and should – we formalize this “or” somehow in the specs?

I guess we still want the potential flexibility of people coming up with alternative encoding schemes for such references in the future, so I would understand it if we do not formalize it yet, or not yet for all properties.

@Anaphory Anaphory changed the title Reference column pointing to unexpected table Forbd reference column pointing to unexpected table Dec 11, 2021
@Anaphory Anaphory changed the title Forbd reference column pointing to unexpected table Forbid reference column pointing to unexpected table Dec 11, 2021
@Anaphory Anaphory changed the title Forbid reference column pointing to unexpected table Forbid reference column pointing to unexpected table? Dec 11, 2021
@xrotwang
Copy link
Contributor

We might want to spell out more clearly, that the or means, the reference must be a foreign key (or NULL) if a LanguageTable exists.

@xrotwang xrotwang added this to the CLDF 1.2 milestone Sep 28, 2022
@xrotwang xrotwang modified the milestones: CLDF 1.2, CLDF 2.0 Nov 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants