I use non-dependent tables to restrict using a custom key source. As an example, my pipeline stages are all parameterized and use a mixin key_source
to specify which parameters are used for each stage for a given dataset:
class ParamsMixin:
@property
def key_source(self):
return super().key_source & (models.Processing * models.Specification)
I have other examples that use a custom query to do a restriction:
@property
def key_source(self):
# Only normalize combinatorial rounds.
return (super().key_source * models.AcquisitionRound) & {
"acquisition_round_kind": "combinatorial"
}
This works great for data processing, but the dependencies are not explicit in the table definition. Therefore, I lose the ability to use cascades to propagate deletions from the non-dependent tables in the custom key_source
-- which violates data integrity in some respects. Also, when using dj.create_virtual_module, underlying functions like _jobs_to_do
will not be correct. Is there an alternate design that could allow me to keep these functionality?