1
00:00:00,000 --> 00:00:00,000
Hello guys.

2
00:00:00,000 --> 00:00:04,000
So we are going to continue the discussion with respect to our graph database.

3
00:00:04,000 --> 00:00:09,000
Now we are going to see some more amazing examples which will be intermediate to advanced level.

4
00:00:09,000 --> 00:00:14,000
And we will try to see that how we can upload this particular data in the graph database itself.

5
00:00:14,000 --> 00:00:14,000
Right.

6
00:00:14,000 --> 00:00:19,000
So uh, here you will be able to see that I've created a GitHub link where I have uploaded some of the

7
00:00:19,000 --> 00:00:25,000
database like uh, data sets, like movies, dot CSV posts, dot CSV ratings, dot CSV.

8
00:00:25,000 --> 00:00:31,000
And then we will take all the CSV file and we'll try to upload this particular data set inside this

9
00:00:31,000 --> 00:00:32,000
graph database itself.

10
00:00:32,000 --> 00:00:34,000
So for that what kind of queries will be required.

11
00:00:34,000 --> 00:00:36,000
All those things we will be discussing.

12
00:00:36,000 --> 00:00:43,000
So the kind of use case that I'm actually going to show you, it is something related to social media

13
00:00:43,000 --> 00:00:43,000
platform.

14
00:00:43,000 --> 00:00:44,000
You know.

15
00:00:44,000 --> 00:00:47,000
So you know that you will be posting your post.

16
00:00:47,000 --> 00:00:48,000
There will be various users.

17
00:00:48,000 --> 00:00:54,000
And based on that, you may be liking a specific post, you know, and you may also have some of the

18
00:00:54,000 --> 00:00:56,000
friends in your social media platform.

19
00:00:57,000 --> 00:01:02,000
So considering this, you can see these are some of the important CSV files.

20
00:01:02,000 --> 00:01:05,000
So here is one user underscore social dot csv.

21
00:01:05,000 --> 00:01:08,000
So here you have user id name age and city.

22
00:01:08,000 --> 00:01:09,000
So these are all the details.

23
00:01:09,000 --> 00:01:11,000
And it is a comma separated file.

24
00:01:11,000 --> 00:01:17,000
Then uh you have this user ID user ID two type like uh 1 to 2.

25
00:01:17,000 --> 00:01:19,000
Uh, who all are friends, right.

26
00:01:19,000 --> 00:01:20,000
Based on the user ID.

27
00:01:20,000 --> 00:01:22,000
So here you can see if 1 to 2 friend is there.

28
00:01:22,000 --> 00:01:25,000
So John and Sarah is actually a friend.

29
00:01:25,000 --> 00:01:25,000
Right.

30
00:01:25,000 --> 00:01:29,000
And similarly 1 to 3 is a friend then 4 to 1.

31
00:01:29,000 --> 00:01:35,000
So fourth ID is basically liking the post of the first ID uh, in terms of the user.

32
00:01:35,000 --> 00:01:35,000
Right.

33
00:01:35,000 --> 00:01:37,000
So all these information is there.

34
00:01:37,000 --> 00:01:41,000
Other than that, you also have some post ID content, user ID and time stamp.

35
00:01:41,000 --> 00:01:43,000
So there is also a post dot csv file.

36
00:01:44,000 --> 00:01:49,000
Here you have posted something with respect to the time stamp and you have all the information.

37
00:01:49,000 --> 00:01:50,000
Now what we are going to do.

38
00:01:50,000 --> 00:01:56,000
First of all, we will insert all the specific data, uh, inside my graph database.

39
00:01:56,000 --> 00:01:57,000
So how do we insert a data.

40
00:01:57,000 --> 00:02:03,000
So for this we will be using a inbuilt function which is called as load CSV.

41
00:02:03,000 --> 00:02:03,000
Right.

42
00:02:03,000 --> 00:02:06,000
So here I'll say load CSV with headers.

43
00:02:06,000 --> 00:02:07,000
Okay.

44
00:02:07,000 --> 00:02:11,000
So I'll say hey with headers we are going to load all the CSV file.

45
00:02:11,000 --> 00:02:15,000
Then uh it will ask me where the CSV file is available.

46
00:02:15,000 --> 00:02:16,000
Right.

47
00:02:16,000 --> 00:02:19,000
So uh right now I have used this.

48
00:02:19,000 --> 00:02:22,000
So here you'll be able to see that I will be copying this entire link.

49
00:02:22,000 --> 00:02:24,000
I'll be pasting it over here okay.

50
00:02:24,000 --> 00:02:28,000
So this will be the link, uh, where my CSV file is present.

51
00:02:28,000 --> 00:02:33,000
So I will just go ahead and create as a temporary variable called as row.

