So the purpose of MongoDB is that it is a database. There is SQL database, there is MongoDB database, which works with JSON. And of course, if
we're going to
have a database, we also need a database server. Now maybe in your SQL class you might have worked with database servers such as Oracle Jesus. That is so irritating. Sorry, guys. I don't know what to tell you. The guy was here. He promised he was going to replace the cable. I know the winking in and out is irritating. I don't really know what to do about it. Let's just ignore it. So anyway, well, also I'll kick out this link so you can also follow along. You can read along with what I'm saying here, so anybody with the link can view and I'll put that up on the top of your lab book, so you can get into it from there,
you so probably for your SQL course, you might have dealt with something like Microsoft SQL Server or maybe Oracle. Here our database is going to be Mongo. Mongo is a database. It lives as an npmjs.com package, so we're going to be installing it in our JavaScript program.
And you can also put a Mongo server on your own local hard drive, on your own operating system. However, we're going to be using a cloud based server, and in fact, maybe if I make a Lucid Chart, that'll because this is a bunch of new content, Maybe this will help everybody keep it mentally organized. I'm
so we've already introduced the class or the point that here in our JavaScript application development. Course, our big purpose is to build a three tier web application, right? So we're going to build that'll be your project,
Model, View Controller, web application.
Now we've talked about it before, and by now, I expect you to know that the view is your Express js web server with HTML on the front end in the users in the user's browser. Men, you
uh, right. So the view was the point of interaction between user and system, and our view is going to be an Express js web server, which we've already seen. We did that last week, of course, an application that does not remember from one day to the next, what you put there would not be very satisfying. It's like if you go to Amazon to review the progress of your order and it says, Well, I don't know who you are. You've never made any orders. So we need to have some sort of a data persistence layer, and that's what we call the model. So in terms of our three tier application back end, so the Express is the web server is the front end, and the model is the data persistence layer is the database. And our database is going to be Mongo. I'm
and that's about it. That's what it's going to be. And we're going to be using a cloud based server. So that way, if you make an application, and if you have several users using the app, maybe it's like for a family shopping list or something, you want everybody to be able to add stuff to the shopping list. So we're going to be hosting our database on a cloud based server, which is called MongoDB, and
then we're going to be writing some JavaScript code. So now. The middle of this is the controller. So the controller is JavaScript objects which deliver the business rules and functionalities of the application. So
So a user logs into your website, address, HTTP, whatever it is, you log into the web server, and maybe there are some forms there. So we put some HTML forms. User fills out some information on the forms, which runs a program over here on the controller, and the controller might need to go and query the database. It might need to send a database query, get back a result, wrap up the results in HTTP HTML and push it back to the user's web browser. So that's what we're going to do. And what we're going to focus on right now is learning to use Mongo as our data store, and we're going to use MongoDB as our hosting platform. So everybody now go and do the following. You
all right, so first of all, we're going to do this step right now, this is our current step. Do everybody go over to MongoDB and log in or make an account? You
so
say, try for free, and then use any email address you can come up with.
I don't know if I have any unused emails yet. Maybe my dog peanut. I don't think I've used his email, penis to Be sean@gmail.com
and password, so make up some password you
that email address is already in use. Of course, it is okay.
Let me just go and see if I can find another email. I'm just going to check my list of my list of emails here.
I'm play with
by yourself. And pretty self explanatory, I'll guide you in a couple seconds when I can find an email to log in
with. I Oh, I don't think I've used my real estate thing. I can just sign up with that one out here. So let's go get that going.
Okay, let's try this again. I'm.
And put in some password you're going to remember,
and
that should be about it. I don't think you need to do anything else. So create your Atlas account. You
I have to go and click on the link. Okay, I have to go and click on the confirmation link. I
All right, my email has been successfully verified. I'm a happy person. Is there anybody who has not set up their MongoDB account?
No, all right, let's carry on
assuming the screen like survives long enough and doesn't blow up before we're done. So now I'm going to go back here and log in. So welcome. Use your account to deploy a cloud database with MongoDB Atlas, very good.
So what's your primary goal?
Just to learn or something learn MongoDB. How long have you been developing? I don't know. Just say you've never developed, or a few months, whatever these questions are just for them to keep track of their users. Has nothing to do with you anyway. What programming language will be using? Node, of course. What type of data will your project use? I don't know. Whatever data I can get for free, basically Sure. I don't know something specify the types of data, open source demographic data. Again, just type some nonsense there, because
doesn't matter for anything.
So your application of any of the following architectural models? Yeah, probably mobile. AI, Internet of Things, serverless, yeah, basically all of them. Why not? We're not paying for them. I
All right now we want to get the account, which is free, not not paying for anything. So therefore, please, very carefully, go over here, the 03 tier layer. So go to there and just click anywhere on this box. You Yes, you cannot change the name once the cluster has been created, all right, so I'm just going to call it Peters test dB,
and this other stuff you can just leave check provider makes totally no difference. I'm going to go with Google Cloud, I guess. But again, it doesn't make any difference region, I don't know. Just stick with Iowa. Yes, that's as good as anything. And next we're going to say, Now, create deployment. Is there anybody who has knocked on this? All good? You can go and do it again later, right? It's not going to hurt anything. It's good to practice it several times anyway. So we'll say, create deployment. And I hate these things, Jesus, right. So go and play around with this for a while. You know, the new chat, GPT, 5.0 can do that much faster than humans. So in a couple of months, once that's out, this isn't going to do it anymore. Uh, okay, I guess that's probably all of it.
Whoops. What happened?
Oh, I see I clicked on the wrong part of the screen.
My thing, where's my I am I just clicked somewhere else because I wanted to see if I was using my pen, and now I have lost my my stairs. Jesus. All right, well, maybe, if I, oh, maybe I just have to click here, maybe, because I already got them all, so I already passed that. All right, so Google Cloud, Iowa Central. Go to Advanced Configuration. I guess we're going to go with the free share by the way, guys, if that's bothering you too much, you actually it just kicks out for a second or two. If it gets any worse, I can kick out an in class screen sharing link, but it's probably not necessary right now. So go here to the free shared level, and that's about it. I guess you could leave all of these as they are. Doesn't have anything to do with you. Where this would make a difference. Let's say you were making a real application, and you were really going to be moving realistic amounts of data. You might have 1000s or 10s of 1000s of users a day, and they might be uploading and downloading a bunch of stuff. If you found a server location closer to your location, you would pay less. So you'd basically make that decision based on what the charges would be. But because we're only going to make like a few little toy learning projects, and we're not paying anyway, that's why we really don't care about any of these things. All right, I guess we're ready now here. So cluster name, we don't have to worry about tags. Just forget that. All right, guys, boys and girls, let's go and click here and create cluster
and this stupid thing again.
How would you like to authenticate with your connection, user ID and password. So my username is Peter Sigurdson, and my password is this. Now, guys, please write this down right? Just make a little Evernote. Email it to yourself, whatever Evernote, whatever you like to use, because it's going to be quite hard to get this. In fact, you can't get this information. Well, actually, yeah, yes, you could do a password reset, but it's basically less trouble if you just record it now. So I'm going to take a couple seconds to record this for myself. I'm
so my username is just that now that's going to go in the JavaScript code later on, so you're going to see where that's used in a few minutes. And my password is, I'm
all right, I guess that's all you need to know. So just keep track of that. Now, where would you like to authenticate from? And we're going to be authenticating from our local environment, which is Visual Studio code in your hard drive, add entries to your IP list. So just say, add your current IP address that will have some importance later on when we want to do things like using MongoDB. Sorry, using Mongo compass, all right. So I guess once you've done all of that you should be pretty much finished so we can say, No, it's not letting me finish and close. What else is on? Did I forget something? I have my username, I have my password. I have where I'm connecting from. What else does it want from me? It's not letting me save it must think I've forgotten something. Oh, I didn't create, oh, I didn't create a user. I have a user. Isn't that me? Peter Sigurdson, that's me. Oh, I can make another one, I guess. All right, maybe. So I'm going to call this peanut and peanuts password, I'll auto generate and copy and create user. So now I have two users, right? That should be pretty good. I'm going to record them in my Evernote. I'm
All right, let's try saving it now.
Mo cluster provisioning so you see what it's saying down here. Look down here when you set up the cluster. It takes a couple of seconds to do it, so I guess that's why I can't save yet. So now we're going to go over some PowerPoint. We'll go over a little bit of theory of what a JSON database is, and by the time we're finished, that should be ready. We will then write some javascript code to make that work. Yeah, it's still provision of my thing, right? So let me go and get our PowerPoint. I
and I'll put a link to this in your PowerPoint, maybe for the test or something You want to go and study it again later.
You all right, so everybody go and get that link and join me there, and we'll I'm not going to go through the whole PowerPoint. It's like 200 slides, but I'll go through some of the key high level overview ones you need to use Mongo effectively enough to be able to go and do Your project. So let's go And look at that. I'm
what is the basis of
of a relational you guys have had relational database, right? You've had a course in SQL and relational database, yeah. So what is the basis of a relational database? I It's,
this, isn't it? This is a relational database. This is Thomas bod. I
This is Claude dog. The dog's name is Oscar Wilde. He was a fan of the phone after a while. By the way, anything I say in class would be a death question, and I'm telling you, that was one of the things I asked last term. Nobody knew which I was kind of disappointed. But anyway, what Claude said he invented something called Claude 13 laws. College 13 laws, back in 1972 the world was kind of messed up. I mean, even more than it is. Even more than it is now. And the basis there
was grounding data, because their programming language was COBOL, was horribly inefficient for
managing data. They had these real to real tape recorders. So their way of doing things was to write COBOL would write a data frame onto the tape. And if you've ever seen the old science fiction movies, when they wanted to retrieve some data, these tapes would go so anyway, that was pretty slow. So basis of cause laws, and ask you again, is why?
What's caused laws based
around your team? So Claude said that you make you use relational database
to make a you
use relational database to make an information system or a. Business domain, just like we're going to be doing in this assignment, we're going to be using no JS, Express js and MongoDB. We're going to make an information management system for a dog in daycare called positive care. And the information systems are left receptionist appointments for dogs like whether Boomer or colorist and all that stuff. So anyway, if we were doing it in SQL, let's look at the simplest example. So let's
say we wanted to make the college enrollment system SQL. So we want to register one enroll students in divorce, we have a college enrollment system.
So cause one buyer help us out, here's what he would advise. First of all, he would say, write down all the things you have in your business domain
and your college we have students and the classes and the other wallets, and then come up and continue to ask those
questions and get more information about our business domain. And then you can find out the students have a student
ID name, and classes have a class name, location, date, time?
And cog would ask us. He would say, Okay, that's great. He would say, so what do you want to do with that? Like, what's your use case? What's your business goal you want to do with that data? And your answer would be, well, we want to roll students into classes. So
how would we do that? Oh, I
know. What if I put it by the way, this will also apply. Also a class
ID. Why just put class ID in my students table, and
then I can make records here. I can make row sets, because this is a table. This is a schema, and every one row of data in the table is a row set. And then I can just make one row set for each student, for each class. Is
that a good idea? Why Well, thinks it's a good way to do it. Everybody
thinks it's a good way to do it. Who's your instructor for relational database?
Lover, near news getting one of
my phone is I'm going to call her and ask her and ask her to change your grade into a failing mark. Because if you honestly can't see that she should, She's a nice person. I mean, she's a nice person. The one thing I don't like about her, she says I would have failed if you were in my relational database. Course, the reason why this is a bad ID idea is that student ID is the primary key, and the basis of cost loss is normalization. Todd said, We don't want to have any duplication we don't want to have duplicate data. Why? Because, um, I have a picture of my PowerPoint show you a while 1972 this hard drive was being loaded before plane. It was basically, sometimes you see that band out buying the building. Every week it comes and delivers all the supplies. A five mega megabyte, a five megabyte, megabyte, you have a little you can't even buy, like, if you walk into Best Buy to pay the smallest memory you can get to something like two terabytes, or something a five terabytes or something a five megabyte hard drive. That was $20,000 a month to rent. Memory was very expensive, so God said no duplication. And the reason why this is bad is because each student has six classes each term, and they have four terms in their program, so we would have so many duplications of the student ID, but because it's the primary key, you're not allowed to
duplicate it. So that's a four duplicate so that's a horrible idea. Another way we could
do this here, why don't we just do a run around? Well, with the student ID over here in classes table, is that a better idea? No. Same problem. Because we're there to duplicate the class ID. It's primary key. We can't do that. So that's not bad. So sorry, guys, put your stuff together. Go home. College is over. It didn't work. We cannot enroll you in the class because of cost loss. Get mad at him, not me. Can anybody see another possible way around this? Remember that it's the relational database system. So we make another table here called enrollments, and that can have rule sets which has a primary key of enrollment ID. Just make up some number, random integer, 12345, whatever. And then we can put
a student ID here, and we can put a class ID here, and we can generate row sets in our module, and they're going to be unique. That's
going to be the unique value, and each row set relates one student to one class. And that is a very simple example of how a SQL database works. Now another couple factors to bear in mind of a SQL database is your SQL database
we hosted on SQL Server, Oracle, for example, the database of the file on the file system, it's going to
be a very complicated file. It's a very dense file that contains all that information, but the database server sort of packs it in. And by the way, I cannot take a Microsoft SQL Server database and open it with Oracle. Why? Because they're different products. They have different products, they have different coding they have different ways of passing the
data. Every single vote is different. So anyway, what the world looks like. Now here's JSON, which
we're going to be learning about now. So JSON starts for Java stands for JavaScript, Object
Notation. It is a data description language,
just like HTML is a page description language. And Jason, everything is collections. So when Jason hit
the stores, name might be the key, Joe might be the value.
And then we have a set of key value pairs beside the in between curly braces. And the first thing he notices that Jason is just text. So because it is text, therefore we can read it and write it and manipulate it and change it. Under program control, just like we can generate HTML from a program, we can generate JSON from a
program, since you can change the shape of your data container dynamically at runtime under
program control, something you could never possibly do with a SQL database, right? You can't change the number of columns in the SQL database with a program, but you can do that with JSON. So here's the first thing we need to realize now, so everything in JSON as collections. So here's a collection, and then we might have other
collections, our class collection. And then how do we do predicate join? Well, that's something I have to show you now. So predicate join when you connect tables on fields. And to do
this stop, to do crud, create, read, update, delete, in Jason, we have to use an npmjs.com package called mongoose, which we're now going to learn how to do. So what we've done so far today is we got ourselves set up. We now have a database server
where we can contain our JSON data, but now we need to write postscript
programs, and we're going to make the college enrollment system. Now exactly what I just showed you, we're now going to make the college enrollment
system. Um, system right so everybody,
I guess, now, is set up with their MongoDB. So let's go and learn. So now the next thing we're going to do is to learn to use a tool called Mongo DB compass, which is a sort of a graphical tool that looks like this. And it's a way that you can sort of visualize. You can poke into your Mongo database, and you can see your collections and documents when you're developing it. It's kind of like a little thing that helps us out
when we're developing our Mongo database. I'm I think
their server might be down. I have the same problem last night. I was at another college, it just kept hanging on the screen, and I don't really know what's wrong. So I'm not going to spend time on DB compass right now until I know that it's working. And the only reason I can think of that it's not working is maybe your servers down or something. So anyway, we'll come back to this later. So now let's go and make some I'm going to get
your worksheet. I'm going to get your let's just go through a couple slides to PowerPoint. First. I'm
so some of this reviews, this is from my database class. So we review some SQL stuff. Not going to get into that here, but I just want to show you a couple of things about Jason. I
Yeah. So the basic thing about Jason is, unlike SQL, the biggest difference is there is no primary key. You do not have a primary key, therefore you do not have referential integrity. That's good and bad. It's bad because we could no longer count on our database to be the truth, right? If we had a warehouse, and if we had a SQL database for the warehouse, we could always go, by the way, that was a hard drive in 1972 right there. So if we had the primary key, you could always be sure the database had referential integrity. However, there's many kinds of problems in the world which does not have a primary key, facial recognition, right retina recognition, thumbprint recognition, and more and more these days with big data, you ever get a test question that says, what's it called when you don't have a primary key? The answer is, it's called big data. And Jason and Mongo are databases that are used for big data type problems, such as we're going to be wrestling with here in our class, by the way, Jason is also the data schema for chat GPT and AI agents. Jason is what's used to manage your conversational memory with your AI agent. So here's the kinds of things we're going to work with with MongoDB. Create databases collections and documents and predicate joins between document collections, that's going to be our exercise. Now, anyway, this was just to give you a little bit yeah, so single source of truth. So when we lose referential integrity, when we do not have a primary key, we cannot be sure that our database is locked up. That's also good, in a sense, because to distribute a SQL database across multiple nodes is quite a difficult thing to do, because you have to lock each database every time you want to replicate it, whereas Jason just being text, it easily replicates across many different database servers, just like a web page can replicate across many different database servers. And I'm going to show you examples where that's quite a beneficial thing, by the way. Here is the basis of SQL. This is the paper that Thomas Codd published in 1972 Todd's 13 laws, where he talked about how SQL is constructed. Memorize that, because you're going to get some questions on that or your final exam. I might just say, like, what's law six or something? And you have to talk about it. Okay, not really, but I still think it's a good thing to know about. Now, some of you might have encountered this little thing that's going around in it circles. Is it called 13 laws, or cods? 12 laws? Being a computer science guy, he always started everything with zero, so there are 13 laws, but the first one is law 00, to 12. So that's why the journalists, the newspaper, people covering the press announcement, got confused, and it's sometimes called as being COD's 12 laws, although there are, in fact, 13 of them. That is going to be a final exam question. If you don't know it, I'm going to laugh at you really hard. Yeah, not just in a pleasant way, either.
So here are some examples comparing SQL and JSON.
The more structured your data is,
the more you want to use SQL. So that is a highly structured data model, right? Maybe that's product in a warehouse. Definitely, SQL is the way to go here, whereas, example, correlating a person's demographic characteristics. So demographic is like gender, male, female, job? Where do they live? Married, unmarried, How many children do they have? What professional do they work in? If you want to correlate somebody's demographic profile with their shopping patterns, then you definitely have to use JSON. Why would I ever want to do that? Well, that's how Facebook and Google make their money on advertising, right? They identify how to present ads to people who are likely to buy that product based on using the methodologies of Jason and big data. So the whole philosophy of COD's laws is to flatten the data make everything look the same. Normalize means make everything look the same.
Normalization washes the subtle details out of the data model. However, if we're building a platform, business like Airbnb, Uber, Amazon, right, any of the big ones that are out there for high bandwidth business models, our monetization hooks, meaning our ways of looking for subtle details of how the customer interacts with the product, we lose those. If we were to put that in SQL, we would lose it. Whereas, if we use a JSON data approach, then we can make our model as refined, right? It's like, if you have a microscope, you can turn that dial in the microscope as much as you want to go and get a more and more fine grained view into what's going on with your business domain. And that's what we call building monetization hooks
into the platform.
I'll give you one example. It was kind of funny. A couple of terms ago, I had a student, and basically, for the past year in my mobile application development was you do capstone project. I'm encouraging them to put AI, because, you know, you can go and get chat, GPT, AI, APIs for a couple of bucks. You can drop a couple of dollars in your account, and you can build the you can use the open AI API keys directly in your own product. So anyway, I was encouraging my students to because in the traditional, in the old way of doing things, I.
I see this is what
the world looked like. Looks like this a lot these days, but this is what we were talking about here as well. Here's my scrolling thing. How do I drag this over? I should have a I should have a scrolling. Oh, it's there. So this is what we're building in this class as well.
Model View Controller.
So the view is the HTTP server, the model is the data store, database, and the controller is some Java or JavaScript objects which implement business rules and algorithms. Now, in the new way of doing it, the control model is being replaced by the artificial intelligence large language model, chat GPT is the best known, but there's many other ones as well. So what I was encouraging my students to do is make connection calls so they would get their users preferences, right? Whatever the user wanted to do, we would, they would get it, they fully pass it as a chat GPT query, and then they would post the chat GPT answer back to their user so the user specified they had certain goals and using the product then those that narrative would be wrapped up as a query, they would send it off to the chat, GPT open AI language server, which would send a response back. And that's as far as we went, because it was just a 14 week course. Like we did, we could have gone much further, if we would have had more time, like I was showing them how to put their responses into a JSON database and so on. But I'm just going to tell you one story which is pretty funny and which does talk about this idea of monetizing fine grade details, of process interactions. So I was testing the students app when he was presenting it, and I, you know, just made up this fictional persona, I don't know, Carolyn, 24 year old marketing manager, and he had made a fitness app. So the the app was asking me, you know, what's your goal in using this app? So as this fictional user, Carolyn, I said, I don't know what to look good to, to have a beach body for when I go to Cancun in the summer. And then we were going through some use cases. It had a reminder function, and it was, you know, typing in certain things as this test user, you know, I'm leaving work now I'm going home. The user told the app, and the app answered back, there's a gym on your way home. Would you like me to book a fitness class for you? And as the user, I typed, no, I'm tired. I don't want to do that. And the app, powered by the AI language model, its response was, do you want to be the only girl in your group at Cancun whose tummy is hanging out over her bathing suit? And that was an example like that's no hue. First of all, no human being would have dared to say that they'd be too worried about getting head injuries. But the point I'm making when I'm talking about monetization hooks and fine grained details, those are the kinds of things yet with Jason, like, how would you code that in SQL? Like, what would be your approach to coding that kind of a user interaction with an AI conversation in SQL? I'm just saying this to get you excited about it, because Jason is a little bit of a learning curve. Initially, it's sort of a little bit hard up front to figure it out, but once you get it going, put it in your LinkedIn, put it in your resume, because employer, all the cool new stuff is being done in Jason, by the way, if you get hired at a company which is kind of, you know, they have some old, established products, they're going to be using SQL, but if they're developing some cool new stuff, I guarantee you it's going to be JSON. So anyway, go and read the rest of my PowerPoint, and we're going to go now. We'll take a little break when we come back, we now have our hook up to MongoDB. We're going to write a no js app. We're basically going to do the college enrollment system. Mongo, all right, take a break. We're zoom at 1020 and then we'll carry on zoom at 1020 you
Hey, Mayor Newsom, Peter,
what's going on? You got a minute? You want to get coffee? Well, basically, I've got some of your students from last term relational database, and we've got things to talk about. Okay, I'll see you. Tim Hortons, in a couple of minutes. All right, Take
care. You.
Oh, Bye,
Yeah, And I Okay. I Don't that's Kind of Going
the Bullet. Yeah,
the is growing. I
See We it was coming.
Okay, I forgot what I said about the breakthroughs, probably 1020 so I'll pick it up.
You. The
So these
if I go to Home Plate, I'll See if it
the I created this favorite and I see this thing, this
Yeah, so The values,
this
So one that's is
another one right.
Whenever you give freedom
of refresh this one
now. You wrote that with chat.
It's all right.
Armand Weir ashmeen, damanpreet no ekmanjaat, jasan Preet
Mohammed,
Priyanka grandman, deep smile. Preet baleena, Alina punch. All right, then, if you were here, what was the name of Thomas cods dog? Because it's not just enough for your butt to be here, your head has to be here too. What was COD's dog's name, Oscar Wilde, very Good.
Arjun Shani deepraj, canoe,
garage, Jasmine Kamal you
manic Mitesh Neha
krishita, Pro Sahan, yes, sir Raj Kumar, Sandeep, Saurav, Shivraj, s
Sudip
UT, Karish, komalpreet Muskan, all right, very good. So these question i.
Number three, you're not amanveer saying I've seen him. You don't look even a little bit like him. Who are you?
Damon fried, you were here.
Let's deal with Damon fried to begin with. What if you were here? What was the name of Thomas codd's girlfriend when he invented sequel?
Ah, so
you weren't actually here. All right, who else thinks they were here?
Name, which one are you? Which number? The first one. So you got to tell me the that's
the only thing I have time to look for
anybody else.
Really, okay.
Anybody else 16,
what's the basis of relational database? Ah, good. All right, Carrie, let's carry on, guys, number three. Amanveer, Singh
Oh. Jocelyn Preet,
you here?
Okay, so you're number five, diamond three. Alright? Anybody else? Let's carry on.
Alright, so
we're now going to make a no js application using Visual Studio code, using MongoDB in the cloud to make the college enrollment system. I don't think we're going to get too far in our positive our pet care application today, but it doesn't matter, because however long it takes, we got to know Jason really well, because it's going to be a big player in our story. So if we do nothing but get a really strong hookup on Jason and MongoDB and then maybe make a little front end web application with Express, that'll be good enough. We'll carry on with the assignment next week. So let's go and do all of that. You I'm
just going to call up my next lesson planning. I'm
all right, ladies and gentlemen, go back to your lab workbook, which maybe a couple of people were, were not here at the beginning. So I'll show you how to get to this. So this is where I'm going to be every week, adding more less material onto this. So if you're not sure where this lab book is, I will show you where it is in Moodle.
Are you guys who here is on the pm guild. And if your hand is not up, then my question is, why? Because project management skills are very strong in any area of business, especially in it, and if you can combine some IT skills with project management, just to show the interest, right, just to walk in the interview and be able to show it on your resume. I'm going to say that if you do not take advantage of this, you're you're probably not very smart, because it's going to be a massive amplifier to your opening the doors in terms of getting into the job you want. So please, as a personal favor to me, it's free, right? You get in there, you get a free. Student Membership. Quiet. Your talking is bothering me. If you want to talk about something else, go to Student Lounge and talk about it. This is going to be a major plus and accelerating your career. So please, next week, when I ask you Who here has gone and joined this I hope to see everybody's hand up there. Alright, so let me show you where the link is. If you joined us a couple of minutes late. It's going to be right here at the top of your right there class learning instructions. That's the link. Every week we're going to be carrying on from there. And I guess I should probably put this in news form as well. If anybody is not here to see that, you
all right now let's go and do it,
so where we're building up to. And to be honest, I'm not totally sure how fast this is going to go, but if we don't get it done today, then we'll, we'll get to there next week. We like to get to the bottom of this lab sheet, which is
building the college enrollment system using Jason, right? So this lab lesson workbook building the college enrollment system using MongoDB. Of course, there's certain stuff we have to learn about before we can get here. We have to learn how to make a simple JavaScript program that can connect to MongoDB using your connection credentials. And we have to learn how to do crud, create, read, update, delete records. And then once we've done all of that, then we can see how to make a predicate join using what in Mongo they call the aggregation pipeline. So anyway, don't be intimidated. We'll go over it slowly. We'll make sure that we get everything done, and we will start at the top of the slab worksheet right now. So first of all, I would suggest, before next week, you go and read through my PowerPoint notes,
lots of good stuff there,
and everything I'm saying now is in this otter AI dictation. So we've previously set ourselves up with Visual Studio code, and we have now done this right? So that's done. We got set up with MongoDB. We made A count. I
All right, so we did that,
and now we're here. So this is our current work item, and the next thing we're going to do in class, in class is a bunch of code drills to learn how to do crud, create, read, update, delete in Mongo. Now the first thing we're going to find out is we'll actually be using in Visual Studio code in our application. We will be using an npmjs.com package called mongoose, which gives us APIs to do crud in a Mongo database. You
all right, so we're going to go and use that package, all right. So first of all, step one, we're. Because let's make a Visual Studio Code project. You should know how to do that by yourself by now.
And make a directory for today's work.
And since we're making the college enrollment system, why not call it Mongo, college enrollment system and call it whatever you want. That's what I'm going to call
mine, close whatever else you have opened somewhere else, File, Open Folder, new folder, and Then whatever you're going to call it,
select folder.
And always take a second to just look up there and make sure that your directory name is showing because if you're not in a directory, you can open Visual Studio code and just be floating in outer space if you don't do the thing of open direct and then I don't know your I don't actually know. I haven't spent time figuring it out, but your code, will just get lost somewhere in la la land, and you have to go back and retype it later. So to avoid that from happening, just double check that and close any messages, pop open any welcome screens. And now we're going to make, first of all, we're going to go File terminal. So we're going to do view terminal, or you can do view terminal. What's the very first thing we do when we make an NPM application, we make and it's very good, npm init, and that creates our package, dot, JSON file. So npm init, and I'm just going to do the dash y option to let it automatically set all the values, because I don't really care, you know, what's the name of the application or something. And if I wanted, I could go back and edit it here anyway. And the next thing now, I need to install certain thing be using, well, if I'm working with Mongo, I probably need to install Mongo, so npm install Mongo and mongoose, and we'll probably need some other ones later, but if we can just get those two for right now, we're good. Does anybody not up to here right now? Does anybody need my help to make a project and to do your basic installs? Very good. Now let's go and make a simple file to do our work in. So we're going to go and say, File, New File. It doesn't matter what you call it, file, one.js or something.
And remember, in your file system, you also got to add the extension so Create File. And now let's go to our lab book and start studying our code and start studying what to do you
so here we are in Our lesson book,
and our first crud drill is going to be,
actually, I should have one, yeah, this is showing the little code snippets. I'm just looking for my I have one file which shows you everything from the beginning. All right, so we've done that. We made our project, we made our init, and we did our NPMS.
Yeah, this is showing little snippets. But. Because you guys are kind of, oh, actually here. So go to point five, right? You can do Control F or whatever to search in this. So look for where it says mongoose. Code drills setting up mongoose. Create a File. Doesn't matter. Call it whatever you want, and add the following contents so you can retype them or copy them straight out of here. So first of all, we're going to say const mongoose equals require mongoose, that makes the Mongoose NPM package available in your program via this variable. Now here you have to get your connection string. Ladies, ladies, ladies. If you want to talk, go to the student lounge and talk. I've been trying to tune it out, but it's making me very distracted. So I guess it's probably also making your class members distracted. If you here, be quiet and pay attention, and if you want to do something else, that's more important, I get that there's a whole pile of rooms on the second floor. You can go and sit there and do anything you like. So first of all, let's drop this into our program. But we need to go and get our information right. So if you forgot to take note of that, I will drive you back to where you can go to your MongoDB account and get it. So let's start right here. Now you see the cool thing about this, because it's a cloud server, so you can make your app, and you can make your app, and you can both point to the same cloud database, and then, if it's a game, for example, and if your data structure is showing you the cards you have in a hand of cards, then it will go to the same point and you can share data. So let's grab this,
and now let's go and make sure you know where to get your stuff here.
So you're going to need your username here. That's basically all you need for right now.
So if you forgot, I generally I tell people to go and get this when they're there, but I know I forgot this time probably good. Another lesson outcome I would like for us to get today is to be pretty familiar with working with the MongoDB website. Let's go back to here and log in with whatever login information you made you
so there is Peter's test database. That's what I made. I can try connecting to it, and I can go to here, I believe it is. Yeah, it's probably VS code. You could also get it from drivers. I think you could actually play around and try getting it from several sources. There. Do you see copy this? Now you're going to be needing this all the time, so my suggestion is make a little Evernote, or a little like Word document or something to just keep that handy.
So that is the name of my database, and I still need my username and password. So let's go. I'm just going to dump a screenshot of this and your instruction notes, because I don't know next week or whatever, when you're doing the assignment by yourself, maybe you just want to go back and refresh on this or something. So I'm
so the rest of you guys just grab that and in your Visual Studio, code, copy that string over, substitute. It's
great doing that in a couple seconds. I just want to update your lesson notes
with this. I'm in the worst case, if you
really can't find it, you can just go and make another cluster and make another cluster
and just get that time you
that connection string also, I think, um. So if you just want to get the connection string to sub in, I think you can get it right there. Yeah, that's what I want. So I could. And once again, I'm just going to drop this directly in your, in your, in your lab notes, so you can have it for later. I'm
I think my editor just wrote, my graphic tool just died. I
No, here it is.
So just copy that out somewhere where you can find it
next time you I'm
going to do that myself, copy
right So going back here. Now I should just be
you see MongoDB, that is a protocol identifier, just like HTTP is a protocol identifier that tells your environment you're going to a server, because you could also host MongoDB on local premises and the rest of that stuff. You get that, right? So actually, but that did not put my username and password in there. That was a thin award.
What's going on? I
Yes, so here. Oh, so still, yeah, what I wanted was my username and password. I forgot that. All right, I'm going to see if I can find it somewhere else. So grab that to start with. That's at least giving your database name, so you can drop this in here and
yeah, it's possible that if I forgot to record it before, which I might have done. I think in that case, I might need to go back and make a new Make a new database. I I don't think there's a way to going to go back and get that, and because I was explaining and talking, I wasn't remembering to do that. So all right, no problem. I'm just going to go and make a whole new database. Now I'm
and if you also didn't get that information before, might not be a bad idea to follow along with me. So I think I go to database. I
Yeah, so I'm going to make a new project. So I go up here to the top make a new project, right? So I go way up to the top of cloud.mongodb.com,
and I say, make a new project,
and I'll call it by the date time. So I'm. When I made it. So I'll call it June 5:11am, that way I won't get it confused with other databases I may have made. I could also now, when you're doing your project, which we're going to start, probably around week seven or week eight, maybe after the march midterm break you can add, so you can make one database and add all your team members in there. And I think here I could just go and click on Next, and I'm going to record everything now, because I don't want to run into this problem again. So I have this little thing I just like, sort of record everything I do. Sometimes I would even just make a video so I could go back and watch the video later. So here's my database,
and I'll say next.
Peter Sigurdson, yeah, that's my email. So again, I should probably remember that I use that email because I might not remember that later, I'm going to say Create Project.
And now I'm going to say, create cluster. So there's my database, 20 4060, 5:11am, name I'll just call it, I don't know, blue horizon or something, because that sounds cool, like a cell phone company or something, and I'll use Google Cloud and I'll host it, why not? And, well, maybe I'll host a Toronto that's closer to us, and I'll get the free account layer over here.
So my cluster name is this,
create deployment and
you can just make another user in sim?
Yeah, I think because I've already set up several accounts now, so they probably want to start charging me some money. So, yeah, I'm just going to go back and make another user there a good point. Yep, you
or I could just pay a couple of bucks. It's not that big a deal. I could just put my credit card in and pay a little
bit i So spend
a couple of seconds. Just click around in your panel, get familiar with it. So there's the in. What happens if I go back to Project Zero and make another user sorry? What's your name? Deep? Deep, yeah. So as deep rod suggested, it might be easier for me, in my case, to just go back to Project Zero and see if I can make another account, another user,
unless I stored the information before. Because usually, well, actually, I think I did store it before. Yeah, my user is password. Oh, sorry. My user is peanut, and my password is here. So I think I'm okay when I did it before I did get that well, let's try it. In the worst case, it's not going to work, and I can just go and make
another account. So I'll grab my username. Is there? Get rid of the curly braces.
So peanut colon, and then I'm pretty sure the password is what I stored here. Well, let's give it a shot. Now, if my DB compass was working, I could just use DB compass to test that as well, but DB compass, I think I'll try it again, But it wasn't worth but it wasn't working.
Before you
there's compass. So if I put in my connection string here, I'm.
So I'm going to try and it wasn't working before, but I'm going to try dumping my creds in this MongoDB compass string, which, first of all, will demonstrate compass if it's working, and will also validate if peanut And that password I'm using is the correct combo You
well, all that tells me is that their compass server still is not working, which isn't really a surprise anyway. Try it again next time. So let's see now if this connection string is going to work okay in my code, so I'm going to go back to my Visual Studio Code. Well, yes, I already got that. All right, guys. So let's try running this little bit of code and see if it gets actually. There should be one more thing you can put in which will just indicate if it is connect correctly made the connection. So that last little bit of code is,
is I
anyway, let's just try. I'll do that later. So let's just, I'm going to try running this little segment now, so save and run.
Dot forward, slash one.js so yeah, it's working, right? It made the connection. It's not giving me any complaining about invalid password or something. So is there anybody who was not able to run this code? Because if you can't get this, it's not going to get any simpler after that. And by the end of today's class, we've got one more hour. I would really like to get it to the point where everybody can do this. All right, so what's the best way to do this now? Um, I guess just come up. I'll help you one at a time. All right? So whoever is not able to do this, I know it's probably gonna take the rest of the class, but I wonder if that's for the assignment. Oh, time down. Oh, very good. So yeah, before I help you guys. Very good. Thanks for catching
that. So yeah, after several
seconds of not working, a time out. All right, so let me go get my own thing here. Yeah, connection refused. I guess. So
let's study with the error messages.
Actually, it's not even saying about the password. It's saying it can't connect to any servers in your cluster. One reason is you're trying to access the database. You know what? I saw this a couple of terms ago, and the IT department told me they were going to fix it, but I don't think they did. So guys, this is what
happened before, and I don't know why. I do not, because you know
that network connection happens over a port, they will not open the ports for a MongoDB so that gives us a couple of choices. Number one, I'm going to go the internet of my email, or just test and see if I can get to it on my phone. That tells us it's a building land. The other so you have a choice. You can use your phone, or we can put MongoDB server directly on your computer, and you promote locally. Who here has a Mac? Because the only problem with putting MongoDB server local, you have a Mac. Yeah. Yeah, so it has a lot of security things you
need to do now for my Mac users. Satisfying solution, I
found is I can give you the instructions to enable your root password and then just do all of your MongoDB work as root.
It's not hard. You just happen. But first of all, I'm just going to do a test myself. I'm going
to go on my phone internet and see if that makes a difference, and if I only have one Mac user of everybody else's windows. It's probably simpler if we just install MongoDB server or won't do it. Now, when we get to having to do the project and share in the database, that will be another thing, but we'll deal with that later on. Maybe I can go back and ask it again to unblock those ports. First of all, I'm gonna go to my phone and see if that gets me past here, because that is not telling me it's a password problem. That's telling me it's a
connection problem. So let's see this makes a difference. I'm
I see what makes a
difference. Now the first thing I'm going to test is MongoDB compass again,
still not so much. Well, the other thing I can do is whitelist my own IP address in the cluster. So I'm going to go back to MongoDB,
and I'm the
current IP address not added, you will not be able to connect to databases from this address because it's My phone, so I will whitelist this address, first network address, current IP Address. I'm going to add my current IP address. I'm
all right, let's try Mongo,
DB, compass again. I I sold no but it wasn't working at another place yesterday, so I think MongoDB compass is just dorked, although if I do install it locally, I can use compass. That's another advantage. I think we're going to go with the option of running MongoDB question louder. Sorry, you got I can't hear a word you're saying. Oh, if MongoDB compass is connected, it'll show you you can point it at a database, and it will show you all of the databases, collections, documents, you can delete, you can add, you can test, you can make sure your code is working. It's pretty cool. Yeah, I think we're going to do that. I'm just going to do only one more test now that I'm on my phone, and then we're going to step back a couple of steps. We're going to install MongoDB server on local and my Mac user. If you're having a problem, I'm going to give you an instruction for active root password, which you're probably going to need anyway, right? You're going to need that for other things anyway. But let me go and try running this code again. So what does this make any difference now that I'm on this database,
on this network connection, connected to dB cloud. Look You see, does everybody see that? Look, there it is. Well, that tells me that those being recorded by auto, AI,
but it's okay. But anyway, that tells me
my password is right, which was the original thing I started here. All right, so, um, I could now proceed, but I guess the rest of you guys are not getting who here. No, you don't want to use your phone anyway. Forget. We're just
going to go install MongoDB local. Let's do Let's spend it on the building, building, when, when, and
then we can get everything going. Then we can get everything going. I'm going to close everything to start it all
again. I'm.
so mean. Who does that? I Yeah, what's up,
don't js, well, so they said, like, the URL must include, like, you got all of that, yeah,
let's just get ourselves. I just want to get the MongoDB server up and going. Then we'll look at
this again. Hey guys, I'm going to give your instructions on how to do that. Hang on you.