﻿1
00:00:01,140 --> 00:00:03,930
‫So let's now implement the cabins,

2
00:00:03,930 --> 00:00:06,570
‫guests and settings tables

3
00:00:06,570 --> 00:00:11,130
‫based on the project requirements that we saw earlier.

4
00:00:11,130 --> 00:00:15,210
‫So if you want, you can have those open at the same time

5
00:00:15,210 --> 00:00:16,980
‫to better understand the reason

6
00:00:16,980 --> 00:00:19,470
‫behind each of the table fields

7
00:00:19,470 --> 00:00:22,443
‫that we are going to create in each table.

8
00:00:23,820 --> 00:00:27,123
‫And let's start with the cabins table.

9
00:00:28,860 --> 00:00:31,200
‫So let's just call it cabins.

10
00:00:31,200 --> 00:00:33,330
‫The description is not necessary.

11
00:00:33,330 --> 00:00:34,770
‫And here, we want to enable

12
00:00:34,770 --> 00:00:37,500
‫something called Row Level Security.

13
00:00:37,500 --> 00:00:40,473
‫And more about what that is a bit later.

14
00:00:41,670 --> 00:00:45,210
‫And then down here, we need to specify exactly

15
00:00:45,210 --> 00:00:48,810
‫all the columns that we want our table to have,

16
00:00:48,810 --> 00:00:52,830
‫or in other words, the fields that each piece of data,

17
00:00:52,830 --> 00:00:56,670
‫so each row in our table should have.

18
00:00:56,670 --> 00:01:01,140
‫So by default, each row in the table will have an ID

19
00:01:01,140 --> 00:01:03,753
‫and this created at timestamp.

20
00:01:05,310 --> 00:01:07,830
‫So let's leave those two.

21
00:01:07,830 --> 00:01:10,260
‫So the timestamp, we could also delete,

22
00:01:10,260 --> 00:01:12,330
‫but it's always a very good idea

23
00:01:12,330 --> 00:01:17,330
‫to be able to know when each row in the table was created.

24
00:01:17,730 --> 00:01:21,270
‫But in here, let's create our own fields,

25
00:01:21,270 --> 00:01:22,473
‫so our own columns.

26
00:01:23,400 --> 00:01:25,710
‫So the first one is gonna be the name,

27
00:01:25,710 --> 00:01:29,010
‫and then here we need to specify the data type.

28
00:01:29,010 --> 00:01:31,353
‫So these are coming from Postgres,

29
00:01:32,280 --> 00:01:34,710
‫but they are pretty intuitive.

30
00:01:34,710 --> 00:01:36,750
‫So the name is just a string

31
00:01:36,750 --> 00:01:40,470
‫and we don't want it to have any default value.

32
00:01:40,470 --> 00:01:42,960
‫And let me just make this a bit bigger,

33
00:01:42,960 --> 00:01:45,540
‫just to make sure that you can actually see

34
00:01:45,540 --> 00:01:46,773
‫what I'm doing here.

35
00:01:48,600 --> 00:01:52,923
‫So next up, let's define the max capacity.

36
00:01:54,330 --> 00:01:57,750
‫And so in this column, we will basically be able to say

37
00:01:57,750 --> 00:02:01,323
‫how many people can rent a certain cabin.

38
00:02:02,340 --> 00:02:05,370
‫So this one is certainly a number.

39
00:02:05,370 --> 00:02:08,220
‫So let's do this integer here.

40
00:02:08,220 --> 00:02:12,060
‫And also, of course, no default value.

41
00:02:12,060 --> 00:02:17,060
‫Then we have the regular price like this.

42
00:02:18,690 --> 00:02:22,680
‫Or we could also use the underscore notation like this,

43
00:02:22,680 --> 00:02:26,400
‫which is actually a bit more common in the database world.

44
00:02:26,400 --> 00:02:29,550
‫But since we are going to use these S variables

45
00:02:29,550 --> 00:02:33,540
‫inside JavaScript later, I prefer to use this notation

46
00:02:33,540 --> 00:02:36,693
‫that we are also used to inside JavaScript.

47
00:02:39,060 --> 00:02:42,060
‫So also an integer.

48
00:02:42,060 --> 00:02:46,080
‫And then let's also have a discount.

49
00:02:46,080 --> 00:02:47,910
‫And these again, are all coming

50
00:02:47,910 --> 00:02:50,610
‫from our list of requirements.

51
00:02:50,610 --> 00:02:54,000
‫So from there, we can understand that this is the data

52
00:02:54,000 --> 00:02:57,003
‫that we need to represent a cabin.

53
00:02:58,170 --> 00:03:02,460
‫Next up, let's also have a description,

54
00:03:02,460 --> 00:03:04,683
‫which is gonna be just text.