52
00:02:33,000 --> 00:02:34,000
Okay.

53
00:02:34,000 --> 00:02:37,000
This row will be making sure that it will have all rows.

54
00:02:37,000 --> 00:02:41,000
It will basically iterate to all the records that are available inside the CSV file.

55
00:02:41,000 --> 00:02:42,000
Okay.

56
00:02:42,000 --> 00:02:47,000
Then we'll go to the next line and then we will go ahead and create all these users.

57
00:02:47,000 --> 00:02:47,000
Okay.

58
00:02:48,000 --> 00:02:51,000
Now here what exactly we have specifically done.

59
00:02:51,000 --> 00:02:54,000
It's just like you are loading this entire CSV file.

60
00:02:54,000 --> 00:02:57,000
You are running a for loop on each and every records.

61
00:02:57,000 --> 00:03:00,000
Okay, so I hope this is very much visible.

62
00:03:00,000 --> 00:03:03,000
Okay, so I'll be just writing it in this way.

63
00:03:03,000 --> 00:03:10,000
Now what I will do, I will go ahead and say for every row let's create a user okay I know so there

64
00:03:10,000 --> 00:03:12,000
is a specific user over here.

65
00:03:12,000 --> 00:03:17,000
And if you probably click this user, there are some of the users that you will be able to see.

66
00:03:17,000 --> 00:03:18,000
Okay.

67
00:03:18,000 --> 00:03:21,000
And uh, let me just zoom out, okay.

68
00:03:21,000 --> 00:03:24,000
And right now the user is just in this ID format.

69
00:03:24,000 --> 00:03:25,000
Okay.

70
00:03:25,000 --> 00:03:27,000
So it was the previous data itself.

71
00:03:27,000 --> 00:03:32,000
Uh, so what I will do is that I will just delete this user, okay.

72
00:03:32,000 --> 00:03:38,000
In order to delete it, you just need to instead of writing return and I will go ahead and delete it.

73
00:03:38,000 --> 00:03:39,000
Delete n okay.

74
00:03:39,000 --> 00:03:46,000
So just by using this delete n and no need to write limit 25, you'll be able to delete the entire node.

75
00:03:46,000 --> 00:03:48,000
So once I execute it here you can see deleted five nodes.

76
00:03:48,000 --> 00:03:52,000
Now you can't you can't see any users over here as the nodes.

77
00:03:52,000 --> 00:03:53,000
Right.

78
00:03:53,000 --> 00:03:55,000
So uh, try to do it in that way.

79
00:03:55,000 --> 00:03:57,000
Now I will go ahead and create my user.

80
00:03:57,000 --> 00:03:58,000
Okay.

81
00:03:59,000 --> 00:04:05,000
Now when we are creating this specific user here, I will also go ahead and specify my user ID.

82
00:04:05,000 --> 00:04:08,000
So let's go ahead and specify my user ID.

83
00:04:08,000 --> 00:04:12,000
This user id will basically be my properties right here.

84
00:04:12,000 --> 00:04:14,000
I will be using two integer.

85
00:04:14,000 --> 00:04:15,000
Now see this.

86
00:04:15,000 --> 00:04:19,000
Once we use two integer, that basically means what we are doing for every row.

87
00:04:19,000 --> 00:04:21,000
Whatever will be the ID over there, right?

88
00:04:21,000 --> 00:04:23,000
So right now this is the user ID right?

89
00:04:23,000 --> 00:04:26,000
By default when we read it this will be in string.

90
00:04:26,000 --> 00:04:28,000
But we will try to convert this into an integer.

91
00:04:28,000 --> 00:04:34,000
So here I'm going to write row dot user id okay.

92
00:04:34,000 --> 00:04:36,000
So row dot user id will be the thing.

93
00:04:37,000 --> 00:04:43,000
Then after that let's go ahead and create my name row like a name property.

94
00:04:43,000 --> 00:04:46,000
So it will be again row dot name okay.

95
00:04:46,000 --> 00:04:51,000
And finally you have this age which will be again two integer.

96
00:04:51,000 --> 00:04:54,000
We will use two integer to float whatever numbers you want.

97
00:04:54,000 --> 00:04:57,000
And here I'm going to basically write row dot age.

98
00:04:57,000 --> 00:05:02,000
So this way we are actually going to create all our properties right.

99
00:05:02,000 --> 00:05:06,000
And finally after this we will also create one more.

100
00:05:06,000 --> 00:05:09,000
That is nothing but city Rho dot city.

101
00:05:09,000 --> 00:05:10,000
Okay.

102
00:05:10,000 --> 00:05:16,000
So I hope uh, every user should be getting created directly from the CSV file.

103
00:05:16,000 --> 00:05:17,000
Okay.

