datajoint-python icon indicating copy to clipboard operation
datajoint-python copied to clipboard

Add non-primary foreign key using alter() method

Open lfrank opened this issue 3 years ago • 2 comments

Feature Request

Problem

It would be helpful to be able to modify existing tables to have references to upstream tables. For example

@schema
class SpikeSortingParameters(dj.Manual):
    definition = """
    # Table for holding parameters for each spike sorting run
    -> SortGroup
    -> SpikeSorterParameters
    -> SortInterval
    ---
    -> SpikeSortingMetrics
    -> IntervalList
    import_path = '': varchar(200) # optional path to previous curated sorting output
    """

is our starting schema, and we'd like to add

-> SpikeSortingArtifactParameters

as a non-primary foreign key. We could have an empty set of parameters for already sorted data, and this would allow us to modify our current pipeline for future sortings.

Requirements

This would seem to require modifying the alter() method to allow initialization based on a particular foreign key.

Justification

This would provide useful additional flexibility when working on

lfrank avatar Apr 05 '21 17:04 lfrank

Thanks for opening this @lfrank. Included this in the milestone for our next release.

guzman-raphael avatar Apr 06 '21 15:04 guzman-raphael

@guzman-raphael It would be great if one could use alter to not only add but also to remove an existing foreign key from a table. Right now trying to do so leads to the same error: NotImplementedError: table.alter cannot alter foreign keys (yet).

khl02007 avatar Dec 04 '22 23:12 khl02007