# Databases and warehouses

> Connect a database or warehouse and ask questions in plain words. Dvina only reads, and every query is checked before it runs.

Connect your database or warehouse and ask the way you'd ask a colleague. Dvina finds the right tables, writes the query and shows you the answer.

## What Dvina can do

- **Answer in plain words.** Ask "Which regions lost repeat customers last quarter?" and Dvina finds the tables, writes the query and shows the answer, often with a chart and the table under it.
- **Map your tables.** Dvina learns how your tables connect, so you never name a join.
- **Show it your way.** Change how an answer looks: **Table**, **Line**, **Area**, **Bar**, **Horizontal Bar**, **Pie**, **Donut**, **Radar** or **Polar Area**.
- **Keep an answer.** Save any answer as an insight and open it again whenever you need it.

You can connect 20 databases and warehouses, including PostgreSQL, MySQL, SQL Server, Snowflake, BigQuery, Redshift and Databricks.

To use a database in a message, type <kbd>/</kbd> in the message field and choose it.

## Permissions

Databases and warehouses you connect are read-only by design.

- **Single reads only:** Every query is checked to be a single read before it runs. Your data stays as it is.
- **No changes:** If you ask Dvina to change or delete data, it tells you it only reads, and can offer to list what you asked about instead.
- **Your account's access:** Dvina sees the tables the database account you connect with can read. If no tables show up, ask the database's administrator to check that account's read access.
- **Rows and columns per person:** When you share a table, access rules can show each person only some of its rows and hide columns. See [Control which rows and columns people see](/docs/connectors/row-and-column-access).

> [!TIP]
> Connect with a database account that can only read. Dvina never writes, and a read-only account keeps it that way on the database's side too.

## How to connect

1. Open **Databases** in your Library and choose **Connect a database**. You can also choose **Add Context** in your Library, then **Databases**.
2. Find your database or warehouse. You can search by name.
3. Choose **Connect**.
4. Enter a **Source Name** and the connection details, like **Host**, **Port**, **Database**, **Username** and **Password**. Some warehouses ask for other details instead, like an account, a project or a service account file.
5. Under **Encryption (SSL)**, choose **Verified**, **Required** or **Off**.
6. To have Dvina look for how your tables connect, turn on **Find relationships between tables**. This may take a while on large databases.
7. Choose **Connect**.

Dvina checks the connection and discovers your tables. Each table shows when it's **Ready for questions**, and you can follow the progress on the database's page.

### If the connection fails

Dvina says what went wrong. The most common fixes:

- **The database rejected the credentials:** Check the username, password and authentication method.
- **The address points to a private or internal network:** Use the database's public host name or IP address.
- **The encrypted connection could not be established:** If the database uses a self-signed certificate, choose **Required** instead of **Verified**. If it doesn't support SSL, choose **Off**.
- **The database could not be reached:** Check its availability, network access, host and port.

To change the details later, open the database and choose **Edit connection**, then **Check again**.

## See how your tables connect

Open **Databases** in your Library, open the database, and choose its card, the first one on the page. The **Database schema** panel shows the database at a glance:

- **Connection:** the database's details, like **Host**, **Port** and **User**, and its **Status**: **Connected** or **Can't connect**, with when it was last checked. Choose **Check again** to check it now.
- **Relationships:** whether Dvina has searched for how your tables connect. Choose **Find relationships**, or **Search again**, to start a search.
- **The diagram:** each table as a card with its columns, its keys at the top, and a line for each relationship between tables. Hover over a line to highlight the two columns it connects. Choose a table to open it.

To find a table or a column, use **Find a table or column**. To see the diagram on the whole screen, choose **Expand**.

In the diagram, **PK** marks a primary key and **FK** a foreign key. A solid line is a relationship your database declares, or one that's confirmed and used in queries. A dashed line is **Suggested**: a relationship Dvina found in your data that isn't used yet.

### Review the relationships Dvina found

1. In the diagram, choose a dashed line.
2. Check the two columns it connects.
3. Choose **Confirm** to use it in queries, or **Dismiss** if it's wrong. A relationship you dismiss isn't suggested again.

### Large databases

- Searching for relationships counts rows across your tables, so it may take a while. For a database with more than 100 tables, Dvina doesn't search on its own, even if you turned on **Find relationships between tables**. Choose **Find relationships** when you're ready.
- When a database has more than 40 tables, the diagram shows one table and its neighbors. Search to focus on another table.

## Save and refresh insights

An insight keeps a question's answer, so you can open it again with fresh data.

1. In the answer's card, choose how you want to see it, like **Table** or **Bar**.
2. Choose **Save**. Dvina says **Saved as an insight**. On a phone, choose **Expand** first, then **Save** in the side panel.
3. To open it, choose **Saved**. You can also find it in your Feed.

The insight opens in the side panel. There you can:

- **Rename it:** Click its name at the top and type a new one.
- **Change its view:** Choose another presentation or a pivot. The new view is saved with the insight.
- **Refresh it:** Open the panel's menu and choose **Refresh** to run it again with the latest data.
- **Download it:** Open the panel's menu and choose **Download**.
- **Delete it:** Open the panel's menu and choose **Delete**. It moves to the Trash, where you can restore it.

### Shared insights

When you share an insight, choose **Can edit** or **Can view** for each person.

- **People who can edit** can also refresh it.
- **People who can view** only look. They can change the view on their own screen, but it isn't saved, and they see **Only editors can refresh** and **Only editors can rename**.

If a table's access rules limit what someone sees, they get their own result from the insight, marked **Restricted view**. See [Control which rows and columns people see](/docs/connectors/row-and-column-access).

## Privacy

- What you connect is never used to train AI models.
- Only what your request needs is read.
- Personal details like card and phone numbers are masked before the AI sees them.
- Your data is encrypted in transit.

## Disconnect

1. Open **Databases** in your Library and choose the database.
2. Open its menu and choose **Disconnect**, then choose **Disconnect** to confirm.

The database moves to the Trash with its tables and the insights built on them, and you can restore them from there. Nothing in the database itself changes.

## Related

- [Connectors overview](/docs/connectors/overview)
- [Row and column access](/docs/connectors/row-and-column-access)
- [Live Answers](/docs/use-dvina/features/live-answers)
- [Your first chat](/docs/use-dvina/get-started/first-chat)
