1
00:00:02,160 --> 00:00:04,500
So, time to add some data.

2
00:00:04,500 --> 00:00:05,900
And for this, I'll first of all,

3
00:00:05,900 --> 00:00:08,900
start by adding an address and the type,

4
00:00:08,900 --> 00:00:10,060
so that thereafter,

5
00:00:10,060 --> 00:00:11,270
I can add a restaurant

6
00:00:11,270 --> 00:00:14,463
that is linked to that address and that type.

7
00:00:15,830 --> 00:00:18,430
For this, let's maybe start with types.

8
00:00:18,430 --> 00:00:20,510
And, to insert some new data here,

9
00:00:20,510 --> 00:00:23,080
I'll add a new SQL statement.

10
00:00:23,080 --> 00:00:25,500
And then, we learned that we can insert value

11
00:00:25,500 --> 00:00:28,550
with the INSERT INTO statement.

12
00:00:28,550 --> 00:00:33,550
And, I wanna insert data into my types table here.

13
00:00:33,660 --> 00:00:35,720
And then thereafter, between parentheses,

14
00:00:35,720 --> 00:00:39,630
we list all the columns into which you wanna add data.

15
00:00:39,630 --> 00:00:40,463
In my case,

16
00:00:40,463 --> 00:00:43,410
the types table does have two columns,

17
00:00:43,410 --> 00:00:44,650
ID and name.

18
00:00:44,650 --> 00:00:48,560
And, I wanna add a value for the name column,

19
00:00:48,560 --> 00:00:52,460
because the ID will be auto-incremented automatically.

20
00:00:52,460 --> 00:00:55,810
And hence, after the values keyword as you learned,

21
00:00:55,810 --> 00:00:57,940
you now define the concrete values

22
00:00:57,940 --> 00:01:01,280
that will be inserted for the columns you specify here,

23
00:01:01,280 --> 00:01:03,720
so for the name column, in my case.

24
00:01:03,720 --> 00:01:05,200
And that here

25
00:01:05,200 --> 00:01:07,120
could be Italian,

26
00:01:07,120 --> 00:01:11,363
so that we have Italian cuisine as one restaurant type.

27
00:01:13,640 --> 00:01:15,240
We now execute this.

28
00:01:15,240 --> 00:01:16,690
That did

29
00:01:16,690 --> 00:01:17,523
work.

30
00:01:19,300 --> 00:01:20,840
Now, let me clear this.

31
00:01:20,840 --> 00:01:23,260
And, let's also maybe add

32
00:01:23,260 --> 00:01:24,853
American,

33
00:01:26,220 --> 00:01:27,260
and also

34
00:01:27,260 --> 00:01:28,433
German,

35
00:01:29,970 --> 00:01:32,920
and maybe also Austrian.

36
00:01:32,920 --> 00:01:35,150
Now, it's up to you which cuisines you wanna add.

37
00:01:35,150 --> 00:01:37,220
Now, I did add four cuisines.

38
00:01:37,220 --> 00:01:39,750
And therefore to see them,

39
00:01:39,750 --> 00:01:43,430
We can run SELECT + * to select everything,

40
00:01:43,430 --> 00:01:44,620
all the columns,

41
00:01:44,620 --> 00:01:45,610
FROM

42
00:01:45,610 --> 00:01:47,270
types.

43
00:01:47,270 --> 00:01:51,440
And if we execute this here, we see our data.

44
00:01:51,440 --> 00:01:52,863
So, that is working.

45
00:01:55,670 --> 00:01:58,090
Now, it's time to add some addresses.

46
00:01:58,090 --> 00:02:01,010
Now for this, we have the addresses table,

47
00:02:01,010 --> 00:02:02,470
which has these columns.

48
00:02:02,470 --> 00:02:04,080
You'll see here on the left.

49
00:02:04,080 --> 00:02:08,750
And hence now, our SQL statement is INSERT INTO, addresses.

50
00:02:10,340 --> 00:02:14,080
Then, we list the columns into which we wanna insert data.

51
00:02:14,080 --> 00:02:16,450
We don't need to insert anything into ID,

52
00:02:16,450 --> 00:02:18,870
because that's set automatically.

53
00:02:18,870 --> 00:02:21,710
But, I wanna set the value for the street.

54
00:02:21,710 --> 00:02:23,500
Then, separated by a comma,

55
00:02:23,500 --> 00:02:26,040
the next column will be street_number,

56
00:02:27,404 --> 00:02:29,190
then the city,

57
00:02:29,190 --> 00:02:30,823
then the postal code,

58
00:02:31,970 --> 00:02:33,903
and then the country.

59
00:02:35,710 --> 00:02:38,510
So, bunch of columns which I want to populate,

