tbls icon indicating copy to clipboard operation
tbls copied to clipboard

BQ now supports FK & PK; take into account for diagrams 🙏

Open MaximusMcCann opened this issue 1 year ago • 8 comments

You can now define Foreign and Primary keys on table columns in BigQuery. Would love to see them interpreted and added to the lovely image output to see connections between tables.

Google docs regarding adding FK and PK constraints. https://cloud.google.com/bigquery/docs/reference/standard-sql/data-definition-language#alter_table_add_constraint_statement

Queries to pull the information off the schema about FK & PK.

https://cloud.google.com/bigquery/docs/information-schema-constraint-column-usage

SELECT *
FROM <PROJECT_ID>.<DATASET>.INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE;

https://cloud.google.com/bigquery/docs/information-schema-key-column-usage

SELECT *
FROM <PROJECT_ID>.<DATASET>.INFORMATION_SCHEMA.KEY_COLUMN_USAGE;

https://cloud.google.com/bigquery/docs/information-schema-table-constraints

SELECT *
FROM <PROJECT_ID>.<DATASET>.INFORMATION_SCHEMA.TABLE_CONSTRAINTS;

General spot for BQ schema information: https://cloud.google.com/bigquery/docs/information-schema-intro

MaximusMcCann avatar Mar 01 '23 22:03 MaximusMcCann

@MaximusMcCann Thank you for your report!

k1LoW avatar Mar 01 '23 22:03 k1LoW

Of course! :)

MaximusMcCann avatar Mar 02 '23 15:03 MaximusMcCann

This would be awesome!

markthepixel avatar Mar 08 '23 18:03 markthepixel

Would love to see this feature!

unstoppable-allensun avatar Mar 08 '23 18:03 unstoppable-allensun

This would be really helpful!!

fruwe avatar Mar 13 '23 16:03 fruwe

This would be very helpful!

tunguyennnnn avatar Mar 13 '23 16:03 tunguyennnnn

Thanks for the issue! I would like to have this as well

sudoryan avatar Mar 15 '23 20:03 sudoryan

+1

helfi92 avatar Mar 15 '23 20:03 helfi92