# Creating and managing databases

## Creating a database

To create a database:

1. Click the create database icon that is next to the database dropdown at the top right.

<figure><img src="https://4109733485-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmoU4gTR9LxlzHeWmQCUZ%2Fuploads%2FWgRXKgNP4zgB1jCP8oMb%2FCreateDatabaseIcon.png?alt=media&#x26;token=15495d61-da80-4a13-bccd-75b7354e7e63" alt=""><figcaption><p>Create database icon</p></figcaption></figure>

2. On the new database panel, in the **Database Name** field, provide a name for the database.
3. If you are not creating a live connection database, then click **Create Database**.\
   \
   Fabricate displays a field for you to get started.

<figure><img src="https://4109733485-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmoU4gTR9LxlzHeWmQCUZ%2Fuploads%2FzIts0oAliu9C9cDGZEdY%2FDataAgent_NewDatabase.png?alt=media&#x26;token=8a6860f1-fc51-418a-a06e-df9f8e22de1f" alt=""><figcaption><p>Database details for a new Data Agent database</p></figcaption></figure>

5. Provide an initial prompt to tell the Data Agent about the data to create.\
   \
   The prompt might be a simple instruction. For example: `Create a database of consumer transactions. The database includes transactions, customers, and products.`\
   \
   You might also paste in a specific schema for the Data Agent to use. For example:  `Create a database of consumer transactions that uses the following schema.`\
   \
   You can also upload files to provide information for the Data Agent to use. For example, instead of pasting in the schema, you can upload a file, drag and drop the file to the Data Agent, or click the attachment icon.  Examples of schema files include:
   1. QL DDL scripts
   2. prisma.schema scripts
   3. Swagger YAML API definitions