60
00:02:38,510 --> 00:02:41,210
and now we can specify the values.

61
00:02:41,210 --> 00:02:42,043
By the way,

62
00:02:42,043 --> 00:02:44,120
you can also split this across multiple lines

63
00:02:44,120 --> 00:02:46,470
to make this easier to read now.

64
00:02:46,470 --> 00:02:47,800
Here between these parentheses,

65
00:02:47,800 --> 00:02:48,970
we can add a line break

66
00:02:48,970 --> 00:02:51,223
and then add our values here.

67
00:02:52,700 --> 00:02:54,260
So now for the street,

68
00:02:54,260 --> 00:02:56,440
I could work with the Teststreet,

69
00:02:58,890 --> 00:03:00,550
separated by a comma.

70
00:03:00,550 --> 00:03:03,460
The number is a string, is a varchar,

71
00:03:03,460 --> 00:03:08,300
because that's how we defined this field to work.

72
00:03:08,300 --> 00:03:10,630
So, that could be 23a

73
00:03:10,630 --> 00:03:13,403
to also show you why it is a varchar.

74
00:03:15,100 --> 00:03:16,610
Then here for the city,

75
00:03:16,610 --> 00:03:17,983
that could be Munich,

76
00:03:19,270 --> 00:03:20,453
or whatever you want.

77
00:03:21,380 --> 00:03:24,980
Then the postal code, in my case here, is an integer.

78
00:03:24,980 --> 00:03:28,883
So here, that could be this integer value,

79
00:03:30,390 --> 00:03:33,603
no quotes around it, because it is an integer.

80
00:03:34,460 --> 00:03:37,253
And then the country, in this case, is Germany.

81
00:03:39,530 --> 00:03:43,050
And now, if I execute this, that was added.

82
00:03:43,050 --> 00:03:45,860
Now, I'll add a second value here real quick.

83
00:03:45,860 --> 00:03:47,600
So, the

84
00:03:47,600 --> 00:03:48,433
Great

85
00:03:49,330 --> 00:03:50,163
street,

86
00:03:52,060 --> 00:03:53,260
let's say,

87
00:03:53,260 --> 00:03:54,350
12,

88
00:03:54,350 --> 00:03:56,223
in Berlin.

89
00:03:57,240 --> 00:03:59,490
And then here, I got a postal code.

90
00:03:59,490 --> 00:04:01,160
Let's say it's 1

91
00:04:01,160 --> 00:04:03,370
0115,

92
00:04:03,370 --> 00:04:05,190
and it's all the Germany.

93
00:04:05,190 --> 00:04:07,250
And of course, you can add other countries as well.

94
00:04:07,250 --> 00:04:09,450
You can add whichever kind of data you want.

95
00:04:10,410 --> 00:04:11,650
Confirm this.

96
00:04:11,650 --> 00:04:14,810
And now, let's also see whether that data is there

97
00:04:14,810 --> 00:04:18,959
by selecting all the columns from addresses,

98
00:04:18,959 --> 00:04:21,300
and no where constraints,

99
00:04:21,300 --> 00:04:23,730
so we also select all the rows,

100
00:04:23,730 --> 00:04:26,200
and therefore, here's the data I got.

101
00:04:26,200 --> 00:04:28,903
So, that data was stored correctly.

102
00:04:30,450 --> 00:04:33,673
And therefore now, we can start storing a restaurant.

103
00:04:34,830 --> 00:04:37,480
Here, we got these columns which we need to populate.

104
00:04:39,850 --> 00:04:42,713
So again, let's insert a value,

105
00:04:43,610 --> 00:04:45,230
into,

106
00:04:45,230 --> 00:04:46,880
restaurants,

107
00:04:46,880 --> 00:04:49,930
and define the columns which we wanna set.

108
00:04:49,930 --> 00:04:52,350
And here, we don't need to set the ID as always,

109
00:04:52,350 --> 00:04:54,090
but I do want to set the name,

110
00:04:54,090 --> 00:04:55,080
and of course,

111
00:04:55,080 --> 00:04:57,270
also the address_id

112
00:04:57,270 --> 00:05:00,370
to make it clear to which address this restaurant belongs,

113
00:05:00,370 --> 00:05:02,480
so which address it has,

114
00:05:02,480 --> 00:05:03,860
and the type_id.

115
00:05:04,720 --> 00:05:07,063
So, we add these columns as well.

116
00:05:08,060 --> 00:05:11,640
Then, we define the values after the values keyword,

117
00:05:11,640 --> 00:05:12,630
and for the name,

118
00:05:12,630 --> 00:05:14,330
that could be,

119
00:05:14,330 --> 00:05:15,657
the

