Getting Started

Xata is currently a closed beta. If you've been given early access, you will be able to login at From here, you will be able to create a workspace. Workspaces are like GitHub organizations, and are intended to represent your organization. Inside workspaces, you can have multiple databases. We’ll talk more about workspaces later in this guide. For now, these 3 steps should get you up to speed with Xata.

1. Create a Database

What you’ll see after you login for the first time to Xata is an “Add a database” button. You can use this to create your first database.

Adding a database button in Xata

Adding a database button in Xata

Once your database is created, we’ll need to create one or more tables.

2. Create Tables

Xata is schemaful and models data with tables, columns, and rows. This structure is called a schema. To create a table, click “+ Add a Table” and fill out a table name.

Adding a table to a database

Adding a table to a database

We can now define the schema for this table using the “+” icon on the table header. All tables start out with one column by default: the id column, which provides a unique identity to each row. For more information about this column, learn more about the data model. It can contain any value that is unique across all rows of data.

When adding columns, we note that each column has multiple types to choose from. These are:

  • Link: A link to another table to form relationships between tables. Rows of this column type link to a single record in another table, like a blog post in a table posts linking to an author in another table authors. We will explore this further below.
  • String: A single line of text.
  • Long Text: A paragraph of text or more.
  • Integer number: A numeric value.
  • Decimal number: A floating point numeric value.
  • Date A date and time value.
  • Boolean: Works like a checkbox: it’s true or false for each row.
  • Multiple Select: Multiple pre-determined values, can be thought of as an array of strings.
  • Email: An email address format.

We can use this information to define a schema for our table.

From here, we generally recommend adding a little bit of seed data to your database that we can query to ensure everything’s working as expected. We can then delete this data via Xata’s API to get familiar with it. We can add data to our table by clicking the “+” in the last empty row in the table.

For more information on how to work with data in Xata, check out our Records API guide.

Once this is done, we can repeat the process to create other tables, and relate them to each other as needed using the Link column type.

Relationships Between Tables

A common use case for relationships between tables is a parent → child type structure. As an example, if we’re building a database for a blog, we’ll have a table for blog posts and a table for authors that are linked to each other.

Creating a Relationship Between Tables using Link Columns

In this scenario with Xata, we add a column of type Link from our posts table to authors to form the relationship. When queried, each table will return its own data and include data from its related table as well: that is, when querying for blog posts, each post will also include its author’s data depending on how we perform the query.

This is one way Xata simplifies relationships between tables: it’s only a matter of adding a column. Nothing more.

3. Work with Your Data

At this point, Xata is ready to process requests for data from clients, and insert incoming data after the database was set up as described above. Let's look at how we can work with our data.

When our tables are set up and ready to be consumed, we can use Xata’s table view to explore and fine-tune our data using the parameters above the table, namely:

  • Filter for retrieving data that fits one or more criteria,
  • Sort for sorting your data in a specific order per your app’s preference,
  • Paginate for retrieving a pageable subset of your data, and
  • Columns for retrieving only a few selected columns to improve performance and enforce least privilege security.

Working with Your New Database

Working with Your New Database

Once you’re happy with the settings of these parameters, clicking the “Get Code Snippet” button will provide a code snippet in a familiar programming language. By copy-pasting this code, you will create a query that returns the data you currently see in the table – including filter, sort, and other parameters.

Next Steps

So far, we’ve created a database, defined a schema, entered data, and consumed it from a client. Next, let’s explore Xata’s API to learn how to work with the data, either via the Xata Command Line Interface (CLI) or from your favorite programming language.

Last modified 29 days ago