1
00:00:02,280 --> 00:00:04,380
So, what's the problem?

2
00:00:04,380 --> 00:00:07,980
Why do we need such a database thing?

3
00:00:07,980 --> 00:00:10,550
Well, up to this point in the course,

4
00:00:10,550 --> 00:00:13,330
when we stored data permanently,

5
00:00:13,330 --> 00:00:16,900
we always stored it in files.

6
00:00:16,900 --> 00:00:19,480
We simply wrote data into a file,

7
00:00:19,480 --> 00:00:21,570
and when we needed that data,

8
00:00:21,570 --> 00:00:23,910
we read it from that file.

9
00:00:23,910 --> 00:00:25,620
That's what we did before,

10
00:00:25,620 --> 00:00:27,400
we write data to a file,

11
00:00:27,400 --> 00:00:29,810
we fetch data from a file.

12
00:00:29,810 --> 00:00:32,780
And then we might filter that fetched data

13
00:00:32,780 --> 00:00:35,770
for a specific ID for example,

14
00:00:35,770 --> 00:00:38,330
as we did it here for restaurants,

15
00:00:38,330 --> 00:00:41,320
where we then went through all the fetched restaurants

16
00:00:41,320 --> 00:00:43,360
to get a specific restaurant,

17
00:00:43,360 --> 00:00:46,250
but we always interacted with the file system

18
00:00:46,250 --> 00:00:47,750
just like that.

19
00:00:47,750 --> 00:00:49,860
Now, whilst that worked,

20
00:00:49,860 --> 00:00:53,450
it's not great because when we create data

21
00:00:53,450 --> 00:00:56,460
and we always replace the entire content of a file

22
00:00:56,460 --> 00:00:58,130
with the new data,

23
00:00:58,130 --> 00:01:01,120
or when we read data and we then always read

24
00:01:01,120 --> 00:01:05,099
the entire file content just to then loop through it

25
00:01:05,099 --> 00:01:07,670
and find a specific element.

26
00:01:07,670 --> 00:01:11,060
Or if we might want to update or delete data,

27
00:01:11,060 --> 00:01:11,950
and for that,

28
00:01:11,950 --> 00:01:16,050
we also read the entire content to then find the element

29
00:01:16,050 --> 00:01:17,960
we wanna update or delete,

30
00:01:17,960 --> 00:01:21,020
then update the entire data and write it back.

31
00:01:21,020 --> 00:01:23,180
If we always do it like this,

32
00:01:23,180 --> 00:01:25,700
then this is pretty inefficient

33
00:01:25,700 --> 00:01:29,120
because we always overwrite everything,

34
00:01:29,120 --> 00:01:31,790
we always read everything,

35
00:01:31,790 --> 00:01:33,100
and that of course,

36
00:01:33,100 --> 00:01:37,070
we're explore various simple demo projects and websites,

37
00:01:37,070 --> 00:01:41,210
but if our website grows and we have more and more data,

38
00:01:41,210 --> 00:01:45,500
that will simply lead to performance issues and our code

39
00:01:45,500 --> 00:01:48,023
will do unnecessarily much work.

40
00:01:48,980 --> 00:01:49,980
As a side note,

41
00:01:49,980 --> 00:01:51,910
the operations we see here,

42
00:01:51,910 --> 00:01:54,730
creating, reading, updating and deleting,

43
00:01:54,730 --> 00:01:58,020
are very common and therefore commonly referred

44
00:01:58,020 --> 00:02:00,660
to as CRUD operations.

45
00:02:00,660 --> 00:02:02,600
And you will see them over and over again

46
00:02:02,600 --> 00:02:04,350
throughout the course and especially,

47
00:02:04,350 --> 00:02:06,530
also throughout the next sections,

48
00:02:06,530 --> 00:02:08,323
which are about databases.

49
00:02:09,850 --> 00:02:11,480
But back to this problem here.

50
00:02:11,480 --> 00:02:12,660
It's pretty inefficient

51
00:02:12,660 --> 00:02:15,780
if we always work with all the data

52
00:02:15,780 --> 00:02:18,270
and it's not just inefficient because we work

53
00:02:18,270 --> 00:02:20,210
with too much data,

54
00:02:20,210 --> 00:02:23,480
because we could try to do that more efficiently.

55
00:02:23,480 --> 00:02:26,570
When working with files as we did it here,

56
00:02:26,570 --> 00:02:29,100
we don't have to read the entire file.

57
00:02:29,100 --> 00:02:31,880
We don't have to write the entire file.

58
00:02:31,880 --> 00:02:35,150
NodeJS and other programming languages

59
00:02:35,150 --> 00:02:39,400
give us tools that would allow us to read parts of a file

60
00:02:39,400 --> 00:02:42,250
or write two parts of a file.