120
00:05:15,657 --> 00:05:16,857
"Schnitzelhaus",

121
00:05:18,990 --> 00:05:21,810
and the address should be the address in Munich.

122
00:05:21,810 --> 00:05:23,820
And of course, that has an ID of one.

123
00:05:23,820 --> 00:05:25,430
You see it here.

124
00:05:25,430 --> 00:05:30,430
So, I specify one as a value for address_id here.

125
00:05:30,500 --> 00:05:34,530
That's my unique ID that I have here.

126
00:05:34,530 --> 00:05:37,060
And I have to pick this ID,

127
00:05:37,060 --> 00:05:40,000
which my Munich address here has,

128
00:05:40,000 --> 00:05:41,410
in the addresses table,

129
00:05:41,410 --> 00:05:42,810
to link this restaurant,

130
00:05:42,810 --> 00:05:44,090
which I'm about to add,

131
00:05:44,090 --> 00:05:46,703
to this specific first address here.

132
00:05:48,620 --> 00:05:49,540
Now, for the type,

133
00:05:49,540 --> 00:05:52,090
I wanna have German as a type.

134
00:05:52,090 --> 00:05:56,270
And here, I'll quickly add a new SQL statement

135
00:05:56,270 --> 00:05:57,960
where I select

136
00:05:57,960 --> 00:05:59,800
all types again,

137
00:05:59,800 --> 00:06:02,010
so that we can see all the entries here.

138
00:06:02,010 --> 00:06:05,003
And we see that German here has an ID of three.

139
00:06:06,060 --> 00:06:08,830
Therefore, where I insert this,

140
00:06:08,830 --> 00:06:12,880
the value for the type ID should be three here,

141
00:06:12,880 --> 00:06:14,343
separated by a comma.

142
00:06:16,300 --> 00:06:19,390
And therefore, we still add values like before.

143
00:06:19,390 --> 00:06:22,010
There isn't really anything special about it.

144
00:06:22,010 --> 00:06:25,782
But of course, the values I pick for address_id and type_id

145
00:06:25,782 --> 00:06:30,093
are now the concrete IDs I picked from the other tables.

146
00:06:32,290 --> 00:06:34,490
So now, we can run this query,

147
00:06:34,490 --> 00:06:36,240
and that was inserted.

148
00:06:36,240 --> 00:06:39,490
And, if we now add a second restaurant,

149
00:06:39,490 --> 00:06:42,060
let's say the "Burgerhouse",

150
00:06:42,060 --> 00:06:45,920
yeah, I'm super creative when it comes to these names.

151
00:06:45,920 --> 00:06:47,860
And, let's say that's also in Munich.

152
00:06:47,860 --> 00:06:49,700
So I'll keep one here,

153
00:06:49,700 --> 00:06:52,820
but the type now is American.

154
00:06:52,820 --> 00:06:55,953
So, I choose two here as a value,

155
00:06:57,700 --> 00:06:58,660
and,

156
00:06:58,660 --> 00:07:00,220
execute this.

157
00:07:00,220 --> 00:07:02,680
And then, I'll add a third restaurant,

158
00:07:02,680 --> 00:07:03,680
and that that should be,

159
00:07:03,680 --> 00:07:06,490
let's say, some Italian cuisine.

160
00:07:06,490 --> 00:07:08,010
So ID one,

161
00:07:08,010 --> 00:07:08,910
in Berlin,

162
00:07:08,910 --> 00:07:10,343
which has an ID of two.

163
00:07:11,510 --> 00:07:13,110
So, I changed this to two,

164
00:07:13,110 --> 00:07:15,607
and I'll name it "La Mama".

165
00:07:16,860 --> 00:07:20,683
Then, we can run this to also at this restaurant.

166
00:07:21,800 --> 00:07:22,690
And if we now, again,

167
00:07:22,690 --> 00:07:25,890
select everything from restaurants

168
00:07:25,890 --> 00:07:28,380
to have a look at all the stored data,

169
00:07:28,380 --> 00:07:29,973
then this is what we see.

170
00:07:31,090 --> 00:07:32,813
So, that was all stored.

171
00:07:34,250 --> 00:07:38,260
Now, before we learn how we can now query related data,

172
00:07:38,260 --> 00:07:41,710
let's also add a first review already.

173
00:07:41,710 --> 00:07:44,070
And, maybe try adding one on your own

174
00:07:44,070 --> 00:07:45,790
with some arbitrary data,

175
00:07:45,790 --> 00:07:46,880
that's up to you,

176
00:07:46,880 --> 00:07:49,860
with a rating between one and five.

177
00:07:49,860 --> 00:07:51,960
In the next lecture, we'll do it together.