104
00:05:17,000 --> 00:05:20,000
so now what I'm going to do I'll close this.

105
00:05:20,000 --> 00:05:24,000
And now let's execute it and let's see whether everything is working fine or not.

106
00:05:24,000 --> 00:05:26,000
So here you can see hey amazing.

107
00:05:26,000 --> 00:05:30,000
It has created five nodes 20 properties and added five labels right now.

108
00:05:30,000 --> 00:05:32,000
Uh, obviously the label is nothing but user.

109
00:05:32,000 --> 00:05:40,000
And here are all your you have all the element, all the people name like Sarah, John, Mike.

110
00:05:40,000 --> 00:05:40,000
Right.

111
00:05:40,000 --> 00:05:42,000
David and Linda.

112
00:05:42,000 --> 00:05:42,000
Right.

113
00:05:42,000 --> 00:05:45,000
So all this information is specifically there.

114
00:05:45,000 --> 00:05:45,000
Perfect.

115
00:05:45,000 --> 00:05:53,000
So these are the people who are specifically using the social media platform over here right now.

116
00:05:53,000 --> 00:05:54,000
Coming to the next one.

117
00:05:54,000 --> 00:05:57,000
For the next one, I will just go back to my post dot CSV.

118
00:05:57,000 --> 00:06:01,000
And these are the information that are posted with respect to the post ID.

119
00:06:01,000 --> 00:06:05,000
And here you can see mapping is also there with respect to the user ID okay.

120
00:06:05,000 --> 00:06:05,000
Okay.

121
00:06:05,000 --> 00:06:08,000
So let's go ahead and upload this specific file.

122
00:06:08,000 --> 00:06:13,000
Now what you do is that just pause the video and just try to see that how you will be able to load this

123
00:06:13,000 --> 00:06:14,000
particular file.

124
00:06:14,000 --> 00:06:15,000
Okay.

125
00:06:15,000 --> 00:06:18,000
Now I'm going to probably write down the query over here.

126
00:06:18,000 --> 00:06:24,000
So here I'm going to say load CSV with headers okay.

127
00:06:24,000 --> 00:06:29,000
Then I'm going to use from and let me just go ahead and use my URL.

128
00:06:30,000 --> 00:06:30,000
Okay.

129
00:06:31,000 --> 00:06:32,000
And here is the URL.

130
00:06:32,000 --> 00:06:35,000
Please try to understand the syntax okay.

131
00:06:35,000 --> 00:06:37,000
So the syntax is very much simple.

132
00:06:37,000 --> 00:06:42,000
We are just using load CSV with headers from this particular URL.

133
00:06:42,000 --> 00:06:45,000
And here also I will just go ahead and use Azure.

134
00:06:45,000 --> 00:06:46,000
Okay.

135
00:06:46,000 --> 00:06:52,000
And uh with respect to the Azure or what we are going to do is that we are going to write this in my

136
00:06:52,000 --> 00:06:55,000
next query, I will say, hey, go ahead and do the matching.

137
00:06:55,000 --> 00:07:02,000
And this time when you are doing the matching, please, first of all, let's go ahead and match the

138
00:07:02,000 --> 00:07:02,000
user.

139
00:07:02,000 --> 00:07:08,000
So I will write you colon user okay u colon user.

140
00:07:08,000 --> 00:07:14,000
And again I will go ahead and say, hey, use this user ID whichever property we have actually created,

141
00:07:14,000 --> 00:07:20,000
let me make some space over here so that it looks good and I'll say, hey, the user ID will try to

142
00:07:20,000 --> 00:07:23,000
convert this into integer, okay.

143
00:07:23,000 --> 00:07:28,000
And then we'll say row dot user id you'll understand what we are exactly doing.

144
00:07:28,000 --> 00:07:36,000
We are matching all the users based on the user ID which we are retrieving it from row dot user id okay,

145
00:07:36,000 --> 00:07:41,000
after doing this particular match, what we have to do is that we have to create a relation.

146
00:07:41,000 --> 00:07:43,000
Now let's go ahead and create this.

147
00:07:43,000 --> 00:07:49,000
I will say, hey, create this user and create a relation, something like Dash.

148
00:07:49,000 --> 00:07:54,000
And let's keep that relation as something like posted okay.

149
00:07:54,000 --> 00:07:57,000
So here I'm going to create my relation as posted.

150
00:07:57,000 --> 00:08:04,000
And this posted should have a relation with what with obviously post.

151
00:08:04,000 --> 00:08:08,000
So this will basically be my label right with post.

152
00:08:08,000 --> 00:08:11,000
Oh let me just go ahead and write posts right.

153
00:08:11,000 --> 00:08:16,000
And here we are going to use some properties like post ID okay.

