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

Generate Related for many-to-many tables with extra columns #1259

Closed
limjiayi opened this issue Nov 28, 2022 · 0 comments · Fixed by #1260
Closed

Generate Related for many-to-many tables with extra columns #1259

limjiayi opened this issue Nov 28, 2022 · 0 comments · Fixed by #1260
Assignees

Comments

@limjiayi
Copy link
Contributor

limjiayi commented Nov 28, 2022

This merged pull request describes the current logic for determining many-to-many relations. PR #1075

I updated to logic to only require the intermediate table of a m-to-n relation to be with

  • Exactly 2 foreign keys
  • A primary key formed by exactly 2 columns
  • Number of primary key equals to number of column

But it sometimes makes sense for these junction tables to contain more than 2 columns. For example, a CustomerProduct table that links the Customer and Product tables based on the products that each customer has bought, may have the following columns to record extra information about the relationship.

  • customer_id (foreign key)
  • product_id (foreign key)
  • price
  • quantity
  • purchase_date
  • promo_code

So, the requirement that the number of primary keys be equal to the number of columns should be removed.

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 a pull request may close this issue.

1 participant