55
00:03:08,250 --> 00:03:11,340
‫And finally, an image.

56
00:03:11,340 --> 00:03:15,240
‫Now here, the image will actually also be text,

57
00:03:15,240 --> 00:03:17,430
‫because what we're gonna store in here

58
00:03:17,430 --> 00:03:19,683
‫is just a URL to the image

59
00:03:19,683 --> 00:03:23,910
‫that we are going to upload to a storage bucket.

60
00:03:23,910 --> 00:03:25,620
‫So remember how I mentioned

61
00:03:25,620 --> 00:03:28,890
‫that we have also buckets here in Supabase

62
00:03:28,890 --> 00:03:30,960
‫where we can upload images to.

63
00:03:30,960 --> 00:03:33,660
‫And so we will, in our application,

64
00:03:33,660 --> 00:03:37,980
‫actually be able to upload images and then store the URL

65
00:03:37,980 --> 00:03:40,833
‫to each of them right here in the cabin.

66
00:03:41,670 --> 00:03:43,863
‫And this is actually it.

67
00:03:44,940 --> 00:03:46,890
‫So let's save this.

68
00:03:46,890 --> 00:03:49,350
‫This will now create the new table,

69
00:03:49,350 --> 00:03:51,093
‫which takes a little bit of time.

70
00:03:52,470 --> 00:03:54,300
‫And there we are.

71
00:03:54,300 --> 00:03:58,560
‫So the table is of course empty, as we can see down here.

72
00:03:58,560 --> 00:04:00,270
‫So zero records.

73
00:04:00,270 --> 00:04:02,643
‫And so let's just insert a row here.

74
00:04:03,510 --> 00:04:05,913
‫So just some dummy cabin for now.

75
00:04:07,230 --> 00:04:10,530
‫So let's call this one 001.

76
00:04:10,530 --> 00:04:13,470
‫And we didn't read this anywhere,

77
00:04:13,470 --> 00:04:15,480
‫so this is not in our requirements,

78
00:04:15,480 --> 00:04:19,290
‫but actually the names of the cabins will just be numbered.

79
00:04:19,290 --> 00:04:22,563
‫So 001 all the way to 008.

80
00:04:23,520 --> 00:04:25,560
‫Let's say this is a really small one,

81
00:04:25,560 --> 00:04:30,330
‫just for the max of two people, and it costs 250.

82
00:04:30,330 --> 00:04:32,670
‫So maybe euros or dollars.

83
00:04:32,670 --> 00:04:36,450
‫And right now, there is a discount going on,

84
00:04:36,450 --> 00:04:38,070
‫so of 50.

85
00:04:38,070 --> 00:04:43,070
‫And then let's say, "Small luxury cabin in the woods."

86
00:04:45,240 --> 00:04:47,790
‫Then here, an image we don't have yet,

87
00:04:47,790 --> 00:04:49,650
‫and so let's just save this.

88
00:04:49,650 --> 00:04:53,520
‫And with this, we have our very first cabin in the table.

89
00:04:53,520 --> 00:04:57,090
‫And so let's keep going and create another one.

90
00:04:57,090 --> 00:04:58,890
‫So another table.

91
00:04:58,890 --> 00:05:03,890
‫So next up it is time for our guests table.

92
00:05:04,140 --> 00:05:07,710
‫So again, enabling the Row Level Security

93
00:05:07,710 --> 00:05:11,043
‫and then let's start to add the data that we need.

94
00:05:12,120 --> 00:05:17,120
‫So first, the full name, which is going to be text.

95
00:05:17,880 --> 00:05:18,870
‫So most of the time,

96
00:05:18,870 --> 00:05:22,683
‫we do actually just have text and numbers here.

97
00:05:24,030 --> 00:05:27,150
‫Then we also need their email address,

98
00:05:27,150 --> 00:05:28,600
‫which makes a lot of sense

99
00:05:29,850 --> 00:05:33,540
‫when we are storing any kind of customer information.

100
00:05:33,540 --> 00:05:36,453
‫Let's also add their nationality,

101
00:05:37,590 --> 00:05:41,043
‫which is always nice to know in a hotel,

102
00:05:42,510 --> 00:05:45,963
‫so for example, to know how to greet the guests.

103
00:05:46,800 --> 00:05:51,450
‫And then let's, also here, include a country flag.

104
00:05:51,450 --> 00:05:54,420
‫So this one is also not in the list of requirements,

105
00:05:54,420 --> 00:05:58,030
‫but we will want to have a flag for for each country

106
00:05:58,920 --> 00:06:00,360
‫right in our application.

107
00:06:00,360 --> 00:06:02,850
‫And so I'm storing that there.

108
00:06:02,850 --> 00:06:05,880
‫Then also, to identify the guest,