61
00:02:42,250 --> 00:02:44,750
So, we could optimize that.

62
00:02:44,750 --> 00:02:45,583
But as I said,

63
00:02:45,583 --> 00:02:49,480
it's not just the inefficiency in our bulk operations

64
00:02:49,480 --> 00:02:51,110
that we have at the moment,

65
00:02:51,110 --> 00:02:53,210
but instead in addition,

66
00:02:53,210 --> 00:02:56,220
we can simply run into scalability issues

67
00:02:56,220 --> 00:02:58,039
as our data size grows,

68
00:02:58,039 --> 00:03:00,250
as we have more, more data.

69
00:03:00,250 --> 00:03:02,800
And if we have more and more requests

70
00:03:02,800 --> 00:03:04,350
coming into our server,

71
00:03:04,350 --> 00:03:06,450
we can also run into issues

72
00:03:06,450 --> 00:03:09,780
because we can have concurrent file access

73
00:03:09,780 --> 00:03:13,140
where because of 10 incoming requests,

74
00:03:13,140 --> 00:03:17,550
we try to write to exactly the same file 10 times

75
00:03:17,550 --> 00:03:19,870
at the same point of time.

76
00:03:19,870 --> 00:03:23,300
So, we could have multiple read and/or write operations

77
00:03:23,300 --> 00:03:27,190
targeting the same file at the exact same point of time.

78
00:03:27,190 --> 00:03:30,180
And that could cause us big issues

79
00:03:30,180 --> 00:03:34,030
where reading then fails or writing fails,

80
00:03:34,030 --> 00:03:37,890
or we accidentally overwrite data from another request

81
00:03:37,890 --> 00:03:40,080
because we have two requests coming in

82
00:03:40,080 --> 00:03:41,493
at the same point of time.

83
00:03:42,520 --> 00:03:44,110
And in addition,

84
00:03:44,110 --> 00:03:47,610
we also might overwhelm our computer, our system

85
00:03:47,610 --> 00:03:48,443
as a whole,

86
00:03:48,443 --> 00:03:50,140
or at least the file system

87
00:03:50,140 --> 00:03:55,020
if we have too many concurrent read and write operations.

88
00:03:55,020 --> 00:03:59,300
So, as our website grows and handles more and more visitors,

89
00:03:59,300 --> 00:04:01,660
we can face more and more issues

90
00:04:01,660 --> 00:04:03,990
if we store and retrieve data,

91
00:04:03,990 --> 00:04:06,350
as we did it up to this point.

92
00:04:06,350 --> 00:04:08,730
Therefore, that was great for getting started

93
00:04:08,730 --> 00:04:10,410
with backend development,

94
00:04:10,410 --> 00:04:12,680
but it's typically not how you would store

95
00:04:12,680 --> 00:04:16,079
and fetch your data in real websites.

96
00:04:16,079 --> 00:04:19,600
And that's where databases help us.

97
00:04:19,600 --> 00:04:22,230
That's why databases are super important,

98
00:04:22,230 --> 00:04:26,070
and part of basically any website you're building.

99
00:04:26,070 --> 00:04:30,570
Because database management systems or DBMS

100
00:04:30,570 --> 00:04:32,990
are simply software systems,

101
00:04:32,990 --> 00:04:36,130
so, software you install on some system,

102
00:04:36,130 --> 00:04:37,310
you could say,

103
00:04:37,310 --> 00:04:41,930
that are optimized for data storage tasks,

104
00:04:41,930 --> 00:04:42,960
under the hood,

105
00:04:42,960 --> 00:04:46,630
they will still store data and files at some point,

106
00:04:46,630 --> 00:04:48,850
but they do it in a way more efficient way,

107
00:04:48,850 --> 00:04:53,530
taking away all the heavy lifting of managing file access

108
00:04:53,530 --> 00:04:56,470
and concurrent read and write access from you,

109
00:04:56,470 --> 00:04:59,440
and allowing you to just work with your data

110
00:04:59,440 --> 00:05:02,350
without having to worry about how that data

111
00:05:02,350 --> 00:05:06,283
is then written to a file or how it's fetched from a file.

112
00:05:07,200 --> 00:05:09,530
So, database management systems

113
00:05:09,530 --> 00:05:13,420
help us by optimizing read-write access,

114
00:05:13,420 --> 00:05:16,260
by taking away that pain from us.

115
00:05:16,260 --> 00:05:18,850
They help us by simply optimizing

116
00:05:18,850 --> 00:05:21,470
how data is stored and retrieved

117
00:05:21,470 --> 00:05:23,350
to make that more efficient,

118
00:05:23,350 --> 00:05:26,740
and don't overwhelm our files system