154
00:08:16,000 --> 00:08:18,000
What will be the post ID that I have.

155
00:08:19,000 --> 00:08:23,000
ID okay it will be again two integer.

156
00:08:23,000 --> 00:08:31,000
And here I'm going to use row dot post id because from this row I will be able to access all the post

157
00:08:31,000 --> 00:08:35,000
id, so I will just go ahead and write row dot post id right?

158
00:08:35,000 --> 00:08:38,000
So let's see what are the post IDs there.

159
00:08:38,000 --> 00:08:39,000
So I will copy this over here.

160
00:08:40,000 --> 00:08:41,000
All right.

161
00:08:41,000 --> 00:08:42,000
Perfect.

162
00:08:42,000 --> 00:08:46,000
Similarly uh the next field that I have is nothing but content.

163
00:08:46,000 --> 00:08:47,000
So I'll go ahead and write.

164
00:08:47,000 --> 00:08:52,000
Content is equal to row dot content.

165
00:08:52,000 --> 00:08:53,000
Right.

166
00:08:53,000 --> 00:08:56,000
Because that is my sorry row dot content not raw.

167
00:08:58,000 --> 00:09:00,000
Row dot content.

168
00:09:00,000 --> 00:09:00,000
Right.

169
00:09:00,000 --> 00:09:02,000
So this is what is my content is there.

170
00:09:02,000 --> 00:09:05,000
Then I have my user ID okay.

171
00:09:05,000 --> 00:09:08,000
So let's go ahead and write the user ID.

172
00:09:08,000 --> 00:09:11,000
But the user id we have already done the mapping.

173
00:09:11,000 --> 00:09:14,000
So I will just go ahead and put the timestamp right.

174
00:09:14,000 --> 00:09:19,000
So here the next thing that I'm actually going to use is time stamp.

175
00:09:19,000 --> 00:09:23,000
Now inside this time stamp I'll use date time.

176
00:09:23,000 --> 00:09:23,000
Right.

177
00:09:23,000 --> 00:09:25,000
So date time is obviously there.

178
00:09:25,000 --> 00:09:29,000
See over here itself because we need to convert that into date time.

179
00:09:29,000 --> 00:09:32,000
So here I have a namespace called as date time.

180
00:09:33,000 --> 00:09:38,000
And here we are going to just go ahead and write row dot time stamp.

181
00:09:40,000 --> 00:09:40,000
Perfect.

182
00:09:41,000 --> 00:09:43,000
And then we will close this entire query.

183
00:09:44,000 --> 00:09:45,000
Step by step.

184
00:09:45,000 --> 00:09:50,000
See here we are matching with respect to user ID and the row user id right.

185
00:09:50,000 --> 00:09:52,000
So user id this two rows user id.

186
00:09:52,000 --> 00:09:54,000
So then mapping has specifically done.

187
00:09:54,000 --> 00:09:57,000
And we are creating a relationship called as posted.

188
00:09:57,000 --> 00:10:01,000
So once I execute this here you can see five nodes is specifically there.

189
00:10:01,000 --> 00:10:02,000
And if I click on post amazing.

190
00:10:02,000 --> 00:10:06,000
See all the posts are there.

191
00:10:06,000 --> 00:10:06,000
Right.

192
00:10:06,000 --> 00:10:10,000
So this is my uh ID also it is mapped right?

193
00:10:10,000 --> 00:10:12,000
My first post my timestamp.

194
00:10:12,000 --> 00:10:17,000
So Mike has posted this third and Linda has posted this other post.

195
00:10:17,000 --> 00:10:19,000
David has posted this right.

196
00:10:19,000 --> 00:10:23,000
All this information is John has posted this right.

197
00:10:23,000 --> 00:10:25,000
So this posting has been done.

198
00:10:25,000 --> 00:10:31,000
And here we can just go ahead and check match P is equal to some blank space Like give nothing over

199
00:10:31,000 --> 00:10:35,000
here and try to see like where is this specific relation.

200
00:10:35,000 --> 00:10:37,000
Once I click on this posted you are able to see this.

201
00:10:37,000 --> 00:10:41,000
Okay now let's do one more thing.

202
00:10:41,000 --> 00:10:44,000
There is also one called as relation dot csv.

203
00:10:44,000 --> 00:10:44,000
Right?

204
00:10:44,000 --> 00:10:47,000
We need to understand who are whose friends right.

205
00:10:47,000 --> 00:10:51,000
So for this we need to load this entire relationship dot dot csv file.

206
00:10:52,000 --> 00:10:54,000
Again let's go ahead and write it down.

207
00:10:54,000 --> 00:10:58,000
So I'll write load underscore CSV with headers.

208
00:10:58,000 --> 00:10:58,000
Okay.

