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

CollectionObjectType and Collection many-to-one on both sides #6184

Open
lexiclevenger opened this issue Jan 30, 2025 · 1 comment
Open

CollectionObjectType and Collection many-to-one on both sides #6184

lexiclevenger opened this issue Jan 30, 2025 · 1 comment
Labels
2 - Database/Schema Issues that are related to the underlying database and schema geospecify

Comments

@lexiclevenger
Copy link
Collaborator

Describe the bug
The CollectionObjectType > Collection and Collection > CollectionObjectType relationships are both many-to-one.

To Reproduce
Steps to reproduce the behavior:

  1. Go to User Tools
  2. Go to Database Schema
  3. Click Collection and see that the collectionObjectType relationship is many-to-one.
  4. Click CollectionObjectType and see that the Collection relationship is many-to-one.

Expected behavior
CollectionObjectType > Collection should be many-to-one; Collection > CollectionObjectType should be one-to-many

Screenshots
Collection > COT:
Image

COT > Collection:
Image

COT > Collection query:
Image

Collection > COT query:

Image

Specify 7 System Information - 2025-01-30T20_19_56.588Z.txt

Please fill out the following information manually:

@lexiclevenger lexiclevenger added 2 - Database/Schema Issues that are related to the underlying database and schema geospecify labels Jan 30, 2025
@acwhite211
Copy link
Member

acwhite211 commented Feb 5, 2025

In the Django model we have:

In Collection, we have a many-to-one foreign key to CollectionObjectType

collectionobjecttype = models.ForeignKey('CollectionObjectType', db_column='CollectionObjectTypeID', related_name='collections', null=True, on_delete=models.SET_NULL)

In CollectionObjectType, we have a many-to-one foreign key to Collection

collection = models.ForeignKey('Collection', db_column='CollectionID', related_name='cotypes', null=False, on_delete=protect_with_blockers)

In the datamodel we have:

In Collection, we have a many-to-one relationship to CollectionObjectType

Relationship(name='collectionObjectType', type='many-to-one',required=False, relatedModelName='CollectionObjectType', column='CollectionObjectTypeID', otherSideName='collections')

In CollectionObjectType, we have a many-to-one relationship to Collection

Relationship(name='collection', type='many-to-one', required=True, relatedModelName='Collection', column='CollectionID'),

So currently, each table has a foreign key the points to the other. The Django model and datamodel are in alignment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2 - Database/Schema Issues that are related to the underlying database and schema geospecify
Projects
None yet
Development

No branches or pull requests

2 participants