119
00:05:26,740 --> 00:05:29,530
and they optimize data querying

120
00:05:29,530 --> 00:05:32,390
by helping us with rich queries,

121
00:05:32,390 --> 00:05:35,330
by giving us specific query languages

122
00:05:35,330 --> 00:05:38,530
that allow us to find specific pieces of data

123
00:05:38,530 --> 00:05:41,340
in a large chunk of data with these,

124
00:05:41,340 --> 00:05:43,570
so that we have to write less code

125
00:05:43,570 --> 00:05:46,100
for the same or even more work

126
00:05:46,100 --> 00:05:49,130
that we want to do in our website.

127
00:05:49,130 --> 00:05:51,430
And therefore, database management systems

128
00:05:51,430 --> 00:05:54,660
are a must use if you have a website

129
00:05:54,660 --> 00:05:57,703
where you are storing and fetching data.

130
00:05:58,750 --> 00:06:00,100
And turns out,

131
00:06:00,100 --> 00:06:03,590
that many websites do that in some form.

132
00:06:03,590 --> 00:06:06,480
Now, there are many database management systems

133
00:06:06,480 --> 00:06:07,550
you could use.

134
00:06:07,550 --> 00:06:10,910
There are many providers, free ones and paid ones,

135
00:06:10,910 --> 00:06:13,860
but there are two main kind of systems

136
00:06:13,860 --> 00:06:15,600
in the end that you can use.

137
00:06:15,600 --> 00:06:17,360
And then for each system,

138
00:06:17,360 --> 00:06:21,860
you'll have plenty of possible database software solutions

139
00:06:21,860 --> 00:06:22,870
to choose from,

140
00:06:22,870 --> 00:06:25,993
but there are two main kinds of databases in the end.

141
00:06:26,910 --> 00:06:31,260
And that would be relational database management systems,

142
00:06:31,260 --> 00:06:34,910
also often called SQL databases.

143
00:06:34,910 --> 00:06:39,900
And SQL often is translated with structured query language,

144
00:06:39,900 --> 00:06:43,760
which means that SQL stands for structured query language.

145
00:06:43,760 --> 00:06:45,060
And you can use that,

146
00:06:45,060 --> 00:06:47,360
but actually it's not coming from that.

147
00:06:47,360 --> 00:06:49,230
It's not an acronym for that.

148
00:06:49,230 --> 00:06:53,650
Instead, SQL originally was called Sequel written like this,

149
00:06:53,650 --> 00:06:58,560
and then it was just shortened to SQL basically.

150
00:06:58,560 --> 00:06:59,930
Now, that's just a side note.

151
00:06:59,930 --> 00:07:03,410
It is a programming language kind of,

152
00:07:03,410 --> 00:07:07,280
that is built for getting data from databases

153
00:07:07,280 --> 00:07:10,790
and storing data in databases or in general,

154
00:07:10,790 --> 00:07:12,450
a language for talking

155
00:07:12,450 --> 00:07:16,220
to such relational database management systems.

156
00:07:16,220 --> 00:07:17,620
That's what SQL is.

157
00:07:17,620 --> 00:07:20,630
And that is what we will learn from this course.

158
00:07:20,630 --> 00:07:23,520
But besides such SQL databases

159
00:07:23,520 --> 00:07:26,000
that use this programming language

160
00:07:26,000 --> 00:07:28,450
for fetching data and writing data,

161
00:07:28,450 --> 00:07:32,490
we also have non-relational database management systems,

162
00:07:32,490 --> 00:07:35,650
which typically are called NoSQL databases

163
00:07:35,650 --> 00:07:36,500
because there,

164
00:07:36,500 --> 00:07:38,640
you store your data differently.

165
00:07:38,640 --> 00:07:42,090
It's structured differently inside of the database

166
00:07:42,090 --> 00:07:46,520
and you don't use the SQL language for fetching your data

167
00:07:46,520 --> 00:07:48,070
or for writing your data,

168
00:07:48,070 --> 00:07:51,340
but instead, different query languages.

169
00:07:51,340 --> 00:07:53,970
And these are the two main kinds of systems.

170
00:07:53,970 --> 00:07:55,470
And in the next lectures,

171
00:07:55,470 --> 00:07:59,942
I'll walk you through the basics of these two systems,

172
00:07:59,942 --> 00:08:04,070
and I'll give you a first comparison of these two systems.

173
00:08:04,070 --> 00:08:05,560
In this course however,

174
00:08:05,560 --> 00:08:08,870
we'll then have entire sections for both systems

175
00:08:08,870 --> 00:08:12,280
so that you get a detailed introduction to both systems

176
00:08:12,280 --> 00:08:15,170
so that you can then also use either system

177
00:08:15,170 --> 00:08:17,253
for your upcoming websites.