109
00:06:05,880 --> 00:06:10,863
‫let's create another field for their national ID number.

110
00:06:11,820 --> 00:06:15,090
‫So national ID number.

111
00:06:15,090 --> 00:06:17,970
‫And again, that's going to be text.

112
00:06:17,970 --> 00:06:21,690
‫Some countries use a number and some use some letters,

113
00:06:21,690 --> 00:06:23,800
‫and so it needs to be text here.

114
00:06:23,800 --> 00:06:26,340
‫Here, we can then rearrange this.

115
00:06:26,340 --> 00:06:28,803
‫So I think it makes a bit more sense to be there.

116
00:06:31,140 --> 00:06:36,090
‫Alright, so this is enough to represent a guest.

117
00:06:36,090 --> 00:06:37,653
‫So let's wait for it here.

118
00:06:39,120 --> 00:06:43,380
‫And so let's insert a row.

119
00:06:43,380 --> 00:06:46,170
‫So the ID and this one here

120
00:06:46,170 --> 00:06:49,680
‫are basically created automatically.

121
00:06:49,680 --> 00:06:54,680
‫And then let's just add one for myself.

122
00:06:56,880 --> 00:07:00,423
‫So here I will just use a test email.com.

123
00:07:01,800 --> 00:07:04,830
‫Then this one also doesn't really matter.

124
00:07:04,830 --> 00:07:08,670
‫Nationality, I am German.

125
00:07:08,670 --> 00:07:11,460
‫And here, maybe some emoji,

126
00:07:11,460 --> 00:07:13,623
‫but for now let's just leave it empty.

127
00:07:15,900 --> 00:07:19,053
‫So we're just doing this so we have some data to start with.

128
00:07:21,270 --> 00:07:25,380
‫And so, now let's create our final table for now,

129
00:07:25,380 --> 00:07:27,753
‫which is gonna be four settings.

130
00:07:30,990 --> 00:07:34,410
‫So here we will be able to define four settings,

131
00:07:34,410 --> 00:07:38,313
‫which is the minimum booking length.

132
00:07:41,010 --> 00:07:42,243
‫So this is a number.

133
00:07:44,520 --> 00:07:47,880
‫And all of these are actually coming directly

134
00:07:47,880 --> 00:07:50,910
‫from the list of requirements.

135
00:07:50,910 --> 00:07:53,523
‫So max booking length.

136
00:07:54,990 --> 00:07:56,373
‫Again, an integer.

137
00:07:58,410 --> 00:08:02,710
‫Then the max number of guests per booking.

138
00:08:05,880 --> 00:08:06,930
‫Again, two.

139
00:08:06,930 --> 00:08:10,473
‫And finally, the breakfast price.

140
00:08:13,890 --> 00:08:15,570
‫And again a number.

141
00:08:15,570 --> 00:08:19,200
‫And here, maybe let's not use an integer, but a float.

142
00:08:19,200 --> 00:08:23,070
‫So for example, the breakfast might be 9.99,

143
00:08:23,070 --> 00:08:25,053
‫so then that's not an integer.

144
00:08:26,460 --> 00:08:29,790
‫Alright, so let's save this again.

145
00:08:29,790 --> 00:08:31,260
‫And this is actually a bit

146
00:08:31,260 --> 00:08:33,660
‫of a special kind of table for us,

147
00:08:33,660 --> 00:08:37,740
‫because here we will really only have one row,

148
00:08:37,740 --> 00:08:41,430
‫because there do not need to be multiple settings

149
00:08:41,430 --> 00:08:45,900
‫all with a different minimum booking length, for example.

150
00:08:45,900 --> 00:08:48,690
‫We just want to set each of them here once

151
00:08:48,690 --> 00:08:52,410
‫and we want them to be able to live here in our database.

152
00:08:52,410 --> 00:08:54,330
‫And so we just created this table,

153
00:08:54,330 --> 00:08:58,953
‫but as I just said, it will only have exactly this one row.

154
00:08:59,790 --> 00:09:02,550
‫So here, let's say that the minimum length

155
00:09:02,550 --> 00:09:04,710
‫needs to be three nights.

156
00:09:04,710 --> 00:09:08,523
‫And most, maybe the guests can stay for 90 days

157
00:09:08,523 --> 00:09:12,000
‫and at most, it can be eight people.

158
00:09:12,000 --> 00:09:14,433
‫And the breakfast costs 15.

159
00:09:16,260 --> 00:09:17,850
‫So let's save that.

160
00:09:17,850 --> 00:09:22,290
‫And with this, we have our three first tables created.

161
00:09:22,290 --> 00:09:26,010
‫And so next up, let's then create the more complicated table

162
00:09:26,010 --> 00:09:28,143
‫which are going to be the bookings.

