k1LoW / tbls

tbls is a CI-Friendly tool for document a database, written in Go.
MIT License
3.37k stars 165 forks source link

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

Open MaximusMcCann opened 1 year ago

MaximusMcCann commented 1 year ago

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

k1LoW commented 1 year ago

@MaximusMcCann Thank you for your report!

MaximusMcCann commented 1 year ago

Of course! :)

markthepixel commented 1 year ago

This would be awesome!

unstoppable-allensun commented 1 year ago

Would love to see this feature!

fruwe commented 1 year ago

This would be really helpful!!

tunguyennnnn commented 1 year ago

This would be very helpful!

sudoryan commented 1 year ago

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

helfi92 commented 1 year ago

+1