# Tables

## Overview

It is best practice to create the data model (tables, primary keys, foreign keys, and fields) before starting to create a solution. Objects in the database can be created with database tools built to administer the database, or within Servoy Developer.\
This guide will demonstrate how to work with database tables, including creating/deleting as well as additional settings that affect the behavior of applications.

## Get Started

Once the database server connection has been set up, developers now have the possibility to access and manage database [tables](/reference/servoycore/object-model/database-server/table.md).

Below are a few examples to begin working with tables.

### Open a table

Servoy applications can access the databases tables that are already created.

To view an existing table, open the [Database Servers](/reference/servoy-developer/solution-explorer/resources/database-servers.md) node in the [Solution Explorer](/reference/servoy-developer/solution-explorer.md), then open the database you need and right-click the [Table](/reference/servoy-developer/solution-explorer/resources/database-servers/database-server/tables.md) and select [Edit table/view](/reference/servoy-developer/solution-explorer/resources/database-servers/database-server/tables.md). This can also be done by double clicking the name of the table instead of right clicking on it and selecting an option.

<div align="left"><figure><img src="/files/pAvI4wOHzLLD3esiK4fZ" alt="" width="650"><figcaption><p>Open an existing table</p></figcaption></figure></div>

### Edit a table

In order to edit a table in Servoy Developer, you should first have [connected to your database](/guides/develop/application-design/data-modeling/databases.md#connect-to-a-database) and [opened the table](#open-a-table) in the [Table Editor](/reference/servoy-developer/object-editors/table-editor.md).

Here you can manage:

* [columns](/guides/develop/application-design/data-modeling/databases/tables/columns.md#columns)
* [calculations](/guides/develop/application-design/data-modeling/databases/tables/calculations.md#calculations)
* [aggregations](/guides/develop/application-design/data-modeling/databases/tables/aggregations.md#aggregations)
* [methods](/guides/develop/application-design/data-modeling/databases/tables/methods.md#methods)
* [events/triggers](/guides/develop/application-design/data-modeling/databases/tables/events-triggers.md#events--triggers)

### Create a table

Here are the steps of creating a table in Servoy Developer:

<div align="left"><figure><img src="/files/gEKnhMtvofS8DWK5dzR8" alt="" width="650"><figcaption><p>Create a table</p></figcaption></figure></div>

1. Right click on the database name in the [Database Servers](/reference/servoy-developer/solution-explorer/resources/database-servers.md) node and select [Create Table](/reference/servoy-developer/solution-explorer/resources/database-servers/database-server/tables.md) **OR** with the database name selected, click on the create table button in toolbar of the list view in [Solution Explorer](/reference/servoy-developer/solution-explorer.md).
2. A dialog will ask for the name for a new table, where you should enter a preferred name.
3. The [table editor view](/reference/servoy-developer/object-editors/table-editor.md) will appear allowing new [columns](/guides/develop/application-design/data-modeling/databases/tables/columns.md#columns) to be entered.

{% hint style="info" %}
When a new table is created, Servoy will add a column in the table editor for the primary key. All tables used in Servoy must have a primary key or a row identifier.
{% endhint %}

### Delete a table

To delete an existing table, open the [Database Servers](/reference/servoy-developer/solution-explorer/resources/database-servers.md) node in the [Solution Explorer](/reference/servoy-developer/solution-explorer.md), then open the database you need and right-click the [Table](/reference/servoy-developer/solution-explorer/resources/database-servers/database-server/tables.md), then select [Delete table](/reference/servoy-developer/solution-explorer/resources/database-servers/database-server/tables.md). You will be asked to confirm the delete.

{% hint style="warning" %}
**No Undo**\
When you drop a table from a database server, there is no undo. While you can re-add the table at any time, any data in that table will still be lost.
{% endhint %}

{% hint style="warning" %}
**Unresolved Data Bindings**\
When you drop a table, you may also create errors in your application if you have objects bound to that table, such as a field on a form or a relation. These errors can be resolved in Servoy Developer.
{% endhint %}

<div align="left"><figure><img src="/files/rsivBXoyS2gJKPzIlMx5" alt="" width="650"><figcaption><p>Deleting a table</p></figcaption></figure></div>


---

# 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.servoy.com/guides/develop/application-design/data-modeling/databases/tables.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.