209
00:10:58,000 --> 00:11:01,000
From my file name.

210
00:11:01,000 --> 00:11:02,000
File name is nothing.

211
00:11:02,000 --> 00:11:04,000
But where is my relationship file.

212
00:11:04,000 --> 00:11:06,000
So it is present in this GitHub location.

213
00:11:06,000 --> 00:11:12,000
And here also I will just go ahead and create a temporary row and let's press enter okay.

214
00:11:13,000 --> 00:11:16,000
Now this is just a simple match query.

215
00:11:16,000 --> 00:11:23,000
First of all we need to match with the user ID with row is your ID then YouTube user with a user id

216
00:11:23,000 --> 00:11:23,000
two.

217
00:11:23,000 --> 00:11:25,000
See there are two users ID right over here.

218
00:11:26,000 --> 00:11:27,000
See this user id one.

219
00:11:27,000 --> 00:11:28,000
User id two.

220
00:11:29,000 --> 00:11:31,000
User id one to user id two.

221
00:11:31,000 --> 00:11:32,000
What type the friends are.

222
00:11:32,000 --> 00:11:33,000
Right.

223
00:11:33,000 --> 00:11:35,000
So this is the kind of mapping that you will be able to see.

224
00:11:35,000 --> 00:11:37,000
So that is the reason we made two mappings.

225
00:11:37,000 --> 00:11:43,000
One is UU1 with user id, one uh user id and then YouTube u2 with user id where we are mapping user

226
00:11:43,000 --> 00:11:48,000
id to user id two, and then we are mapping this user id to user id one.

227
00:11:48,000 --> 00:11:48,000
Okay.

228
00:11:48,000 --> 00:11:55,000
Then we are creating this called as create U1 friends friends relationship likes relationship with U1

229
00:11:55,000 --> 00:11:56,000
to U2.

230
00:11:56,000 --> 00:11:58,000
Okay, so just go ahead and explore this.

231
00:11:58,000 --> 00:12:03,000
You will get a complete idea what exactly we have done over here.

232
00:12:03,000 --> 00:12:08,000
So once I execute this So created 22 relationships.

233
00:12:08,000 --> 00:12:09,000
This is amazing.

234
00:12:09,000 --> 00:12:10,000
Right?

235
00:12:10,000 --> 00:12:12,000
So, uh, if you go ahead and see.

236
00:12:12,000 --> 00:12:14,000
Friends see nicely.

237
00:12:14,000 --> 00:12:16,000
All the graph is basically coming.

238
00:12:16,000 --> 00:12:18,000
Sarah is a friend of Mike.

239
00:12:18,000 --> 00:12:19,000
John is a.

240
00:12:19,000 --> 00:12:20,000
Friend of Mike.

241
00:12:20,000 --> 00:12:21,000
Then.

242
00:12:21,000 --> 00:12:25,000
And remember this user ID and user one uh, user ID is basically getting mapped.

243
00:12:25,000 --> 00:12:26,000
Right 1 to 2.

244
00:12:26,000 --> 00:12:30,000
Right 1 to 2 basically means one is the friend of two.

245
00:12:30,000 --> 00:12:32,000
So one is John is friend of Sarah.

246
00:12:32,000 --> 00:12:36,000
So if you go ahead and see John is a friend of Sarah, then Sarah is a friend of Mike.

247
00:12:36,000 --> 00:12:40,000
This entire friend circle is basically getting created perfect.

248
00:12:41,000 --> 00:12:48,000
So, uh, I hope you have understood of probably creating all the tables and how you can basically define

249
00:12:48,000 --> 00:12:50,000
all the relationships.

250
00:12:50,000 --> 00:12:54,000
Now it's time we start retrieving like start.

251
00:12:54,000 --> 00:12:56,000
Let's start from some basic queries.

252
00:12:56,000 --> 00:12:58,000
We will go ahead and retrieve all users.

253
00:12:58,000 --> 00:13:01,000
So for this I'm going to write my match keyword.

254
00:13:01,000 --> 00:13:05,000
Let me go ahead and write you colon user okay.

255
00:13:05,000 --> 00:13:06,000
This will basically be user.

256
00:13:06,000 --> 00:13:10,000
And let's return return you okay.

257
00:13:10,000 --> 00:13:16,000
So once I execute this here you will be able to see that I'm able to get all the users over here Sara,

258
00:13:16,000 --> 00:13:18,000
John, David Linda and Mike.

259
00:13:18,000 --> 00:13:19,000
Okay.

260
00:13:19,000 --> 00:13:24,000
Now the next one, what I will do is that I will retrieve all the post.

261
00:13:24,000 --> 00:13:27,000
Okay, so here again we will use a match query.

262
00:13:28,000 --> 00:13:32,000
Let me go ahead and write P colon post post okay.

263
00:13:32,000 --> 00:13:36,000
And here we are going to return P okay.

264
00:13:36,000 --> 00:13:39,000
Sorry we have to use this capital letter.

265
00:13:39,000 --> 00:13:41,000
It's good return p.

266
00:13:41,000 --> 00:13:41,000
P.

267
00:13:41,000 --> 00:13:44,000
So I'm just trying to check which all posts are there.

268
00:13:44,000 --> 00:13:46,000
So so many different posts are there.

269
00:13:46,000 --> 00:13:47,000
Love New York beautiful.

270
00:13:47,000 --> 00:13:52,000
And this is basically given with the help of this post ID okay, perfect.

271
00:13:52,000 --> 00:13:56,000
Now let's retrieve a friend of a specific user.

272
00:13:56,000 --> 00:13:56,000
Okay.

273
00:13:56,000 --> 00:13:59,000
If I say hey for this user John who is the friend.

274
00:13:59,000 --> 00:14:03,000
So here what I'm actually going to do again, I'll go ahead and write my match query.

275
00:14:03,000 --> 00:14:08,000
And with respect to this match query again I will go and write u is equal to u colon user.

276
00:14:08,000 --> 00:14:09,000
Okay.

277
00:14:09,000 --> 00:14:14,000
And then I will go ahead and use the property name colon name colon.

278
00:14:14,000 --> 00:14:16,000
Nothing but John.

279
00:14:16,000 --> 00:14:16,000
Okay.

280
00:14:16,000 --> 00:14:20,000
So once I do this and now I need to probably create that relation.

281
00:14:20,000 --> 00:14:23,000
The relation is very simple friend.

282
00:14:23,000 --> 00:14:23,000
Right.

283
00:14:23,000 --> 00:14:27,000
So I will use this I will write colon friend okay.

284
00:14:27,000 --> 00:14:33,000
And then I will say hey give me f user.

285
00:14:33,000 --> 00:14:33,000
Okay.

286
00:14:33,000 --> 00:14:35,000
I'm just creating this another label.

287
00:14:36,000 --> 00:14:39,000
So here let me go ahead and write F user.

288
00:14:39,000 --> 00:14:40,000
This will be another label.

289
00:14:40,000 --> 00:14:43,000
This will be another label to distinguish between them.

290
00:14:43,000 --> 00:14:43,000
Right.

291
00:14:43,000 --> 00:14:47,000
And then we are just going to return f dot name.

292
00:14:48,000 --> 00:14:55,000
So once I do this you will be able to see that you'll be getting all the f uh f dot names over here.

293
00:14:55,000 --> 00:15:00,000
So David, Sara, Mike, Linda are the friends of John.

294
00:15:00,000 --> 00:15:04,000
And if you don't believe me, see David, Sara, Mike and Linda.

295
00:15:04,000 --> 00:15:07,000
So if I go and click on friend David.

296
00:15:08,000 --> 00:15:09,000
Uh, David is the friend.

297
00:15:09,000 --> 00:15:10,000
Sara is the friend.

298
00:15:10,000 --> 00:15:12,000
Mike is the friend.

299
00:15:12,000 --> 00:15:12,000
Right?

300
00:15:12,000 --> 00:15:13,000
And Linda is also a friend.

301
00:15:13,000 --> 00:15:14,000
Right.

302
00:15:14,000 --> 00:15:19,000
All this information is basically getting extracted and that is how you are able to see to it right

303
00:15:19,000 --> 00:15:20,000
now.

304
00:15:20,000 --> 00:15:27,000
Uh, let's go ahead and see how many, uh, let's see the post made by the friends of a specific user.

305
00:15:27,000 --> 00:15:27,000
Okay.

306
00:15:28,000 --> 00:15:31,000
So here you will be able to see that I will go ahead and write my match query.

307
00:15:31,000 --> 00:15:33,000
I will say, hey, let's go ahead and create this.

308
00:15:33,000 --> 00:15:35,000
You label user.

309
00:15:36,000 --> 00:15:37,000
Uh, sorry user is my label.

310
00:15:37,000 --> 00:15:41,000
And then I am just going to write you is just a node okay.

311
00:15:41,000 --> 00:15:44,000
Name with respect to John.

312
00:15:44,000 --> 00:15:44,000
Okay.

313
00:15:45,000 --> 00:15:49,000
Now we know that John, first of all we need to retrieve all the friends right.

314
00:15:49,000 --> 00:15:51,000
So I will go ahead and write friend okay.

315
00:15:51,000 --> 00:15:56,000
And then I will create another label F colon user okay.

316
00:15:57,000 --> 00:16:00,000
And I'll say hey let's go ahead with posted.

