2.4 Database Tables

The first thing you want to do after you have created a database is to add tables to the database. But to do that, we need to have a clear understanding of what the model should look like.

What will be awesome is if users can be part of multiple accounts and send tweets through those accounts if possible. What good is a product like Herm if the users can’t connect multiple accounts?

We want a many-to-many relationship between an accounts' table and a users' table.

Let’s make this model come to live on Hasura.


  • Create tables in Hasura
  • Learn how to add primary keys to tables
  • Add unique constraints to primary keys and fields like email and username

Exercise 1: Create Account Table

Task 1: Create an Account table

Click on the Data tab then click on the Add Table button:

Task 2: Add columns to Account table

Fill out the table columns with the bare minimum values, as shown in the model:

Task 3: Add a primary key to Account table

Right below the column names, you will find a field for setting the table’s primary key. The primary key is a unique identifier for each row in your table.

Task 4: Save the Account table

Lastly, scroll down to the end of the page and click Add Table to persist your changes.

Exercise 2: Create a User Table

Create a user table using the same steps you learned when creating the account table. The columns should also be the same as what you see in the database table model.

Here is what it should look like: