‫So let's now implement the cabins,
‫guests and settings tables
‫based on the project requirements that we saw earlier.
‫So if you want, you can have those open at the same time
‫to better understand the reason
‫behind each of the table fields
‫that we are going to create in each table.
‫And let's start with the cabins table.
‫So let's just call it cabins.
‫The description is not necessary.
‫And here, we want to enable
‫something called Row Level Security.
‫And more about what that is a bit later.
‫And then down here, we need to specify exactly
‫all the columns that we want our table to have,
‫or in other words, the fields that each piece of data,
‫so each row in our table should have.
‫So by default, each row in the table will have an ID
‫and this created at timestamp.
‫So let's leave those two.
‫So the timestamp, we could also delete,
‫but it's always a very good idea
‫to be able to know when each row in the table was created.
‫But in here, let's create our own fields,
‫so our own columns.
‫So the first one is gonna be the name,
‫and then here we need to specify the data type.
‫So these are coming from Postgres,
‫but they are pretty intuitive.
‫So the name is just a string
‫and we don't want it to have any default value.
‫And let me just make this a bit bigger,
‫just to make sure that you can actually see
‫what I'm doing here.
‫So next up, let's define the max capacity.
‫And so in this column, we will basically be able to say
‫how many people can rent a certain cabin.
‫So this one is certainly a number.
‫So let's do this integer here.
‫And also, of course, no default value.
‫Then we have the regular price like this.
‫Or we could also use the underscore notation like this,
‫which is actually a bit more common in the database world.
‫But since we are going to use these S variables
‫inside JavaScript later, I prefer to use this notation
‫that we are also used to inside JavaScript.
‫So also an integer.
‫And then let's also have a discount.
‫And these again, are all coming
‫from our list of requirements.
‫So from there, we can understand that this is the data
‫that we need to represent a cabin.
‫Next up, let's also have a description,
‫which is gonna be just text.
‫And finally, an image.
‫Now here, the image will actually also be text,
‫because what we're gonna store in here
‫is just a URL to the image
‫that we are going to upload to a storage bucket.
‫So remember how I mentioned
‫that we have also buckets here in Supabase
‫where we can upload images to.
‫And so we will, in our application,
‫actually be able to upload images and then store the URL
‫to each of them right here in the cabin.
‫And this is actually it.
‫So let's save this.
‫This will now create the new table,
‫which takes a little bit of time.
‫And there we are.
‫So the table is of course empty, as we can see down here.
‫So zero records.
‫And so let's just insert a row here.
‫So just some dummy cabin for now.
‫So let's call this one 001.
‫And we didn't read this anywhere,
‫so this is not in our requirements,
‫but actually the names of the cabins will just be numbered.
‫So 001 all the way to 008.
‫Let's say this is a really small one,
‫just for the max of two people, and it costs 250.
‫So maybe euros or dollars.
‫And right now, there is a discount going on,
‫so of 50.
‫And then let's say, "Small luxury cabin in the woods."
‫Then here, an image we don't have yet,
‫and so let's just save this.
‫And with this, we have our very first cabin in the table.
‫And so let's keep going and create another one.
‫So another table.
‫So next up it is time for our guests table.
‫So again, enabling the Row Level Security
‫and then let's start to add the data that we need.
‫So first, the full name, which is going to be text.
‫So most of the time,
‫we do actually just have text and numbers here.
‫Then we also need their email address,
‫which makes a lot of sense
‫when we are storing any kind of customer information.
‫Let's also add their nationality,
‫which is always nice to know in a hotel,
‫so for example, to know how to greet the guests.
‫And then let's, also here, include a country flag.
‫So this one is also not in the list of requirements,
‫but we will want to have a flag for for each country
‫right in our application.
‫And so I'm storing that there.
‫Then also, to identify the guest,
‫let's create another field for their national ID number.
‫So national ID number.
‫And again, that's going to be text.
‫Some countries use a number and some use some letters,
‫and so it needs to be text here.
‫Here, we can then rearrange this.
‫So I think it makes a bit more sense to be there.
‫Alright, so this is enough to represent a guest.
‫So let's wait for it here.
‫And so let's insert a row.
‫So the ID and this one here
‫are basically created automatically.
‫And then let's just add one for myself.
‫So here I will just use a test email.com.
‫Then this one also doesn't really matter.
‫Nationality, I am German.
‫And here, maybe some emoji,
‫but for now let's just leave it empty.
‫So we're just doing this so we have some data to start with.
‫And so, now let's create our final table for now,
‫which is gonna be four settings.
‫So here we will be able to define four settings,
‫which is the minimum booking length.
‫So this is a number.
‫And all of these are actually coming directly
‫from the list of requirements.
‫So max booking length.
‫Again, an integer.
‫Then the max number of guests per booking.
‫Again, two.
‫And finally, the breakfast price.
‫And again a number.
‫And here, maybe let's not use an integer, but a float.
‫So for example, the breakfast might be 9.99,
‫so then that's not an integer.
‫Alright, so let's save this again.
‫And this is actually a bit
‫of a special kind of table for us,
‫because here we will really only have one row,
‫because there do not need to be multiple settings
‫all with a different minimum booking length, for example.
‫We just want to set each of them here once
‫and we want them to be able to live here in our database.
‫And so we just created this table,
‫but as I just said, it will only have exactly this one row.
‫So here, let's say that the minimum length
‫needs to be three nights.
‫And most, maybe the guests can stay for 90 days
‫and at most, it can be eight people.
‫And the breakfast costs 15.
‫So let's save that.
‫And with this, we have our three first tables created.
‫And so next up, let's then create the more complicated table
‫which are going to be the bookings.