Chapter 2:
Create your database table

We’ll use Data Tables to store feedback from our users. Data Tables are an out-of-the-box option for data storage in Anvil, and they’re backed by PostgreSQL.

Step 1: Add the Data Tables service

In the panel on the left (the App Browser), click the ‘+’ next to ‘Services’, then click on Data Tables.

Adding the Data Tables service

Step 2: Feedback

Now set up your “feedback” table, with the following columns:

  • name (Text column)
  • email (Text column)
  • feedback (Text column)
  • created (Date and Time column)

Here’s how to do that:

  1. Click ‘Add a table’ in the light blue box at the top, then ‘Create new table…’. You’ll be prompted to give your table a name - let’s call it ‘feedback’.

  2. Next, add a column for the name of the person submitting feedback, by clicking ‘+ New Column’ and choosing ‘Add text column…’. Call this column ‘name’.

  3. Keep adding columns until your Data Table has the structure we described above. Column titles are case sensitive, so let’s stick to lower case.

Creating a Data Table

Your Data Table should look something like this:

The final Data Table

In Chapter 3, we’ll write some server-side code to store data in the new Data Table.

Chapter complete

Nice work! Your Data Table is set up and ready to use.

In chapter 3, you’ll write some server-side code to store the feedback in it.