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

handle complex foreign key associations #15

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

djerius
Copy link

@djerius djerius commented Aug 12, 2015

Properly handle complex foreign key associations.

The new logic implements the following rules:

  • a table which has fk cascades to more than one table must be an
    Association
  • a table which has multiple fk cascades to a single table (even if it
    has fk non-cascades) is a Composition.
  • a table with multiple fk cascades to a single ref table combines
    those cascades into a single Composition
  • a table with fk cascades and non-cascades to a single ref table
    splits the cascades into a Composition and the non-cascades to an
    Association
  • Associations and Compositions are merged if possible.

A table may have multiple foreign keys with cascaded deletes.  The original
logic would create a Compositions for each foreign key association,
resulting in a single table being part of multipe Compositions,
which is not permissable.  Instead, if this condition applies, turn
the associations into Associations.
@djerius djerius changed the title tables with multiple foreign key cascaded deletes must be Associations handle complex foreign key associations Aug 13, 2015
@djerius djerius force-pushed the sql_translator_compositions branch from 33d50f9 to 1792396 Compare August 13, 2015 22:19
The previous commit didn't properly handle the case where a table
had multiple foreign key associations (with and without cascades)
to one or more tables.

The new logic implements the following rules:

* a table which has fk cascades to more than one table must be an
  Association

* a table which has multiple fk cascades to a single table (even if it
  has fk non-cascades) is a Composition.

* a table with multiple fk cascades to a single ref table combines
  those cascades into a single Composition

* a table with fk cascades and non-cascades to a single ref table
  splits the cascades into a Composition and the non-cascades to an
  Association

Associations and Compositions are merged if possible.
@djerius djerius force-pushed the sql_translator_compositions branch from 1792396 to c5b5033 Compare August 13, 2015 22:20
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

Successfully merging this pull request may close these issues.

1 participant