1
00:00:07,270 --> 00:00:08,440
In this video.

2
00:00:08,440 --> 00:00:17,770
Let's talk about types of database relationship, which means that how we can relate to or more documents

3
00:00:17,770 --> 00:00:18,690
together.

4
00:00:18,700 --> 00:00:24,310
But before we get into that, let's go over what we call the planning stage.

5
00:00:24,310 --> 00:00:30,730
So as we discussed in the previous video, let's go over again because it's really important.

6
00:00:30,760 --> 00:00:36,850
Now, let's say that you got the idea about the entire application.

7
00:00:37,060 --> 00:00:43,840
So after you go the idea, the first step is what you name your database as we said.

8
00:00:43,840 --> 00:00:47,740
So in this case, let's say you are building a blog application.

9
00:00:47,740 --> 00:00:52,840
So here the name of a database is called What Blog Application?

10
00:00:52,960 --> 00:00:56,890
And for the blog application you may need a different collection.

11
00:00:56,890 --> 00:01:02,110
For example, you're going to have post collection and call this one as collection one.

12
00:01:02,110 --> 00:01:08,470
You need collection to core users and you need another collection called Comments.

13
00:01:08,500 --> 00:01:12,940
Now you can see that these collections are independent.

14
00:01:12,940 --> 00:01:14,590
They don't know each other.

15
00:01:14,650 --> 00:01:23,500
And let's say that if you want to know which post was made by a certain user and what comments was made

16
00:01:23,500 --> 00:01:27,340
by a user and what post has a specific comment.

17
00:01:27,340 --> 00:01:31,180
And this is what we call database relationship.

18
00:01:31,180 --> 00:01:37,510
So with that being said, let's have a look at types of database relationship.

19
00:01:37,540 --> 00:01:44,650
The first type of database relationship is what you call 1 to 1 relationship.

20
00:01:44,680 --> 00:01:45,790
What does it mean?

21
00:01:45,790 --> 00:01:53,410
Let's take it that we are building a blog application and we have three collections posts, users and

22
00:01:53,410 --> 00:01:54,280
comment.

23
00:01:54,280 --> 00:02:03,190
When we say 1 to 1, it simply means that one user can have one post or can create a post and a post

24
00:02:03,190 --> 00:02:12,520
belongs to a user, meaning one is to one, and for this kind of relationship is not mostly used.

25
00:02:12,610 --> 00:02:19,510
The next type of relationship is what you call one to many relationship.

26
00:02:19,720 --> 00:02:23,620
Again, let's take a block application into this context.

27
00:02:23,770 --> 00:02:33,310
It simply means that one user can have or create many posts, but a post belongs to a single user.

28
00:02:33,430 --> 00:02:34,420
That is it.

29
00:02:34,420 --> 00:02:41,200
And this kind of relationship is mostly used 100% in any application.

30
00:02:41,200 --> 00:02:48,850
I can tell you that there is at least one to many relationship, and the next type of relationship is

31
00:02:48,850 --> 00:02:52,210
what we call many to many relationships.

32
00:02:52,360 --> 00:02:53,860
Well, what does it mean?

33
00:02:53,860 --> 00:03:02,650
It simply means that one user can have many posts, but a post belongs to many users.

34
00:03:02,890 --> 00:03:11,020
Again, this kind of relationship is not mostly used and we use this kind of relationship mostly in

35
00:03:11,020 --> 00:03:12,880
e commerce application.

36
00:03:13,480 --> 00:03:21,340
We can have a product having many orders and the same orders can have many users.

37
00:03:21,490 --> 00:03:29,530
So let's say that we have a product called iPhone, that iPhone many users can order that particular

38
00:03:29,530 --> 00:03:36,160
product, meaning that that particular product can have many orders and that orders belongs to that

39
00:03:36,160 --> 00:03:37,390
particular product.

40
00:03:37,390 --> 00:03:44,350
And again, this kind of relationship is not that mostly used, but the one which is really important

41
00:03:44,350 --> 00:03:47,970
is what we call one to many relationship.

42
00:03:47,980 --> 00:03:51,970
And this is what I'm going to show you if I show you this one.

43
00:03:52,030 --> 00:03:54,850
Implementing these ones are easy.

44
00:03:54,850 --> 00:04:01,210
But like I said, you are going to work with what is called one to many relationships.

45
00:04:01,240 --> 00:04:02,110
All right.

46
00:04:02,110 --> 00:04:08,020
The next video, I will show you how we can relate document together.

47
00:04:08,020 --> 00:04:14,070
So we are in the process of what modeling data now we know ties of relationship.

48
00:04:14,080 --> 00:04:22,450
Now let's go ahead and talk about how we can relate to or more document together in the next video.

