1
00:00:02,110 --> 00:00:05,689
Now that's it for this course section.

2
00:00:05,689 --> 00:00:06,910
In this course section,

3
00:00:06,910 --> 00:00:10,450
you got a thorough introduction into SQL

4
00:00:10,450 --> 00:00:13,470
and the kind of databases that use that language.

5
00:00:13,470 --> 00:00:15,690
Most importantly, MySQL,

6
00:00:15,690 --> 00:00:18,223
which we installed and started working with.

7
00:00:19,210 --> 00:00:20,530
Though, I want to mention again,

8
00:00:20,530 --> 00:00:23,450
that what you learned about the SQL Syntax in this

9
00:00:23,450 --> 00:00:27,390
section here, will apply to all the SQL databases

10
00:00:27,390 --> 00:00:28,770
you might be using.

11
00:00:28,770 --> 00:00:33,200
It's a very popular and common database system,

12
00:00:33,200 --> 00:00:36,160
and therefore definitely a system or a language,

13
00:00:36,160 --> 00:00:39,210
you have to know when being a Web Developer.

14
00:00:39,210 --> 00:00:42,730
You'll learn that when you work with a relational database

15
00:00:42,730 --> 00:00:46,550
management system, as we did it here in this course section,

16
00:00:46,550 --> 00:00:50,590
that it's all about working with different tables.

17
00:00:50,590 --> 00:00:54,060
Storing your data in a normalized form,

18
00:00:54,060 --> 00:00:57,820
which means in a simplified form, where you have no complex

19
00:00:57,820 --> 00:01:01,290
data in a single table across multiple tables,

20
00:01:01,290 --> 00:01:06,290
linked together through IDs or other unique identifiers,

21
00:01:06,570 --> 00:01:08,973
as we did it in this course section.

22
00:01:10,560 --> 00:01:13,490
And you then learn how you can run commands to create

23
00:01:13,490 --> 00:01:17,100
tables, to insert data into tables,

24
00:01:17,100 --> 00:01:21,120
to update or delete data, and of course, to query data.

25
00:01:21,120 --> 00:01:23,140
To query data just like that,

26
00:01:23,140 --> 00:01:26,890
or with constraints or counting the data that's

27
00:01:26,890 --> 00:01:28,313
in a database table.

28
00:01:29,420 --> 00:01:33,230
And then since we do work with multiple tables, of course,

29
00:01:33,230 --> 00:01:35,630
you also learned about the very important

30
00:01:35,630 --> 00:01:38,840
inner join statement, which allows you to

31
00:01:38,840 --> 00:01:42,880
merge data together in your result sets

32
00:01:42,880 --> 00:01:46,530
with which you then might be working in your applications.

33
00:01:46,530 --> 00:01:49,197
So that you can answer questions like,

34
00:01:49,197 --> 00:01:53,210
what's the name of the restaurant that has a rating of five?

35
00:01:53,210 --> 00:01:54,313
For example.

36
00:01:56,090 --> 00:01:59,300
Now coming back to these relationships.

37
00:01:59,300 --> 00:02:00,960
In this core section,

38
00:02:00,960 --> 00:02:04,180
we saw the one to many relationship and action,

39
00:02:04,180 --> 00:02:08,410
which means that one record in table A can be related to

40
00:02:08,410 --> 00:02:11,163
multiple records in table B.

41
00:02:11,163 --> 00:02:12,390
For example,

42
00:02:12,390 --> 00:02:15,260
that a single restaurant can have multiple reviews,

43
00:02:15,260 --> 00:02:18,253
but every review belongs to only one restaurant.

44
00:02:19,540 --> 00:02:22,910
There also are other kinds of relationships.

45
00:02:22,910 --> 00:02:26,300
For example, one-to-one relationships.

46
00:02:26,300 --> 00:02:28,490
There, you would have one record

47
00:02:28,490 --> 00:02:30,370
in table A that's related to

48
00:02:30,370 --> 00:02:33,080
exactly one other record in table B,

49
00:02:33,080 --> 00:02:36,000
and not more than one record.

50
00:02:36,000 --> 00:02:39,400
An example could be a team that has one team leader,

51
00:02:39,400 --> 00:02:43,900
and that team leader leads exactly one team and team leaders

52
00:02:43,900 --> 00:02:47,163
and team data is stored in different tables.

53
00:02:48,820 --> 00:02:50,010
And last but not least,

54
00:02:50,010 --> 00:02:53,310
you could also have many to many relationships,

55
00:02:53,310 --> 00:02:55,880
which is a bit more advanced and therefore was not

56
00:02:55,880 --> 00:02:58,810
covered here, but which you will always encounter,

57
00:02:58,810 --> 00:03:03,100
if you dive deeper into web development and take dedicated

58
00:03:03,100 --> 00:03:07,120
sequel courses or deep dive courses in general.

59
00:03:07,120 --> 00:03:11,070
The idea behind many to many relationships is that a record

60
00:03:11,070 --> 00:03:14,860
in table A can be related to multiple records in table B

61
00:03:14,860 --> 00:03:16,709
and vice versa.

62
00:03:16,709 --> 00:03:19,660
To handle this with a SQL database,

63
00:03:19,660 --> 00:03:21,850
you would have an intermediate table

64
00:03:21,850 --> 00:03:24,020
that stores the connections.

65
00:03:24,020 --> 00:03:25,390
And an example would be,

66
00:03:25,390 --> 00:03:27,410
a restaurant that has many customers

67
00:03:27,410 --> 00:03:31,120
and every customer might visit many restaurants.

68
00:03:31,120 --> 00:03:32,660
This is just a side note here.

69
00:03:32,660 --> 00:03:34,350
It's not too important.

70
00:03:34,350 --> 00:03:37,070
And we will come back to these relationships later

71
00:03:37,070 --> 00:03:39,730
in the course, once we do dive in deeper.

72
00:03:39,730 --> 00:03:43,940
And once we do build our online shop, for example.

73
00:03:43,940 --> 00:03:46,400
I just wanted to mention them here already,

74
00:03:46,400 --> 00:03:50,670
because of course a main feature off SQL databases of

75
00:03:50,670 --> 00:03:53,960
relational database management systems,

76
00:03:53,960 --> 00:03:56,090
as the name already implies, I guess,

77
00:03:56,090 --> 00:03:59,440
is that you do work with relationships and that you do

78
00:03:59,440 --> 00:04:01,863
relate data from different tables.

79
00:04:02,840 --> 00:04:05,890
And therefore now, with that in the next chord section,

80
00:04:05,890 --> 00:04:08,930
we're going to see how we can now actually use what we

81
00:04:08,930 --> 00:04:10,680
learned in this section,

82
00:04:10,680 --> 00:04:15,680
inside of a real application, inside of node JS code.

83
00:04:15,830 --> 00:04:18,910
So that we don't have to write all the queries here in the,

84
00:04:18,910 --> 00:04:22,380
MySQL workbench, which is nice for playing around,

85
00:04:22,380 --> 00:04:26,310
but which isn't a real application and that we instead see

86
00:04:26,310 --> 00:04:30,640
how we can actually do work with the database from inside

87
00:04:30,640 --> 00:04:32,293
our node JS code.

