Over the course of the next few videos, we will be creating a simplified Twitter clone with users and statuses on Hasura. We will create two tables,
statuses and add a foreign key between them. We'll also populate the databases using Hasura's interface.
Ali Spittel: [0:00] We go into the Data tab in order to create some tables. The first table that we're going to create is the users' table. Click Add Table, and then add in a table name. I'm going to call it users.
[0:19] Then we're going to add some columns. First, I'm going to create ID, which will be an auto-incrementing integer, which needs to be unique. It's going to be our Primary Key field, so I'll go ahead and select that. We're also going to have a username which is going to be a Text field. Once I've done that, I'm going to scroll down and click the Add Table button.
[0:48] Now, I'm going to click that Add Table button again and create a statuses table. This one's going to have the column ID, which again is going to be that auto-incrementing Primary Key. I'm going to also have created_at field which is going to be a Timestamp. I'm going to put now() there. I'm also going to add in text. This will be a Text field.
[1:31] Then my final one is going to be user_id which will be an integer. That one's going to be a Foreign Key. This one is going to connect my statuses to my users, so users can have statuses. My user_id column in my status table is going to reference my ID column in my users table.
[1:59] I'm going to click Save and Add Table. Hasura's also going to create us some forms so we can add data. If you click on Insert Row, you can add some users. Now, I have two users, which I can see in my Browse Rows tab.
[2:28] Then I'm going to add some statuses. You can go back to the Browse Rows and see my IDs and created_at were done for me. They both also have text and the user that they reference.
[2:56] In summary, we created some tables. We added some columns, including a relationship between two tables, and then we added data to our database.