Skip to content

Add many-to-many relationship InvestigationSample to the schema#240

Closed
EmilJunker wants to merge 4 commits intoicatproject:masterfrom
EmilJunker:schema-investigationsample
Closed

Add many-to-many relationship InvestigationSample to the schema#240
EmilJunker wants to merge 4 commits intoicatproject:masterfrom
EmilJunker:schema-investigationsample

Conversation

@EmilJunker
Copy link
Contributor

@EmilJunker EmilJunker commented Jul 6, 2020

This closes #231.

Here is a short summary of the changes:

  • adds a new class InvestigationSample to the schema
    (representing a many-to-many relationship between Investigation and Sample)
  • changes the unique constraint for the Sample table from investigation, name to just pid
    (adding a NOT NULL constraint for pid while also keeping the existing NOT NULL constraint for name)

Note that this is still very much a work in progress. A few points to note:

  • The upgrade script initializes the value of the Sample.pid field with 'local:<id>' (reusing the id attribute) for all samples where the pid is currently NULL. However, in the current ICAT schema, the pid field has no unique constraint. This means that there could already be two samples with the same pid (at least theoretically). Or perhaps there could be several samples with the pid set to '' (an empty string). The upgrade script currently does not handle these cases (as they are very unlikely to occur in practice).

  • The upgrade script also needs to move the existing one-to-many relationship between Investigation and Sample over to the new InvestigationSample table. Once this is done, the unique constraints on the Sample table are updated and the Sample.investigation_id column is dropped. I'm not sure if the current implementation of the upgrade script handles all of this correctly. In other words: thorough testing is needed.

@RKrahl RKrahl added enhancement schema this involves changes to the ICAT schema labels Jul 6, 2020
@EmilJunker
Copy link
Contributor Author

I'm closing this PR in favor of #294.

@EmilJunker EmilJunker closed this Jul 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement schema this involves changes to the ICAT schema

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make the relationship between Sample and Investigation many-to-many

3 participants