Documentation

Tables

⚠ WARNING: This page contains information that only applies to FeatureBase Cloud. Additionally, this page represents a work in progress that is subject to frequent changes.

A table is an object within a database that stores related data. A table here is analogous to a table found in a traditional RDBMS. A table is created and must be uniquely named within a database. Table names are immutable. Tables contain data, a schema that details the structure of the data, and an optional description of the table (defined when the table is created). You must create a table before you can ingest data.

Before you begin

Create A Table

In the user interface, click on “Tables” on the left hand navigation bar. You will see a list of all the tables that currently exist. Click “New Table” to create a table. You will be prompted to pick a database using a dropdown. This is populated by all the databases in your organization. You will now type in a table name. The table names can only contain lowercase alphanumeric characters, dashes (-), and underscores (_) but must start with an alphabetic character. This name is immutable, so it’s important to name it appropriately. Additionally, an optional description of the table can be entered to help existing and new users understand what data the table contains and what its intended purpose is.

The most important aspect of creating your table is indicating whether the _id column is a unique number (positive integer) or a unique string (passed as a single column or concatenation of multiple columns). The _id acts as the primary key of your table and must uniquely represent a record in your table. If your data has a unique key that is a positive integer, you should select Number. If your data has a unique string key or has a combination of columns that can be used to create a unique key, pick String. This cannot be changed after creation, so ensure you pick the appropriate choice for your data. Click “Create” to create your table.

Create a table using the API

Creating the table can also be accomplished programmatically.

If you select a number for the ID, keys is false, and is otherwise true. You can see the full table api here.

HTTP API Reference:

curl --location --request POST 'https://api.featurebase.com/v2/tables/<database_id>' \
--header 'Authorization: Bearer <IdToken>' \
--header 'Content-Type: application/json' \
--data-raw '{
    "name": "<table name>",
    "description": "<table description>"
    "options": {"keys":<bool>}    
}'

Add or delete table columns

Once a table is created, columns can be added or deleted one at a time. It is highly recommended to create tables and columns within the UI for easier mapping of column types, constraints, and options. Click on the name of your table and go to the “COLUMNS” tab in order to add or delete columns. You will see the _id column that was created during table creation. This is the only immutable column that cannot be deleted.

Create a column

To create a column, click “ADD COLUMN”. You will have to provide a column name unique to this table and only contains lowercase alphanumeric characters, dashes (-), and underscores (_) but must start with an alphabetic character. Next, pick the data type for this column, which will automatically populate the relevant constraints you can apply to that type. Types and constraints help define the incoming data and how it will be stored in FeatureBase. The valid data types and constraints can be seen here. Constraints and types have to be defined during column creation and cannot be altered after creation.

Creating a column can also be accomplished programmatically, but is not recommended at this time. Using this API references types listed here.

HTTP API Reference:

curl --location --request POST 'https://api.featurebase.com/v2/tables/<database_id>/<table_name>/fields/<column_name>' \
--header 'Authorization: Bearer <IdToken>' \
--header 'Content-Type: application/json' \
--data-raw '{
    "options": {"type": "<data_type>", <constraint_options>}
}'

Delete a column

To delete a column, find the three dots next to the column you want to delete, click “Delete”, and confirm the deletion. Deleting a column DROPS THE UNDERLYING DATA AND CANNOT BE RECOVERED. Only delete a column if you do not need the underlying data.

Deleting a column can also be accomplished programmatically.

HTTP API Reference:

curl --location --request DELETE 'https://api.featurebase.com/v2/tables/<database_id>/<table_name>/fields/<column_name>' \
--header 'Authorization: Bearer <IdToken>' \
--header 'Content-Type: application/json' \

Drop table

You can also drop the entire table by going to the “TABLE DETAILS” tab, clicking “DROP TABLE”, and confirming the drop. Like deleting a columns, this action DROPS THE UNDERLYING DATA AND CANNOT BE RECOVERED. Only delete a table if you do not need the underlying data.

Deleting a table can also be accomplished programmatically.

HTTP API Reference:

curl --location --request DELETE 'https://api.featurebase.com/v2/tables/<database_id>/<table_name>' \
--header 'Authorization: Bearer <IdToken>' \
--header 'Content-Type: application/json' \

Once you have created a table, you are ready to load data into it.

Next step

Something missing or incorrect?
Help improve this article or join us on Discord!

© 2022 Molecula Corp. (DBA FeatureBase). All rights reserved.