317
00:16:00,000 --> 00:16:01,000
Right.

318
00:16:01,000 --> 00:16:02,000
So here I'm going to write.

319
00:16:03,000 --> 00:16:11,000
It's just a posted one Okay, I now see there will be a little bit of confusion with respect to the

320
00:16:11,000 --> 00:16:14,000
queries, but you need to practice these things, right?

321
00:16:14,000 --> 00:16:19,000
But this is very simple when compared to MySQL I feel still this is very very comfortable.

322
00:16:19,000 --> 00:16:20,000
Very very much easy.

323
00:16:20,000 --> 00:16:21,000
Yeah.

324
00:16:21,000 --> 00:16:25,000
Then you can go ahead and write p colon post.

325
00:16:25,000 --> 00:16:25,000
Right.

326
00:16:25,000 --> 00:16:27,000
So here what we are doing.

327
00:16:27,000 --> 00:16:33,000
We are basically matching first of all user name who is a friend of the other user like of the same

328
00:16:33,000 --> 00:16:38,000
user with respect to comparing with all the other users, then we are basically considering whether

329
00:16:38,000 --> 00:16:40,000
they have actually posted, right?

330
00:16:40,000 --> 00:16:43,000
So posted is one of the relationship with respect to P is equal to post.

331
00:16:43,000 --> 00:16:44,000
Okay.

332
00:16:44,000 --> 00:16:52,000
And here I will just go ahead and write return f dot name and p dot content is just like inner queries

333
00:16:52,000 --> 00:16:52,000
right.

334
00:16:52,000 --> 00:16:59,000
So now if I just go ahead and execute this, you'll be able to see David has posted San Francisco is

335
00:16:59,000 --> 00:17:00,000
amazing.

336
00:17:00,000 --> 00:17:02,000
Sarah has posted my first post.

337
00:17:02,000 --> 00:17:04,000
Mike has posted beautiful day in Chicago.

338
00:17:04,000 --> 00:17:10,000
Linda love New York and all right, um, this is, uh, how you can basically do this.

339
00:17:10,000 --> 00:17:15,000
But again, here the main aim is not to become pro in Cypher Query language.

340
00:17:15,000 --> 00:17:21,000
This is just for your purpose to show you because later on we will be when we implementing or when we

341
00:17:21,000 --> 00:17:27,000
are creating our generative AI applications with the help of Lang Chain right there, we will be using

342
00:17:27,000 --> 00:17:28,000
all this kind of queries.

343
00:17:28,000 --> 00:17:31,000
Some of the queries will be using in order to insert the data and all.

344
00:17:31,000 --> 00:17:39,000
So guys now let's go ahead and see one more example where we are going to find users who likes a specific

345
00:17:39,000 --> 00:17:40,000
user post.

346
00:17:40,000 --> 00:17:44,000
So here you will be able to see uh with respect to the post, right?

347
00:17:44,000 --> 00:17:46,000
How many people have liked it.

348
00:17:46,000 --> 00:17:46,000
Right.

349
00:17:46,000 --> 00:17:48,000
4 to 1, 4 to 5, 1 to 5 like that.

350
00:17:48,000 --> 00:17:49,000
Right.

351
00:17:49,000 --> 00:17:52,000
So we will try to create another relationship with respect to that.

352
00:17:52,000 --> 00:17:53,000
Right.

353
00:17:53,000 --> 00:17:58,000
So uh, let's go over here and let's see how to probably write this.

354
00:17:58,000 --> 00:18:05,000
So here I'm going to write a match keyword again u colon user okay.

355
00:18:05,000 --> 00:18:09,000
And uh, let's say the user name is John.

356
00:18:09,000 --> 00:18:11,000
So I will just go ahead and write John okay.

357
00:18:12,000 --> 00:18:17,000
And here we will go ahead and write colon posted.

358
00:18:17,000 --> 00:18:18,000
Oops.

359
00:18:19,000 --> 00:18:21,000
Colon posted relation okay.

360
00:18:22,000 --> 00:18:31,000
Um then this will be mapped to p colon post P colon push.

361
00:18:31,000 --> 00:18:36,000
And with respect to this I will also go ahead and specify my likes.

362
00:18:36,000 --> 00:18:40,000
So let's go ahead and see with respect to likes okay.

363
00:18:40,000 --> 00:18:46,000
Because we are comparing inside this p post itself we have this specific likes okay.

364
00:18:46,000 --> 00:18:51,000
Uh see when you give this kind of direction that basically means we are just trying to find out the

365
00:18:51,000 --> 00:18:57,000
relationship we are traversing the relationship between this user and post and inside this post, you

366
00:18:57,000 --> 00:19:00,000
know that, uh, there are something called as likes, right?

