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

Add add_relationship method to MultiTableMetadata #890

Closed
amontanez24 opened this issue Jul 8, 2022 · 0 comments
Closed

Add add_relationship method to MultiTableMetadata #890

amontanez24 opened this issue Jul 8, 2022 · 0 comments
Assignees
Labels
feature request Request for a new feature
Milestone

Comments

@amontanez24
Copy link
Contributor

Problem Description

As a user, it would be helpful to be able to programmatically specify and add relationships between tables in my metadata.

Expected behavior

  • Add a add_relationship method
  • The relationship should be added to the private dict created in Create MultiTableMetadata class #883
  • Parameters:
    • parent_table_name: A string representing the name of the parent table
    • child_table_name: A string representing the name of the child table
    • parent_primary_key: A string or tuple of strings representing the primary key of the parent
    • child_foreign_key: A string or tuple of strings representing the foreign key of the child
  • Errors:
metadata.add_relationship(
  parent_table_name='users',
  child_table_name='transactions',
  parent_primary_key='user_id', # can be a tuple for composite keys
  child_foreign_key='purchaser_id' # can be a tuple for composite key
)

metadata.add_relationship(
  parent_table_name='users',
  child_table_name='transactions',
  parent_primary_key='user_id', # can be a tuple for composite keys
  child_foreign_key='start_date' # can be a tuple for composite key
)
Error: Relationship between tables ('users', 'transactions') is invalid. The primary and foreign key columns are not the same type.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Request for a new feature
Projects
None yet
Development

No branches or pull requests

2 participants