6. The Data Agent analyzes the request, and if needed asks clarifying questions about the data values, the volume of data, and the relationships between the tables.\
   \
   If you provided a schema that contains more than 10 tables, then the Data Agent automatically switches to [Plan mode](https://docs.tonic.ai/fabricate/data-agent-tools/data-agent-modes/data-agent-plan-mode). It creates a plan to create the database, which you can then review and execute.\
   \
   When you send the initial prompt, the Data Agent chat moves to the right side of the page.
7. You can provide answers to further shape the data, and optionally tell the Data Agent to use its own judgment for some elements of the data.\
   \
   For example: `Create 70 customers. Each customer has 1-3 orders. Each order has 1-5 products. You can choose the distribution of the customers throughout the United States.`
8. When it has enough information to work from, the Data Agent creates the database structure and then populates the database, then provides a summary of the results.

## Creating a live connection database

{% hint style="info" %}
Live connection databases are currently in private preview. To request access, contact Tonic.ai.
{% endhint %}

{% hint style="info" %}
Live connection databases require an Enterprise license.

For Fabricate to connect to an external database, you must allow list the following IP addresses:

* &#x20;34.224.174.7
  {% endhint %}

By default, the database data is generated in Fabricate. You can then export the data to files or to a database.

A live connection database generates data directly to an external database.

On the new database panel, to indicate to create a live connection database, check the **Use live database connection** checkbox.

<figure><img src="https://4109733485-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmoU4gTR9LxlzHeWmQCUZ%2Fuploads%2FLVJ0wvIHCNRc8Il4NFIM%2FDataAgent_NewLiveConnection.png?alt=media&#x26;token=6034ce1f-5769-4cb3-8cc9-4fad2a11436d" alt=""><figcaption><p>Details panel to identify the default database connection for a live connection database</p></figcaption></figure>

When you create a live connection database, you identify the first database connection. A database connection consists of:

* A server connection. You can [configure available server connections for a workspace](https://docs.tonic.ai/fabricate/workspaces/workspace-server-connections).
* The database name.

To connect to the database:

1. From the **Server** dropdown list, select the server connection where the database is located.\
   \
   To create a new server connection, select **new connection**, then provide the details for the connection. Fabricate adds the connection to the available server connections for the workspace.\
   \
   To edit the selected server connection, click **Edit**. Note that any changes to the configuration apply wherever the server connection is used.
2. In the **Database** field, provide the name of the database.
3. To verify that Fabricate can connect to the database, click **Test Connection**.
4. To create the database, click **Create Project**.

Fabricate analyzes the database schema to determine the data structure. It displays the list of tables and selects the first table.

Below the table list, the **Connections** section lists the database connections for the current database.

The first database connection is marked as the default database connection, and is initially assigned the name `default`.

<figure><img src="https://4109733485-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmoU4gTR9LxlzHeWmQCUZ%2Fuploads%2FY27pxIJsVkAp0cuguUBI%2FDatabase_LiveConnectionConnections.png?alt=media&#x26;token=7ee9d133-180d-42e2-b278-8639c40daef4" alt=""><figcaption></figcaption></figure>

## Selecting a database to manage

To select a database to manage:

1. Click the database dropdown at the top right.

<figure><img src="https://4109733485-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmoU4gTR9LxlzHeWmQCUZ%2Fuploads%2FP3lURgDkeiBup4gMrzPu%2FDataAgent_DatabaseList.png?alt=media&#x26;token=d2fa6940-43ea-4a16-b3ef-f5510f876f49" alt=""><figcaption><p>Database dropdown list to search for and select a database to manage</p></figcaption></figure>

2. In the dropdown list, select the database. You can use the search field to look for a specific database by name.

<figure><img src="https://4109733485-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmoU4gTR9LxlzHeWmQCUZ%2Fuploads%2FJGRH6AuDsxxecUI8Iwd7%2FDataAgent_DatabaseListSearch.png?alt=media&#x26;token=823b4054-2916-48d9-b21b-42c31d602658" alt=""><figcaption><p>Database list filtered based on a search</p></figcaption></figure>

## Cloning a database

You can create a new database as a clone of an existing database. For example, you might want a similar set of data that uses international names and addresses.

You cannot clone a live connection database.

You can add the new database to any workspace that you have edit access to.

When you clone a database, you choose whether to preserve the chat history from the original database. By default, the history is not preserved.

To clone a database:

1. In the table list, hover over the database name.

<figure><img src="https://4109733485-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmoU4gTR9LxlzHeWmQCUZ%2Fuploads%2F6Bxy6N0KuR4VoFckv8gZ%2FDataAgent_EditDeleteIcons.png?alt=media&#x26;token=f78da566-b272-4cd2-8208-542c09f387bc" alt=""><figcaption><p>Edit, clone, and delete icons for a Data Agent database</p></figcaption></figure>

2. Click the copy icon.
3. On the **Clone Database** panel:
   1. In the **New Database** **Name** field, provide the name for the new database.
   2. From the **Workspace** dropdown list, select the workspace to add the new database to.
   3. To include the chat history from the original database, check the **Include chat history** checkbox.
   4. Click **Clone Database**.

<figure><img src="https://4109733485-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmoU4gTR9LxlzHeWmQCUZ%2Fuploads%2FOrh0aOLlCyIUMKByS7D8%2FDataAgent_CloneDatabase.png?alt=media&#x26;token=d7579a04-01a8-4d32-9a44-b1d0b184d6a8" alt=""><figcaption></figcaption></figure>

## Renaming a database

To change the name of a database:

1. In the table list, hover over the database name.

<figure><img src="https://4109733485-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmoU4gTR9LxlzHeWmQCUZ%2Fuploads%2F6Bxy6N0KuR4VoFckv8gZ%2FDataAgent_EditDeleteIcons.png?alt=media&#x26;token=f78da566-b272-4cd2-8208-542c09f387bc" alt=""><figcaption><p>Edit, clone, and delete icons for a database</p></figcaption></figure>

2. Click the edit icon.
3. In the **New Database Name** field, provide the new name for the database.
4. Click **Rename Database**.

## Deleting a database

To delete a database.

1. In the table list, hover over the database name.

<figure><img src="https://4109733485-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmoU4gTR9LxlzHeWmQCUZ%2Fuploads%2F6Bxy6N0KuR4VoFckv8gZ%2FDataAgent_EditDeleteIcons.png?alt=media&#x26;token=f78da566-b272-4cd2-8208-542c09f387bc" alt=""><figcaption><p>Edit, clone, and delete icons for a database</p></figcaption></figure>

2. Click the delete icon.
3. On the confirmation panel, click **Delete Database**.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.tonic.ai/fabricate/database-management/data-agent-db-create-manage.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