367
00:19:00,000 --> 00:19:06,000
So we are just going to use a reverse direction right where we are saying this as likes.

368
00:19:06,000 --> 00:19:09,000
And this is another relationship that we are trying to create.

369
00:19:09,000 --> 00:19:10,000
Okay.

370
00:19:10,000 --> 00:19:16,000
And this likes will be with respect to another user, another user.

371
00:19:16,000 --> 00:19:19,000
Uh uh, I can just consider another user label.

372
00:19:19,000 --> 00:19:20,000
Right.

373
00:19:20,000 --> 00:19:23,000
And then we will go ahead and return L dot name.

374
00:19:24,000 --> 00:19:27,000
Along with this we will also return p dot content.

375
00:19:28,000 --> 00:19:31,000
So this way you will be able to see everything as such.

376
00:19:31,000 --> 00:19:32,000
Let's execute this.

377
00:19:32,000 --> 00:19:36,000
So it says uh no changes, no records.

378
00:19:36,000 --> 00:19:37,000
No records has been found.

379
00:19:38,000 --> 00:19:40,000
Um, let's again see this.

380
00:19:40,000 --> 00:19:43,000
Uh, you can see user with respect to name is equal to John.

381
00:19:43,000 --> 00:19:44,000
Okay.

382
00:19:44,000 --> 00:19:50,000
And whatever John has specifically posted with respect to that particular post and likes has been compared

383
00:19:50,000 --> 00:19:52,000
with L dot user over here.

384
00:19:52,000 --> 00:19:54,000
And then we are returning L dot name.

385
00:19:54,000 --> 00:19:58,000
So right now no match is specifically happening.

386
00:19:58,000 --> 00:20:04,000
Um, so with respect to any John post, uh, I think this is there.

387
00:20:04,000 --> 00:20:07,000
Let's verify the ID itself.

388
00:20:07,000 --> 00:20:07,000
Okay?

389
00:20:07,000 --> 00:20:11,000
So I will just, uh, make sure to copy the same thing.

390
00:20:11,000 --> 00:20:13,000
Let's execute it.

391
00:20:13,000 --> 00:20:17,000
So it says John posted p post.

392
00:20:17,000 --> 00:20:25,000
So, uh, John is over here with respect to John one comma, user id comma user id one, comma user

393
00:20:25,000 --> 00:20:27,000
id two right.

394
00:20:27,000 --> 00:20:28,000
With respect to likes.

395
00:20:29,000 --> 00:20:33,000
So I think there will be no record that is specifically matching.

396
00:20:33,000 --> 00:20:35,000
Okay, let's try one more query over here.

397
00:20:35,000 --> 00:20:39,000
Let's count the number of friends each user has.

398
00:20:39,000 --> 00:20:45,000
And now I'm going to use this specific query I'm writing match u colon user with respect to friend f

399
00:20:45,000 --> 00:20:45,000
colon user.

400
00:20:45,000 --> 00:20:51,000
Again F is another label uh another node written u dot name count f as number of friends.

401
00:20:51,000 --> 00:20:55,000
See all the inbuilt function like how we use in uh, MySQL and all.

402
00:20:55,000 --> 00:20:56,000
Similarly, we are able to do this.

403
00:20:56,000 --> 00:20:58,000
So order by number of friends describing.

404
00:20:58,000 --> 00:21:01,000
So it will just show you that David has five friends.

405
00:21:01,000 --> 00:21:05,000
Sarah has five friends, John has four friends, Mike has four friends, and Linda has four friends.

406
00:21:05,000 --> 00:21:06,000
Right.

407
00:21:07,000 --> 00:21:11,000
Um, these are some of the good examples that I've actually shown you guys.

408
00:21:11,000 --> 00:21:15,000
Uh, but again, it is up to you to go ahead and try it out again here.

409
00:21:15,000 --> 00:21:22,000
The main intention of creating this module is not to become perfectionist in a cypher query languages,

410
00:21:22,000 --> 00:21:27,000
because obviously there are different different scenarios, but you can see just the power of this,

411
00:21:27,000 --> 00:21:27,000
right?

412
00:21:28,000 --> 00:21:33,000
Our main aim of understanding this was that we should be able to work with long chain whenever we are

413
00:21:33,000 --> 00:21:35,000
creating a generative AI application.

414
00:21:35,000 --> 00:21:38,000
So yes, uh, this was it from my side.

415
00:21:38,000 --> 00:21:40,000
I hope you liked this particular video.

416
00:21:40,000 --> 00:21:43,000
I will be see you all in the next video.

417
00:21:43,000 --> 00:21:43,000
Thank you.

418
00:21:43,000 --> 00:21:44,000
Take care.

