How to check Tables relationship ER diagram (Data Model) Snowflake data!

R. Ganesh
4 min readJun 10, 2024

--

To view the data model in Snowflake, you can use several tools and methods. Here’s a comprehensive guide:

1. Snowflake Console

Using the Web Interface:

  1. Log in to the Snowflake Web Interface:
  • Open your web browser and navigate to the Snowflake login page.
  • Enter your account details to log in.

2. Navigate to the Databases:

  • Click on the “Databases” tab in the top menu.
  • Select the database you are interested in.

3. Explore the Database Objects:

  • Within the selected database, you can explore schemas, tables, views, and other objects.
  • Click on a schema to see the tables and views within it.
  • Click on a table or view to see its columns, data types, and other details.

2. Using SQL Commands:

  1. DESCRIBE Table/View:
  • Use the DESCRIBE command to get information about the structure of a table or view.
DESCRIBE TABLE schema_name.table_name;

2. SHOW Commands:

  • Use the SHOW commands to list different types of objects.
SHOW TABLES IN schema_name;
SHOW VIEWS IN schema_name;
SHOW SCHEMAS IN database_name;
  • This command will return the column names, data types, and other metadata.

2. Third-Party Tools

Several third-party tools can visualize Snowflake’s data model, providing an ERD (Entity-Relationship Diagram) or similar views. Some popular tools include:

  1. dbt (Data Build Tool):
  • dbt is a command-line tool that helps you transform data in your warehouse by writing simple SQL SELECT statements. It also supports creating documentation and lineage graphs.
  • dbt

2. Snowflake Partner Tools:

  • Snowflake partners with various data modeling tools like Lucidchart, ER/Studio, and others that can connect to Snowflake and help visualize the data model.
  • Snowflake Partners

3. Power BI / Tableau:

  • Both Power BI and Tableau can connect to Snowflake and help visualize your data through dashboards and reports.
  • Power BI
  • Tableau

3. Programmatic Access

Using Python:

You can use the Snowflake Python Connector to programmatically access and visualize the data model.

  1. Install the Snowflake Connector:
pip install snowflake-connector-python

2. Connect to Snowflake and Describe Tables:

import snowflake.connector  
# Create a connection
conn = snowflake.connector.connect(
user='<your_user>',
password='<your_password>',
account='<your_account>' )
# Create a cursor
cur = conn.cursor()
# Describe a table
cur.execute("DESCRIBE TABLE schema_name.table_name")
for row in cur:
print(row)

DBVeer (also known as DBeaver) is a popular database management tool that supports a wide range of databases, including Snowflake. It offers a graphical user interface (GUI) to explore and visualize your data model. Here’s how you can use DBeaver to view your data model in Snowflake:

4. DBeaver

If you haven’t already, download and install DBeaver from the official website.

1. Set Up a Connection to Snowflake

  1. Open DBeaver:
  • Launch the DBeaver application.

2. Create a New Connection:

  • Click on the Database menu and select New Database Connection.
  • In the Connect to a database wizard, search for Snowflake and select it.

3. Enter Connection Details:

  • Fill in your Snowflake account information:
  • Host: <account_name>.snowflakecomputing.com
  • Database: Your database name (optional)
  • Schema: Your schema name (optional)
  • Warehouse: Your warehouse name (optional)
  • Username: Your Snowflake username
  • Password: Your Snowflake password

Click on the Test Connection button to ensure the connection is working.

Click Finish to save the connection.

4. Explore the Data Model

  1. Navigate the Database:
  • In the Database Navigator pane on the left, expand your Snowflake connection.
  • Expand the database and schema to see the tables and views.

2. View Table Structure:

  • Click on a table to view its structure. This will show the columns, data types, primary keys, foreign keys, and other metadata.

3. Generate ER Diagrams:

  • Right-click on the schema or a specific table.
  • Select ER Diagram from the context menu.
  • This will open a graphical representation of the data model, showing the tables and their relationships.

4. Using SQL Editor

  1. Open SQL Editor:
  • Click on the SQL Editor button or press Ctrl+Enter.
  • Use SQL commands to describe tables or retrieve metadata.

2. Describe Table:

DESCRIBE TABLE schema_name.table_name;
  • Run the above command to get a detailed description of the table’s structure.

Additional Features

  • Data Export/Import: DBeaver supports exporting and importing data in various formats like CSV, Excel, etc.
  • Query Execution: Execute complex queries and analyze the results directly within the tool.
  • Data Visualization: Utilize built-in charts and data visualization tools to better understand your data.

5. Documentation and Code Repositories

If your organization maintains a data catalog or repository with documentation on the data model, this can be a valuable resource. Tools like Atlassian Confluence, GitHub, or custom-built documentation sites often house detailed descriptions of data models.

By combining these tools and methods, you can effectively explore and understand the data model in Snowflake.

Happy Learning !!!

About me

I’m available on LinkedIn. For any assistance book slot https://topmate.io/ganesh_r0203. Please stop by if you like to say ‘Hi’.

--

--