MERN Stack Interview Questions and Answers | MERN Stack Interview 2023 | Simplilearn
Résumé
TLDRThe video explores the MERN stack, consisting of MongoDB, Express.js, React.js, and Node.js, highlighting its efficiency in building scalable and responsive web applications. It delves into the basics and advanced aspects of each technology, offering insights into industry-relevant interview questions. MongoDB's advantages include flexibility, scalability, and high performance, while Node.js is celebrated for its speed and event-driven architecture. React.js uses JSX for a seamless integration of JavaScript and HTML, improving code readability and debugging. Express.js, part of Node.js, enables swift API development. Practical applications discussed include MongoDB's use cases such as IoT, mobile applications, and large-scale data management, emphasizing its utility in managing vast datasets and processing them effectively.
A retenir
- 🚀 MERN stack is efficient for developing scalable web applications.
- 📚 MongoDB provides flexibility and scalability with its document-based structure.
- 🖥️ React.js uses JSX, making code easier to read and debug.
- 🔄 Virtual DOM in React updates only changed elements, enhancing performance.
- 💻 Node.js is fast and event-driven, suitable for real-time applications.
- 🔧 Express.js is vital for building quick and robust APIs.
- 📈 MongoDB excels in handling large volumes of unstructured data.
- 📱 MERN stack supports both front-end (React.js) and back-end (Node.js, Express.js) development.
- 💡 Understanding MERN can significantly benefit those pursuing full stack development roles.
- 🔍 Regular study and practice of interview questions can enhance job prospects.
Chronologie
- 00:00:00 - 00:05:00
The video introduces the MEAN stack as a popular web development stack comprising MongoDB, Express, React, and Node.js, and outlines the basic roles of each technology (MongoDB for databases, Express for backend, React for frontend, and Node.js for server-side runtime). It highlights how these technologies together create highly scalable web applications.
- 00:05:00 - 00:10:00
It informs viewers about an upcoming segment on frequently asked MEAN stack interview questions. It advises subscribing for updates and suggests a coding bootcamp for immersive learning. The bootcamp covers Java technologies, while also mentioning other topics like Angular, JSPs, and MongoDB.
- 00:10:00 - 00:15:00
The presenter explains JSX (JavaScript Syntax Extension) used in React.js to bind JavaScript and HTML, simplifying code structure. The concept of the virtual DOM in React, which allows for efficient page updates by only altering changed elements, is introduced. React extensions like Flux and React Native for mobile apps are mentioned.
- 00:15:00 - 00:20:00
The speaker discusses React components, dividing complex UIs into reusable chunks. They detail "state" in React as a way to track data changes over time, initialized in constructors, allowing pages to render based on current data states. Higher-order components and pure components, which help with reuse and shallow comparison respectively, are also described.
- 00:20:00 - 00:25:00
React routing is introduced as a means to manage URL paths and deliver components using React modules. The session transitions to a Node.js interview overview with beginner to advanced questions. Node.js is presented as a leading server-side platform due to its open-source, cross-platform JavaScript runtime allowing fast application development.
- 00:25:00 - 00:30:00
Node.js's foundation on the V8 engine, its high-speed asynchronous I/O operations, and its applications in web, distributed, and network applications are highlighted. The difference between frontend and backend development is explained, with examples of typical technologies used in each realm.
- 00:30:00 - 00:35:00
The section delves into npm (Node Package Manager), its role in managing online repositories and command line utilities. An overview of Node.js modules is given, explaining how these JavaScript libraries are utilized for server-side tasks, such as setting up a web server using HTTP.
- 00:35:00 - 00:40:00
Node.js's advantage over traditional back-end technologies like Java and PHP is discussed. Its speed, node package manager resources, suitability for real-time data applications, and ease of code synchronization between client and server due to JavaScript are noted as key benefits.
- 00:40:00 - 00:45:00
The information on Angular vs Node.js establishes Angular as a client-side framework and Node.js as a server-side one. Databases commonly used with Node.js, particularly MongoDB and MySQL, are discussed, with MongoDB being preferred for its scalability with large data sets.
- 00:45:00 - 00:50:00
The segment covers popular Node.js libraries like Express.js for quick API development and Mongoose for database connectivity. The pros (fast processing, extensive package availability) and cons (complex callback structure, CPU-intensive operations) of Node.js are examined, with solutions like cloud scaling proposed.
- 00:50:00 - 00:55:00
Commands relevant to Node.js, particularly for importing external libraries using the "require" function, are elaborated upon. The transition to intermediate Node.js questions includes explanations of event-driven programming, how event loops, emitters, and API functions operate, highlighting synchronous vs asynchronous programming.
- 00:55:00 - 01:00:00
The video explains Node.js's package.json file's role as a project metadata holder and using URL modules for utility enhancement. Express.js is detailed as a framework facilitating web app creation in Node.js, streams in Node.js accomplish ongoing data reads/writes, and dependency management is outlined.
- 01:00:00 - 01:05:00
Synchronous/non-blocking APIs in Node.js scale applications effectively by allowing data to be processed without blocking operations. Examples of using async functionality and module exports to encapsulate code for shared use are also covered.
- 01:05:00 - 01:10:00
MongoDB is introduced as a key NoSQL database, with emphasis on its document-based storage structure, scalability, and schema flexibility. Common MongoDB interview questions focus on its architecture, alternative NoSQL databases, and distinctions from SQL databases.
- 01:10:00 - 01:15:00
Details on MongoDB's data models (embedded and reference), how indexing expedites query operations, replication and sharding for data availability, and the advantages of MongoDB's flexible schema are provided. Practical questions hone in on tasks like document insertion and handling large files.
- 01:15:00 - 01:20:12
MongoDB's role in highly available systems, aspects like capped collections for performance, GridFS for large file storage, and aggregation techniques like map-reduce are discussed. The video wraps with typical real-world MongoDB applications and resources for further learning.
Carte mentale
Questions fréquemment posées
What is the MERN stack?
MERN stack is a web development technology stack consisting of MongoDB, Express.js, React.js, and Node.js.
What is MongoDB used for in the MERN stack?
MongoDB is used as the database in the MERN stack.
What does Express.js provide in the MERN stack?
Express.js provides the backend framework in the MERN stack.
What role does React.js play in the MERN stack?
React.js is used for handling the front-end in the MERN stack.
What is Node.js used for in the MERN stack?
Node.js is used as the server-side runtime environment in the MERN stack.
What are some advantages of using MongoDB?
MongoDB offers flexibility, scalability, high availability, high performance, and a flexible schema design.
How does the virtual DOM improve React performance?
The virtual DOM updates only the objects that have changed, rather than the entire DOM, improving performance.
What is JSX in React.js?
JSX is a syntax extension for JavaScript that allows HTML to be written within React.js code.
What are some key features of Node.js?
Node.js is known for being fast, event-driven, and uses JavaScript for both client and server-side scripting.
What are the different data models in MongoDB?
MongoDB has embedded and reference data models for structuring data.
Voir plus de résumés vidéo
Molly Wright: How Every Child Can Thrive by Five | TED
PUSH Forward: Our Housing Justice Work in 2021
Very Important Stable Swap Update!!!
"The 1619 Project": Nikole Hannah-Jones on confronting the truth about slavery
Tissues, Part 1: Crash Course Anatomy & Physiology #2
Embracing Agility with Hands, Heart, and Spirit with Jacqueline & Milton Mayfield
- 00:00:01foreign
- 00:00:09stack is a popular web development stick
- 00:00:12that includes four different
- 00:00:13Technologies mongodb crashes reactors
- 00:00:17and node.js mongodb is used for the
- 00:00:21database express.js provides the
- 00:00:23back-end framework react.js handles the
- 00:00:25front and node.js is used as the
- 00:00:28server-side runtime environment
- 00:00:30so this stack allows for creation of
- 00:00:32Highly scalable efficient and responsive
- 00:00:35web application
- 00:00:36hello everyone and welcome to Simply
- 00:00:38learns YouTube channel today we'll take
- 00:00:41you through the most frequently Asked
- 00:00:43interview questions in Moon stack web
- 00:00:45development in this video tutorial we'll
- 00:00:48cover all the Technologies related to
- 00:00:51Moon stack but before we begin let me
- 00:00:54tell you guys that we have regular
- 00:00:55updates on multiple Technologies so if
- 00:00:58you are a tech geek in a container Sun
- 00:01:00for the latest technological trends then
- 00:01:02consider getting subscribed to our
- 00:01:04YouTube channel and press that Bell icon
- 00:01:06to never miss any updates from Simply
- 00:01:09low for those interested in a
- 00:01:11comprehensive coding bootcamp we highly
- 00:01:13recommend the Caltech coding bootcamp
- 00:01:15with this program you can learn to code
- 00:01:17and become a full stack developer in
- 00:01:20just six months this state-of-the-art
- 00:01:22bootcamp will fully immerse you in
- 00:01:24accelerated coding training helping you
- 00:01:27become a valued software engineer ready
- 00:01:29to take on any challenges in the
- 00:01:31industry
- 00:01:32during this boot camp you will Master
- 00:01:34both front-end and back-end Java
- 00:01:37Technologies starting with the basics
- 00:01:39and progressing to the advanced aspects
- 00:01:41of full stack web development
- 00:01:44you'll also learn angular spring boot
- 00:01:46web services jsps and mongodb to help
- 00:01:50you launch your career as a full stack
- 00:01:53developer
- 00:01:54for those who are looking to deepen
- 00:01:55their understanding of full stack web
- 00:01:57development or simply want to become a
- 00:02:00full stack developer in a shorter amount
- 00:02:02of time a Caltech coding bootcamp is an
- 00:02:05excellent option so without wasting any
- 00:02:07more time let's hand over this session
- 00:02:09to our training export the react is
- 00:02:11interview questions
- 00:02:12now as we know it react.js is as
- 00:02:15important as like in other tools which
- 00:02:18you've already has seen so what is the
- 00:02:20jsx here jsx called JavaScript syntax
- 00:02:23extension
- 00:02:24okay so this syntax extension to the
- 00:02:28JavaScript in reactors is in the way
- 00:02:31how you express
- 00:02:33to bind JS and HTML together to result a
- 00:02:36j6
- 00:02:38content so by using j6 you can write a
- 00:02:41structure in the same file that contains
- 00:02:44the JavaScript code that is something
- 00:02:46more Innovative way because of that
- 00:02:47react.js is creating a more buzz in a
- 00:02:50market
- 00:02:51so jsx actually helps making code more
- 00:02:55easy to understand and debug and avoids
- 00:02:57a lot of boilerplate code okay inside
- 00:03:00the Dom structure
- 00:03:01now the next thing is what is the
- 00:03:03virtual Dom see the virtual Dom is
- 00:03:05representing a Dom in a memory
- 00:03:08okay that is called virtual Dom so
- 00:03:11manipulating the real term is much more
- 00:03:13slower and costly Affair okay because
- 00:03:15you need to repaint the Dom over and
- 00:03:18over the period of time when the user
- 00:03:21changes few things so
- 00:03:24when the state change virtual Dom
- 00:03:26changes and only the objects which are
- 00:03:28in real term
- 00:03:29okay
- 00:03:30update instead of updating the entire
- 00:03:33object so that makes your page to be
- 00:03:34load far more faster
- 00:03:36okay so in Virtual Dom what happens this
- 00:03:38is the real Dom this is a virtual Dom so
- 00:03:40the orange color portions which you're
- 00:03:42seeing that is basically the changes
- 00:03:43which has been made okay these are
- 00:03:46called Changed object okay so virtual
- 00:03:49Dom is basically compare it's to the
- 00:03:51previous state and understand which area
- 00:03:54it needs to send for the updates and
- 00:03:56avoid the other areas
- 00:03:58okay that's what this virtual Dom really
- 00:04:01works
- 00:04:03so what are react extension react
- 00:04:05extensions are many like you talk about
- 00:04:07like in flux it is a third party tool
- 00:04:09which is responsible to attach
- 00:04:12the State Management feature to talk
- 00:04:14about react native which is responsible
- 00:04:16to develop the hybrid mobile
- 00:04:17applications
- 00:04:18in JavaScript so these are two very
- 00:04:21popular and there are many more which
- 00:04:23are available okay so like you talk
- 00:04:27about
- 00:04:29architectural support you talk about
- 00:04:31server side rendering okay so Redux and
- 00:04:34there are lot many other tools are also
- 00:04:35available
- 00:04:36so what is an event in react and how
- 00:04:39you're going to create that so react is
- 00:04:40basically offering the ideas of handing
- 00:04:44the event very fairly easy so let me
- 00:04:48talk about clicking anything you talk
- 00:04:50about taking your mouse somewhere so
- 00:04:53these kind of options generate an event
- 00:04:55so for that we typically say alert and
- 00:04:59you click on this render you click on
- 00:05:01this button in a curly braces you call
- 00:05:03the function to trigger to event
- 00:05:06now what are the components in react
- 00:05:09so friends react components are nothing
- 00:05:11but a call View
- 00:05:13okay like a complex view can be divided
- 00:05:16into the smaller portions
- 00:05:18a complex UI can be distributed further
- 00:05:21to create more better and reusable views
- 00:05:25clear so it splits the user interface
- 00:05:29into the independent pieces of code
- 00:05:30which can be developed and joins
- 00:05:34later on okay so that's how you define
- 00:05:37the component in and react so in angular
- 00:05:41and react in both the areas the word
- 00:05:44component is very much used so the
- 00:05:46component meaning is very simple you
- 00:05:48talk about a view
- 00:05:51so what is the state in a react so state
- 00:05:53is react is nothing but is the one which
- 00:05:57identify what was and what is now okay
- 00:06:02if it stores the value for the specific
- 00:06:04period of time which changes and react
- 00:06:07is basically detecting those
- 00:06:09so it is changing because of some
- 00:06:11actions either taken by the users or by
- 00:06:14the applications okay so keep tracking
- 00:06:16about all those States what it was there
- 00:06:18like in I'm talking about an
- 00:06:20incrementing encounter so that is also
- 00:06:22the state a variable there okay so the
- 00:06:25state object is always initialized in
- 00:06:26the Constructor so it can contains the
- 00:06:29multiple properties so this dot set
- 00:06:31state is used to change the value of the
- 00:06:33state object and set state is
- 00:06:35responsible
- 00:06:37to
- 00:06:38perform the shallow merge between the
- 00:06:40new state and the previous state
- 00:06:43now the state holds the data that a
- 00:06:47component renders to the web page
- 00:06:49certainly because every time the state
- 00:06:51changes so it needs to be stored
- 00:06:53somewhere so this is how the state is
- 00:06:56accessed as you can see this example
- 00:06:57here
- 00:06:58in the Constructor we are defining the
- 00:07:00super props and the states has been
- 00:07:02initialized and you're rendering the
- 00:07:04states there are three different steps
- 00:07:05are involved initialize the state rent
- 00:07:08to the state and update the states
- 00:07:12what is the higher order component and
- 00:07:14pure component react higher components
- 00:07:16are the component which are typically a
- 00:07:19function okay that takes a component and
- 00:07:21return a new component to you by
- 00:07:23manipulating few things that basically
- 00:07:26designed for the reusing
- 00:07:28okay so the higher the components are
- 00:07:30typically a function that takes a
- 00:07:32component and return a new component
- 00:07:34okay so to in order to perform some
- 00:07:37reusability
- 00:07:38a pure components are the components
- 00:07:41okay is a variation of react component
- 00:07:44that doesn't
- 00:07:46that does a shallow comparison of props
- 00:07:49and State
- 00:07:51okay shell comparison basically checks
- 00:07:54what the equality
- 00:07:55are we clear now so that's what the main
- 00:07:58job
- 00:08:01going ahead what do we Implement and how
- 00:08:03do you implement react routing so to
- 00:08:05implement a react routing react routing
- 00:08:07also comes with inbuild
- 00:08:10react modules and that particular module
- 00:08:14to import it so
- 00:08:16here we Define the react modules by
- 00:08:19offering the route path where you have a
- 00:08:22call left hand side is the name and the
- 00:08:25right hand side is a component which you
- 00:08:27would like to deliver it now hello this
- 00:08:30is Matthew and we're going to be going
- 00:08:31through some of the simple questions
- 00:08:33that you would be asked during a node.js
- 00:08:36interview what we're going to do is
- 00:08:38we're actually going to break out the
- 00:08:40section into three key areas that'll be
- 00:08:42beginner questions there will be an
- 00:08:44intermediate questions and advanced
- 00:08:46questions and the expectation is as you
- 00:08:49go through this video is that these
- 00:08:52questions could be pushed together as
- 00:08:54you're going through the interview kind
- 00:08:56of think of it like this is if you've
- 00:08:58answered the beginner questions that you
- 00:09:00would get asked at the beginning of the
- 00:09:01interview with confidence and Surety
- 00:09:03then the client is going to then jump to
- 00:09:06those intermediate Advanced questions
- 00:09:08quite quickly and they're looking for
- 00:09:10people who can help them serve and solve
- 00:09:12their problems at that more intermediate
- 00:09:15and advanced level so let's just get
- 00:09:16started so the first question you're
- 00:09:18probably going to be asked is you know
- 00:09:20you know what is node.js you know do you
- 00:09:22know what it's for and essentially
- 00:09:23node.js is one of the most popular if
- 00:09:26not the most popular open source
- 00:09:28cross-platform JavaScript programs and
- 00:09:31it allows you to build out web
- 00:09:33applications that run on the server it's
- 00:09:37extremely flexible it allows you how to
- 00:09:39implement a lot of solutions outside of
- 00:09:41just the the core programming runtime
- 00:09:44and it allows you to build Solutions
- 00:09:46extremely quickly in an open source
- 00:09:49mindset for devops
- 00:09:52it is used essentially for creating
- 00:09:54client-sized web applications we'll see
- 00:09:57this later on and you may want to talk a
- 00:09:59little bit about you know using
- 00:10:00express.js and how you can build out
- 00:10:03apis uh to work with node.js and
- 00:10:06connecting to databases such as mongodb
- 00:10:10and that is also really good for being
- 00:10:12able to store a data intensive
- 00:10:16applications that are asynchronous and
- 00:10:18event driven in their model and this is
- 00:10:21important when you're talking about
- 00:10:23creating applications that can scale
- 00:10:26rapidly
- 00:10:28so you can then ask be asked you know
- 00:10:30how does node.js work well node.js
- 00:10:33itself is actually built on the V8
- 00:10:36engine and the V8 JavaScript engine is
- 00:10:38the same engine that runs JavaScript in
- 00:10:41your Chrome web browser extremely fast
- 00:10:45it allows for high output and
- 00:10:48non-blocking through your i o input
- 00:10:50outputs and is is single threaded event
- 00:10:53blue
- 00:10:55so you're going to be a man asked you
- 00:10:57know where can you use node.js and and
- 00:11:01the reality is the applications for
- 00:11:03node.js keep expanding but there are
- 00:11:05some core applications that you can work
- 00:11:07with node.js right now so such as web
- 00:11:10applications distributed system and
- 00:11:12network applications uh probably
- 00:11:14referencing the web applications is a
- 00:11:17really good starting point because here
- 00:11:19you can actually talk about maybe some
- 00:11:21examples that you've done where you're
- 00:11:22building out some of these web
- 00:11:23applications uh indeed one of the things
- 00:11:25that you want to be consistently doing
- 00:11:27and peppering your answers with is
- 00:11:30examples of work that you have done now
- 00:11:33it doesn't matter if those examples are
- 00:11:35purely experimental or training examples
- 00:11:38that you've done the fact that you've
- 00:11:40actually worked with node.js and created
- 00:11:42a distributed system or a web
- 00:11:44application is really valuable because
- 00:11:47it shows that the person that you're
- 00:11:49meeting with that you have knowledge and
- 00:11:51understanding and practical experience
- 00:11:54of applying the theory of working with
- 00:11:57new Js with the practice of working with
- 00:12:00node.js
- 00:12:01so we asked about you know your answer
- 00:12:04and essentially the io refers to the
- 00:12:07transfer of data in and out of a system
- 00:12:10and that's really it you know there's a
- 00:12:12reason why Google calls that conference
- 00:12:14IO it's the transfer of data in and out
- 00:12:17of our brains at that conference the
- 00:12:19application is same here it's about
- 00:12:21moving data in and out of systems
- 00:12:23through using node.js and that every um
- 00:12:27event can be tracked and whether it's on
- 00:12:30a physical device a network or files
- 00:12:32within a system again it's input and
- 00:12:34output
- 00:12:36so let's go through and you know you're
- 00:12:38going to be asked you know can you
- 00:12:39explain the difference between front end
- 00:12:41and back-end development and this is a
- 00:12:43question that I can ask a lot when I'm
- 00:12:47meeting with clients and you know people
- 00:12:49get really confused about what is the
- 00:12:51difference between front-end and
- 00:12:52back-end development bottom line front
- 00:12:54end is what gets resolved inside of your
- 00:12:57web browser or the app on your mobile
- 00:13:01device backend is what gets resolved
- 00:13:04essentially um what we call the the back
- 00:13:06office or server-side applications but
- 00:13:09it's becoming more and more synonymous
- 00:13:11for what gets run in the cloud
- 00:13:14so web applications
- 00:13:16um really get a lot of the functionality
- 00:13:19of the web application gets run in the
- 00:13:20front end and I think with CSS HTML5 uh
- 00:13:24client-side JavaScript so we can get
- 00:13:26right on the front end everything else
- 00:13:27such as connecting to a database gets
- 00:13:30run behind the scenes in the back end
- 00:13:33and so you know anything that's going to
- 00:13:36have like Graphics is going to be on the
- 00:13:37front end uh apis are going to be run on
- 00:13:40the back end and then just finally some
- 00:13:43of the scripting languages are using on
- 00:13:45the front end so HTML CSS JavaScript
- 00:13:48those are all Common Core scripting
- 00:13:51languages that you would use you can use
- 00:13:53Frameworks such as angularjs and
- 00:13:55react.js or view those would be a
- 00:13:58front-end Frameworks uh back-end
- 00:14:00Frameworks will include Java PHP Python
- 00:14:04and node.js are some of the back-end
- 00:14:06Technologies you'd also throw in their
- 00:14:08dot net as well and it's just a whole
- 00:14:12you know Litany of front-end and
- 00:14:14back-end Technologies and Frameworks
- 00:14:16that you can use and this is a actually
- 00:14:18a good point to kind of explain the
- 00:14:22experience you have outside of just
- 00:14:23working with node.js but other
- 00:14:25technologies that you've been working
- 00:14:27with that potentially that the client is
- 00:14:29also using
- 00:14:31so another question you're going to be
- 00:14:33asked when you're looking at node.js is
- 00:14:35you know can you tell me about npm and
- 00:14:37so when somebody asks you what is npm
- 00:14:39the first thing you're going to respond
- 00:14:40is do you mean node package manager and
- 00:14:43the reason why you want to respond like
- 00:14:45that is that you want to qualify that
- 00:14:47question with understanding that you
- 00:14:49know what they're talking about but you
- 00:14:50want them to verify that and so node
- 00:14:53packet manager is npm
- 00:14:55and it's responsible for packaging all
- 00:14:57of your modules that you're working with
- 00:14:59in node.js and we have a whole series of
- 00:15:02videos that we've done on node.js and
- 00:15:05every single one of them includes
- 00:15:07references to npm
- 00:15:10so you're going to be asked you know so
- 00:15:12okay you tell me um what it is you know
- 00:15:14can you go into a little bit more um
- 00:15:16details you know so you can provide two
- 00:15:18main functionalities and so one of them
- 00:15:21is being able to manage online
- 00:15:23repositories or modules and packages
- 00:15:26um so you can go to like
- 00:15:28search.nodejs.org and you can find a
- 00:15:30packages that you can install Into Your
- 00:15:33solution such as express.js and it also
- 00:15:37provides a command line utility that
- 00:15:39allows you to manage your packages very
- 00:15:42quickly through terminal window or
- 00:15:44command line
- 00:15:45I use vs code a lot Visual Studio code
- 00:15:49and it has a command line utility built
- 00:15:51right into it that allows me to interact
- 00:15:53with npm
- 00:15:55so what are some of the modules in
- 00:15:57node.js and so you know modules
- 00:16:01um in node.js they're essentially like
- 00:16:03JavaScript libraries so you can think of
- 00:16:06some of the JavaScript libraries that
- 00:16:08you may have used the functionality is
- 00:16:11somewhat the same but they're designed
- 00:16:13for node.js and to run on the server and
- 00:16:16there are ways in which you can go ahead
- 00:16:17and create some of those modules so for
- 00:16:21instance if we're creating a web server
- 00:16:23you can actually use the require
- 00:16:26commands to be able to require that the
- 00:16:29server be there so the example we have
- 00:16:32on the right hand side shows that we
- 00:16:34really do need to have HTTP which is a
- 00:16:37web server and we require that to be
- 00:16:39installed and so that if you're running
- 00:16:42that npm package it will actually
- 00:16:45install the HTTP server and then you can
- 00:16:48actually write some code to actually
- 00:16:49then listen on the localhost port 2000
- 00:16:54for where you'll be running your app
- 00:16:55application
- 00:16:57and there are just you know there's a
- 00:16:59whole bunch of modules like I come with
- 00:17:01node.js now right out of the gate and
- 00:17:05here are some of the modules that you
- 00:17:06have and we also referenced that just
- 00:17:08earlier on HTTP is a core module for uh
- 00:17:11running a web server uh you have a
- 00:17:15utility function that is useful for
- 00:17:17developers to assess features within
- 00:17:20your node.js project you have a URL
- 00:17:23module for any URL passing you'd be
- 00:17:26doing
- 00:17:26and you also have a stream which allows
- 00:17:30you to be able to stream data in and out
- 00:17:33of your system and be able to manage how
- 00:17:35that's been worked and then zlib which
- 00:17:37allows you to compress and decompress
- 00:17:39files so that you can keep your storage
- 00:17:42of files to a minimum
- 00:17:45so a question you're going to be asked
- 00:17:48is you know why is node.js being
- 00:17:50preferred over back-end Technologies
- 00:17:52such as Java and PHP and particularly
- 00:17:55with gyro it's a very mature stable
- 00:17:57language it's been around for more than
- 00:17:5820 years you know PHP
- 00:18:00um runs some of them the most powerful
- 00:18:03and largest websites out there such as
- 00:18:06Facebook so why would you use node.js
- 00:18:09well the first response is kind of a
- 00:18:12gimme but it is really fast and if you
- 00:18:15watched any of the videos that we've
- 00:18:18done on node.js building out Solutions
- 00:18:20and developing the solutions you'll see
- 00:18:23just how fast it is the second is the
- 00:18:27really kind of the secret sauce with
- 00:18:30node.js is the node package manager and
- 00:18:33no package manager allows you to install
- 00:18:36additional functionality such as Express
- 00:18:40or as a database into your
- 00:18:43solution really quick green and there's
- 00:18:46over 50 000 bundles available for node
- 00:18:49package manager
- 00:18:51if you're building out a real-time
- 00:18:54application that's data intensive and
- 00:18:57you need to have apis quickly developed
- 00:19:00then node.js is another great it's
- 00:19:03really the great solution for you it
- 00:19:05allows you to build out these Solutions
- 00:19:07really quickly
- 00:19:09and there is a easy synchronization
- 00:19:12between the server and the client due to
- 00:19:15the code base
- 00:19:18and then finally because the structure
- 00:19:21of node.js is Javascript if you are
- 00:19:25making the pivot from being a front-end
- 00:19:27web developer to node.js it's just going
- 00:19:30to make it a lot easier for you to pick
- 00:19:32up node.js because you have that common
- 00:19:35language of JavaScript and on top of
- 00:19:37that JavaScript is the world's most
- 00:19:39popular scripting language
- 00:19:42so let's talk about some of the
- 00:19:44differences between angular node.js and
- 00:19:47so and the reason why this question may
- 00:19:49come up is the person interviewing you
- 00:19:51is seeing whether or not you do know the
- 00:19:54difference between a front-end framework
- 00:19:57and a back-end framework and this is one
- 00:20:00of those questions where you can go well
- 00:20:02there are differences but the
- 00:20:04differences are because they complement
- 00:20:06each other so angular is a front-end
- 00:20:08development framework whereas node.js is
- 00:20:11a server side and framework are the
- 00:20:14differences though between the actual
- 00:20:15Frameworks themselves is that angular is
- 00:20:17written in typescript which is a
- 00:20:19modification of JavaScript node.js is
- 00:20:22written in C and C plus plus
- 00:20:24anger is used for building out single
- 00:20:27play client-side web applications and so
- 00:20:31that's a keyword there is client-side
- 00:20:34whereas node.js is about building out
- 00:20:37fast and scalable server-side Network
- 00:20:40applications uh so uh again the two
- 00:20:44complement each other
- 00:20:46uh angular splits web applications into
- 00:20:48the MVC and model view control
- 00:20:50components whereas node.js generates a
- 00:20:54lot of database crazy it does more than
- 00:20:56that as well but you can think of
- 00:20:58node.js as that glued to your database
- 00:21:02let's talk a little bit about when
- 00:21:04you're connecting to a database with
- 00:21:06node.js and so you're going to probably
- 00:21:08be asking what is the most popular
- 00:21:11database used with node.js and there are
- 00:21:15a couple mongodb is largely the most
- 00:21:18popular nosql cross-platform database
- 00:21:21MySQL is also very popular and that's a
- 00:21:24more traditional relational database
- 00:21:27you would go with mongodb for really
- 00:21:30more modern solutions when you're
- 00:21:33looking at creating an application
- 00:21:34that's going to really scale into just
- 00:21:37managing masses and masses of data that
- 00:21:42has to be created red updated and
- 00:21:46deleted very very quickly
- 00:21:50for some of the other popular libraries
- 00:21:53that you use for node.js express.js is a
- 00:21:56very popular one and I really like
- 00:21:58working with express.js allows me to
- 00:22:00build out web applications really
- 00:22:02quickly more importantly it allows me to
- 00:22:05build out apis very quickly and which
- 00:22:08you know apis are essentially web
- 00:22:10applications themselves but being able
- 00:22:12to do that very quickly with a framework
- 00:22:14like express.js is very useful uh
- 00:22:17Mongoose is an application that makes
- 00:22:19connecting to a database really
- 00:22:22easy so here is an example of express.js
- 00:22:26which is a in itself really a flexible
- 00:22:28but a solution that you can do lots with
- 00:22:31and Mongoose which is a more focused
- 00:22:34solution which allows you know to you
- 00:22:37make it easier to connect to your
- 00:22:39databases
- 00:22:41so you know what are the pros and cons
- 00:22:43of working with node.js there's lots of
- 00:22:46ways we explain this earlier on that you
- 00:22:47can actually build out applications that
- 00:22:50run on the cloud why would you you know
- 00:22:53what's uh the pros and cons so a pro is
- 00:22:56that node.js is extremely faster
- 00:23:00processing thing an event based model uh
- 00:23:03it really is fast I can't is if you have
- 00:23:06something that is a very heavy
- 00:23:08computational task it's not so good at
- 00:23:11that now I will caveat that this is that
- 00:23:14node.js is getting better all the time
- 00:23:17and so you might have to be provide an
- 00:23:20example of what a very heavy
- 00:23:22computational task is and that may be uh
- 00:23:25calculating a risk on an insurance
- 00:23:28application against many many variables
- 00:23:32that maybe something that's seen as
- 00:23:34computationally very heavy but what you
- 00:23:36can do in that example is you can then
- 00:23:38offload the task to another Solution
- 00:23:42that's designed for it and use apis to
- 00:23:44pass the data back and forth
- 00:23:46Pro JavaScript is used for building out
- 00:23:50your applications with node.js great
- 00:23:53lots of people know JavaScript
- 00:23:56a restriction and again this is evolving
- 00:23:59as JavaScript itself evolves is that
- 00:24:02when you do a callback you may end up
- 00:24:05doing lots of nested callbacks
- 00:24:07um if you're doing something that's very
- 00:24:09complicated again another way around the
- 00:24:12con and so this is one of the things
- 00:24:13that I always look for is if you have a
- 00:24:16blocker or a barrier
- 00:24:18how do you get around that barrier and
- 00:24:21so for instance when you're talking uh
- 00:24:23to your recruiter
- 00:24:25you can say look the reason why I use
- 00:24:27node.js is that it's fast it's event but
- 00:24:29it's driven I can use JavaScript there
- 00:24:32are some challenges and but what I do to
- 00:24:35get around those challenges are and
- 00:24:36that's where you can say that you know
- 00:24:38you may run the complex script off and
- 00:24:41you may write that in net or Java or PHP
- 00:24:45and then use an API to do the response
- 00:24:48back into node.js so you get the
- 00:24:50benefits of Both Worlds but minimize the
- 00:24:53investment in having to manage a complex
- 00:24:56environment such as Java versus a
- 00:24:59relatively simple environment with
- 00:25:01node.js the node package manager makes
- 00:25:04it extremely easy to access just an
- 00:25:07awful lot of functionality with over 50
- 00:25:11000 packages there's a package for that
- 00:25:13so from being able to have a tool that
- 00:25:18creates unique identifiers that you
- 00:25:20might need to have for generating
- 00:25:22content that gets posted into a database
- 00:25:24through to being able to connect to
- 00:25:27databases through you know to running so
- 00:25:30many different solutions and the npm
- 00:25:32package manager with its access to so
- 00:25:34many different packages makes it great
- 00:25:36for
- 00:25:38um getting access to all that content
- 00:25:39now Khan is working with relational
- 00:25:43databases with node.js isn't as easy as
- 00:25:46a nosql database now you can do it and
- 00:25:50there are ways around that and what I
- 00:25:53would do when this question comes up is
- 00:25:55always kind of pivot to say hey this is
- 00:25:58how you can actually then get around
- 00:26:00building out that application
- 00:26:05designed for streaming huge amounts of
- 00:26:07data in and out a con is that node.js is
- 00:26:11single threaded and so it can be CPU
- 00:26:13intensive but again there are ways
- 00:26:15around that and a good way around that
- 00:26:17is scaling Your solution and elastic
- 00:26:20environments such as the cloud
- 00:26:22so what is the command used to import an
- 00:26:25external library and so to import an
- 00:26:28external Library the command is the
- 00:26:30require command so an example we have
- 00:26:33here is uh you can assign a variable and
- 00:26:36the variable is going to be for HTTP and
- 00:26:38you're going to then require the HTTP
- 00:26:41service and that means that the
- 00:26:44application itself won't run unless the
- 00:26:46external Library the HTTP library is
- 00:26:49installed
- 00:26:50okay so those were our introductory uh
- 00:26:53questions for node.js this kind of pivot
- 00:26:55and take a look at the intermediate
- 00:26:58questions that you would be asked
- 00:27:00so what does event driven programming
- 00:27:03mean so event driven programming means
- 00:27:06that if something happens something else
- 00:27:08will happen in response so for instance
- 00:27:10if you click a mouse that Mouse click is
- 00:27:13an event that means something has to
- 00:27:15respond to that event just think of it
- 00:27:18as cause and effect it's just the basic
- 00:27:20motion of physics so that's what event
- 00:27:23driven programming means
- 00:27:25you also look at it as a callback
- 00:27:28function so that when an element is
- 00:27:31executed something will happen in
- 00:27:33response
- 00:27:35so what is an event Loop in node.js so
- 00:27:39an event Loop in node.js is when you do
- 00:27:41an asynchronous call and what that
- 00:27:45essentially means is that you are
- 00:27:47sending out data and then a non-blocking
- 00:27:50input output from node.js is pulling
- 00:27:54data back in
- 00:27:56what is an event emitter in node.js so
- 00:28:01an event meta has really two areas of
- 00:28:03focus one is that it manages uh the
- 00:28:06classes that hold all the objects uh
- 00:28:08within your event and we have an example
- 00:28:11of this on the right hand side and then
- 00:28:14whenever an event actually is thrown the
- 00:28:17functions are then called on that event
- 00:28:19synchronously so for instance we have in
- 00:28:22our example on the right hand side we
- 00:28:25create an event and then we have the
- 00:28:28functions and that executed in a series
- 00:28:31from that event
- 00:28:34so let's talk about the API functions in
- 00:28:37node.js so there are two types one is an
- 00:28:40asynchronous non-blocking function and
- 00:28:43the second is a synchronous blocking
- 00:28:46function and the difference between the
- 00:28:47two of them is asynchronous is that
- 00:28:49there is no structure to the order if I
- 00:28:52have the API is resolved synchronous
- 00:28:56means that when the feedback from the
- 00:28:58API is received you have to execute the
- 00:29:01response in a series for how the
- 00:29:05response is sent to you
- 00:29:07so what is a package Json file so the
- 00:29:12package Json file is at the heart of our
- 00:29:15node.js package when we actually will
- 00:29:18initialize a solution a folder to be in
- 00:29:21node.js package
- 00:29:24you'll find that the package itself
- 00:29:25holds all of the metadata that's
- 00:29:28particular to the project you're working
- 00:29:30on such as project name version
- 00:29:33requirements it is you have to have it
- 00:29:35installed in the root of the directory
- 00:29:37for the project and again look at any of
- 00:29:42the videos that we have on nodejs we do
- 00:29:44have demonstrations within those videos
- 00:29:47that actually then go through and break
- 00:29:49out how to create that root package and
- 00:29:54you'll see how you can actually then go
- 00:29:55ahead and update the instructions or the
- 00:29:58metadata within the package so here we
- 00:30:01have an example of what that metadata
- 00:30:03looks like so again this kind of
- 00:30:05continues that question of what is a
- 00:30:07packet Json file and you may be asked
- 00:30:09you know what is the metadata and why is
- 00:30:12it important and the metadata is a basic
- 00:30:16Json collection of pairing of key
- 00:30:21details such as name version description
- 00:30:23and then and the custom version that you
- 00:30:26put so for instance under name you could
- 00:30:29create a name for your project there
- 00:30:30can't be any spaces what is the version
- 00:30:33and the description and what is the main
- 00:30:36or starting path and for the solution
- 00:30:39typically that would be index.js but it
- 00:30:42could be anything.js but index.js is
- 00:30:46typical simply because
- 00:30:48index.html is the starting point for a
- 00:30:51typical web application
- 00:30:53so how would you use a URL module in
- 00:30:57node.js
- 00:30:59so with a URL module what it allows you
- 00:31:01to do is really two things one is that
- 00:31:03it provides the resolution passing of a
- 00:31:07URLs for Utilities in your application
- 00:31:10and then it allows you to extend your
- 00:31:14module with built-in Solutions and split
- 00:31:17up the web address into a readable
- 00:31:19format
- 00:31:20so in this example we have the URL and
- 00:31:25the response it would would give for
- 00:31:28that URL which will then be a year and
- 00:31:32month and it'll be in a readable format
- 00:31:35so they would read out as 2020 and then
- 00:31:39the month
- 00:31:41so what is express.js and you've heard
- 00:31:44me mentioned this a couple of times in
- 00:31:45the video and we actually have a
- 00:31:46separate video on express.js
- 00:31:49um I would express.js is a web
- 00:31:51application framework that allows you to
- 00:31:52build out Web Solutions for both mobile
- 00:31:56and traditional desktop right inside of
- 00:32:00node.js so it's very easy to use
- 00:32:03being able to install and web.js is as
- 00:32:06simple as requiring Express to be
- 00:32:08installed in the example that we have
- 00:32:10here on the screen it's a full solution
- 00:32:13of showing how to actually build out a
- 00:32:16solution with web.js so in this example
- 00:32:19you start off the first two lines
- 00:32:22required Express to be installed and the
- 00:32:25store comes from node packet manager
- 00:32:27then we have a simple application that
- 00:32:29will then send to the browser window a
- 00:32:33hello world message confirming that
- 00:32:35Express is up and running and then the
- 00:32:39third block of content starting with
- 00:32:40vars server actually will Define the
- 00:32:44port where your application is going to
- 00:32:46run so in this instance the port is
- 00:32:49going to run on localhost and the port
- 00:32:54will be Port 8081 and so you can
- 00:32:57actually go to localhost colon 8081 and
- 00:33:00when you do that that will trigger the
- 00:33:02Apple application that will forward up
- 00:33:05the message hello world and it's all
- 00:33:07coming from express.js
- 00:33:10so what are streams in node.js so
- 00:33:14streams are objects that allow you to
- 00:33:17read and write data continuously back
- 00:33:20and forth within your application and
- 00:33:22there's really four different types of
- 00:33:24streams there's readable writable duplex
- 00:33:27and transform
- 00:33:31the readable one stream through which
- 00:33:33data can be read
- 00:33:35the writable streams that you can
- 00:33:37actually write to a duplex is a stream
- 00:33:40where it is both readable and writable
- 00:33:44and transform our streams that can be
- 00:33:47manipulated the data while it is being
- 00:33:50read or written
- 00:33:53so how do you update and delete a
- 00:33:56dependency so say for instance we want
- 00:33:59to install something like Express so if
- 00:34:02you wanted to install Express what you
- 00:34:04would do is you would just write them
- 00:34:06inside of your project you want to go to
- 00:34:09terminal window and write in the command
- 00:34:12npm install Express
- 00:34:15if you want to update the dependencies
- 00:34:19within your node package manager to
- 00:34:21update all of them all you have to do is
- 00:34:23write the command npm update all
- 00:34:26dependencies
- 00:34:27and then if you want to explicitly
- 00:34:29uninstall a dependency such as
- 00:34:32express.js that's using the uninstall
- 00:34:35command and so that would again be going
- 00:34:38to terminal window and you would type
- 00:34:40npm uninstall Express
- 00:34:43and again it's really easy to create a
- 00:34:46simple server in node.js that will run a
- 00:34:49simple command the HTTP service is
- 00:34:52actually built into node.js you don't
- 00:34:55need to use express.js I typically use
- 00:34:57express.js when I want to do a web
- 00:34:59server because typically what I find is
- 00:35:01that I will want to go and do something
- 00:35:03more complicated but if you want to do
- 00:35:04something that illustrates just the core
- 00:35:07functionality within node.js you can
- 00:35:09actually just require the core HTTP
- 00:35:12service that actually comes as part of
- 00:35:14node.js and then you can actually then
- 00:35:16go ahead and tell it to create a service
- 00:35:20and then to write in plain text I
- 00:35:25command or text string such as in this
- 00:35:28case it'll be hello world and that would
- 00:35:30pop out and then the final line is to
- 00:35:33then listen that if you go to a web
- 00:35:36browser that's on
- 00:35:39port127.0.01 or localhost and go to Port
- 00:35:43colon 8080 once you actually go to that
- 00:35:47that will trigger this application and
- 00:35:48you'll get the text hello world pop up
- 00:35:51on your screen
- 00:35:52so explain synchronous and non-blocking
- 00:35:55apis in node.js
- 00:35:58so all the apis in node.js are
- 00:36:03asynchronous which means that they are
- 00:36:04non-blocking which means you can run
- 00:36:06them continuously and scale around that
- 00:36:10which is just fantastic it's one of the
- 00:36:12reasons why node.js can scale so fast
- 00:36:14and the eighth means that the apis can
- 00:36:17return data send data after it's been
- 00:36:19called and really increase the
- 00:36:22efficiency of events as they are
- 00:36:24triggered Within node.js
- 00:36:27so how do you implement async and you
- 00:36:30know JS and so the example that we have
- 00:36:32on the left hand side allows us to
- 00:36:35trigger async and it's using the async
- 00:36:38function and as you can see in this
- 00:36:40example it's actually something that can
- 00:36:42be done very quickly in this example
- 00:36:44we're actually making a command to logo
- 00:36:47host and an app that's running on Port
- 00:36:503000 and then depending on what we get
- 00:36:54if there's an error message and then
- 00:36:56we'll have error message go to the
- 00:36:58console log which is the terminal window
- 00:37:00and if we get a response to an
- 00:37:03application then we'll actually get a
- 00:37:06positive response which would be fetched
- 00:37:08response so again very quick and easy
- 00:37:12that you use the async function to be
- 00:37:15able to build out and you to get your
- 00:37:18asynchronous code
- 00:37:21so what is the purpose of module exports
- 00:37:24so a module export is a way to
- 00:37:27encapsulate your the entire code for a
- 00:37:30solution in a single package and a
- 00:37:32single file and then you can then share
- 00:37:35that with other developers so you're all
- 00:37:38working from the same environment
- 00:37:41so what is a callback function in
- 00:37:44node.js a callback function is
- 00:37:46essentially that once you run and you've
- 00:37:49triggered an event mongodb has
- 00:37:51consistently been ranked as one of the
- 00:37:53top five nosql database Management
- 00:37:54Systems so if you're someone who's
- 00:37:56applying for a position in database
- 00:37:58management roles you will almost
- 00:37:59certainly be working with mongodb at
- 00:38:01some point now whether you are upgrading
- 00:38:03your skills or interviewing for a
- 00:38:05database management position using
- 00:38:06mongodb it's a good idea to be familiar
- 00:38:09with the most frequently Asked mongodb
- 00:38:11interview questions and answers in the
- 00:38:13latter case it is beneficial for you to
- 00:38:15prepare for the interview so that you
- 00:38:17are not God off guard even if you are
- 00:38:19just interested in learning about
- 00:38:20mongodb for the sake of upskilling keep
- 00:38:23in mind that acquiring this kind of
- 00:38:25knowledge may lead you to looking for a
- 00:38:27better job which means you'll be facing
- 00:38:29an interview sooner on that note hey
- 00:38:31everyone welcome to simple Channel I
- 00:38:34hope you guys are doing good and staying
- 00:38:36safe in this tutorial we'll be
- 00:38:38discussing some specially curated
- 00:38:39mongodb interview questions that you
- 00:38:41must Master to crack your next interview
- 00:38:43so without any further Ado let's get
- 00:38:46started with today's topic well but
- 00:38:48before we begin if you're new to the
- 00:38:49channel and haven't subscribed already
- 00:38:51consider getting subscribed to our
- 00:38:52Channel simply code to stay updated with
- 00:38:54all the latest tech content and hit that
- 00:38:56Bell icon to never miss an update from
- 00:38:58us so let's get started with today's
- 00:39:00tutorial so firstly let us discuss the
- 00:39:02agenda now this mongodb interview
- 00:39:04question is intended to give you a
- 00:39:06general idea of the types of interview
- 00:39:08questions you might face now we'll be
- 00:39:10covering some theoretical as well as
- 00:39:12practical questions in this tutorial now
- 00:39:14typically recruiters begin with simple
- 00:39:16questions and gradually increase the
- 00:39:18difficulty level so in this mongodb
- 00:39:20interview questions tutorial we'll start
- 00:39:22with the basics and the progress to more
- 00:39:25complex questions now before we begin
- 00:39:27with the types of questions that are
- 00:39:28being asked here's a simple and quick
- 00:39:31tip for everyone who is watching this
- 00:39:33video now make sure you have the never
- 00:39:35give up attitude I know it's that time
- 00:39:37of the year where placements are going
- 00:39:39in a rampant way but and I know you
- 00:39:42might be giving interviews uh regularly
- 00:39:45and what if you uh didn't get an offer
- 00:39:48in one of the interviews from that so
- 00:39:50make sure you have that attitude of
- 00:39:52never give up and prepare for your next
- 00:39:54interview and whenever you're giving an
- 00:39:55interview make sure you are interactive
- 00:39:57being interactive is one of the most
- 00:39:59best or best way you can say in order to
- 00:40:02get uh you know hired by the recruiter
- 00:40:04so make sure you're conversing properly
- 00:40:06with the interviewer while asking the
- 00:40:08questions and finally behave
- 00:40:09professionally which is another key
- 00:40:12aspect while giving an interview so let
- 00:40:14us now discuss the first question which
- 00:40:16is the basic question which will be
- 00:40:18asked which is explain what is mongodb
- 00:40:20and its features so this is how you can
- 00:40:23answer mongodb is basically an open
- 00:40:25source cross platform nosql document
- 00:40:27oriented database management system now
- 00:40:30noise sculpin can be utilized as a
- 00:40:33substitute for traditional relational
- 00:40:34databases like SQL and MySQL which is
- 00:40:38dependent on the SQL language right so
- 00:40:40if you want to work with large data sets
- 00:40:43of distributed data then nosql databases
- 00:40:45may be quite supportive which are used
- 00:40:47to store large volumes of data in the
- 00:40:50form of documents which will offer the
- 00:40:52developers the flexibility to work with
- 00:40:54the evolving data models as there is no
- 00:40:56fixed schema in this now relational
- 00:40:58databases such as MySQL and Oracle store
- 00:41:01data in tables and rows right they are
- 00:41:04based on a branch of a theory known as
- 00:41:06relational databases now these
- 00:41:08relational databases are structured and
- 00:41:10tables can be linked with each other via
- 00:41:12a foreign key which is a property of
- 00:41:15relational database which is asset
- 00:41:17property which is being Satisfied by the
- 00:41:19relational database but whereas the
- 00:41:22mongodb being a documented oriented
- 00:41:25database it can handle only that sort of
- 00:41:28information and store as well as
- 00:41:30retrieve information from these
- 00:41:31documents only it provides the
- 00:41:33flexibility as well as scalability that
- 00:41:35you want with the querying and indexing
- 00:41:37according to your requirement this
- 00:41:39mongodb basically is based on json-like
- 00:41:42documents where we store all the
- 00:41:43information in that so this is how you
- 00:41:45can answer the question which is what is
- 00:41:47mongodb and its features
- 00:41:50well the next question is what are some
- 00:41:53alternative nosql databases to mongodb
- 00:41:56now we have various Alternatives from
- 00:41:58mongodb such as Cassandra Apache
- 00:42:00Cassandra is a free and open source
- 00:42:03distributed nosql database management
- 00:42:05system which is again similar to that of
- 00:42:07mongodb to handle large amounts of
- 00:42:09unstructured data across the servers
- 00:42:12providing High availability with no
- 00:42:14single point of failure Apache Cassandra
- 00:42:17is a database which can be a right
- 00:42:19choice when you need scalability and
- 00:42:21also High availability without
- 00:42:22compromising performance next we have
- 00:42:25redis redis is actually another uh
- 00:42:28popular nosql database which is an open
- 00:42:30source which is implemented as a
- 00:42:33distributed key value store with
- 00:42:34optional durability it can be also used
- 00:42:37as a catchy Adam message broker also we
- 00:42:40have other types other popular noise
- 00:42:42databases like Amazon Dyno dynamodb
- 00:42:45Apache headspace and neo4j now HPS again
- 00:42:48is an open source non-relational uh
- 00:42:50distributed database guys it is
- 00:42:52generally written in JavaScript and it
- 00:42:54is also developed as part of the Apache
- 00:42:56software foundation so these are some of
- 00:42:59the examples and can be used in
- 00:43:01alternative to mongodb
- 00:43:03all right let us now move to the next
- 00:43:05question which is what type of nosql
- 00:43:08database is mongodb now in general we
- 00:43:11have four different types of categories
- 00:43:13when we talk about in which category
- 00:43:15mongodb comes under so basically we have
- 00:43:17key value column based document database
- 00:43:20and graph database now when I talk about
- 00:43:23key value these database store data as
- 00:43:25an index key and value pairs this
- 00:43:28database is stored data in a schema-less
- 00:43:30way example of a key value data store
- 00:43:33include Cassandra redis dynamodb and Etc
- 00:43:36next we have column based now column
- 00:43:39based or column store type of database
- 00:43:41is the one where these databases are
- 00:43:44designed to store data as Columns of
- 00:43:46data rather than as rows as data if it
- 00:43:49stores in a row type of data it becomes
- 00:43:51a traditional which is not a noise
- 00:43:53database right so again example of a
- 00:43:56column store databases are hbase even
- 00:43:58Cassandra comes under the column based
- 00:44:01as well next we have the document data
- 00:44:03database which is actually the type of
- 00:44:06nosql database that we are looking for
- 00:44:07which is mongodb now document databases
- 00:44:10had designed to store documents with
- 00:44:12each document having a unique key and
- 00:44:15popular document databases are couch
- 00:44:17base and mongodb and finally we also
- 00:44:19have a graph type of database where they
- 00:44:22are based on graph Theory so these
- 00:44:24databases are basically designed for
- 00:44:26data which needs to be represented as
- 00:44:28graphs so the data that is present in
- 00:44:31this sort of database is interconnected
- 00:44:33with multiple number of relationship
- 00:44:36between them in in the form of graphs
- 00:44:38and trees and a popular graph database
- 00:44:41is neo4j as well as big data so this is
- 00:44:45what mongodb is and it comes under the
- 00:44:48document database type of noise scale
- 00:44:50database the next question is how does
- 00:44:53mongodb store data now data in mongodb
- 00:44:56is stored in based on documents or the
- 00:44:58Json style data structures documents
- 00:45:01contain one or more fields and each
- 00:45:04field contains a value of a specific
- 00:45:06data type so mongodb stores data records
- 00:45:09as documents which are in the form of
- 00:45:11based on documents which are gathered
- 00:45:13together in collections so these
- 00:45:16documents as we said earlier has a sub
- 00:45:19specific data types including let's say
- 00:45:21arrays normal General data and these
- 00:45:24documents tend to share a similar
- 00:45:26structure which are organized as
- 00:45:28collection so you can say a group of
- 00:45:30documents are kept in a collection it
- 00:45:33may be helpful to think of documents as
- 00:45:34in a comparison to the rows in a
- 00:45:37relational database so fields are
- 00:45:39similar to columns and collections are
- 00:45:41similar to tables in mySQL database
- 00:45:44which is again a no it's a relational
- 00:45:46database so this is how mongodb stores
- 00:45:48data the next question is mongodb is a
- 00:45:52schemailers database if yes how do you
- 00:45:55create schema in mongodb now the scheme
- 00:45:57of a data base describes the structure
- 00:45:59of the data to be stored right in a
- 00:46:01relational database the schema defines
- 00:46:03its tables its fields in each table and
- 00:46:07the relationship between each field and
- 00:46:09each table so if you take SQL as an
- 00:46:12example which is a schema based database
- 00:46:15right so in schema is defined by the
- 00:46:16tables and the fields that is the
- 00:46:19columns and rows that are present in it
- 00:46:20and the relation between them
- 00:46:23on the other hand we have mongodb now in
- 00:46:26documented oriented databases like
- 00:46:28mongodb data is stored in collections of
- 00:46:31key value pairs now given that Json is a
- 00:46:34schema free data structure and that
- 00:46:36mongodb depends on it it would be more
- 00:46:38accurate to say that it has a
- 00:46:40dynamically typed data so whenever you
- 00:46:42create an insert a document to create a
- 00:46:45schema it will automatically create one
- 00:46:47for you so whenever a document is added
- 00:46:49the database will automatically create
- 00:46:51the corresponding collection
- 00:46:53the next question is how is mongodb
- 00:46:56different from SQL and better than MySQL
- 00:46:58now mongodb is again a documented
- 00:47:01oriented nosql database which is used to
- 00:47:03store high volume of data and which
- 00:47:05needs to process your huge data in a
- 00:47:08quick session now it is a database that
- 00:47:10came into picture around the mid 2000s
- 00:47:13and it is again considered into the
- 00:47:15category of a nosql database whereas
- 00:47:17when you take SQL SQL is a programming
- 00:47:20language used to communicate with and
- 00:47:22manipulate relational databases for
- 00:47:24example MySQL now there are quite
- 00:47:28differences between both of these
- 00:47:30databases basis right being being one as
- 00:47:33a relational database the other being
- 00:47:34relational and non-relational database
- 00:47:37there are quite differences between them
- 00:47:38so for example if you take the structure
- 00:47:40in SQL data is represented in tables
- 00:47:43whereas the data is represented in
- 00:47:44documents and this further documents are
- 00:47:46stored in collections now schema again
- 00:47:49SQL has a predefined schema so whenever
- 00:47:51you are creating a table you need to
- 00:47:53predefine its schema whereas mongodb
- 00:47:56does not have the implications of
- 00:47:58specifying any schema before working on
- 00:48:00it so it has basically a dynamic schema
- 00:48:02next we have this scalability the data
- 00:48:05in SQL can be vertically scalable and
- 00:48:07when it comes to mongodb both horizontal
- 00:48:10and vertical scalable of scaling of data
- 00:48:12is possible when I talk about
- 00:48:14transactions SQL also supports Atomic
- 00:48:16operations and follows asset properties
- 00:48:18whereas Bongo DB does not have proper
- 00:48:21support for transactions and it follows
- 00:48:23cap theorem and finally the type of
- 00:48:25operations now some operations that we
- 00:48:29perform in relational databases like SQL
- 00:48:32for example SQL supports join operation
- 00:48:34whereas we don't have the same sort of
- 00:48:37join operation and mongodb so in this
- 00:48:40way mongodb is different from SQL and in
- 00:48:43some ways it is better than MySQL in
- 00:48:46terms of processing a lot of
- 00:48:47unstructured data and also has certain
- 00:48:49features like replication sharding and
- 00:48:53mapreduce and some of more critical
- 00:48:55features that are not present in MySQL
- 00:48:58well the next question is what are the
- 00:49:00different data models in mongodb now
- 00:49:03data models are categorized into two
- 00:49:05types the first one is embedded data
- 00:49:07model the next one is referent data
- 00:49:09model now if I talk about Emirate data
- 00:49:11model embedded documents capture
- 00:49:13relationship between data by storing
- 00:49:15related data in a single document
- 00:49:17structure whereas reference data models
- 00:49:20store the relationship between data by
- 00:49:23including any links or references from
- 00:49:25one document to another
- 00:49:27moving on to the next question the next
- 00:49:29question is how does indexing Works in
- 00:49:32mongodb now a good indexing strategy be
- 00:49:35it a relational database or a nosql
- 00:49:38database it is essential for ensuring
- 00:49:40that your database returns your results
- 00:49:42as quickly as possible now mongodb
- 00:49:45indexing is a special data structure on
- 00:49:47which the index is created to hold the
- 00:49:49data of a specific fields in a document
- 00:49:52now in the absence of indexing in
- 00:49:54mongodb there is a need to scan every
- 00:49:56collection which is basically a
- 00:49:58collection scan so mongodb indexes make
- 00:50:01it unnecessary to perform a collection
- 00:50:03scan which involves looking through
- 00:50:05every document in collection from
- 00:50:07matches to your query it also provides
- 00:50:09effective indexing strategy now any
- 00:50:11collection in mongodb can have one or
- 00:50:14more indexes and those indexes can be
- 00:50:16made on one or more multiple Fields And
- 00:50:18even through throughout a mongodb
- 00:50:20database so you need a good indexing
- 00:50:22strategy to quickly add let's say
- 00:50:24effectively access the data you required
- 00:50:27from it and it also provide search
- 00:50:28efficiency now indexing is a necessary
- 00:50:31operation in mongodb which will bring
- 00:50:33search efficiency in various execution
- 00:50:36of statements so this is how indexing
- 00:50:38Works in mongodb
- 00:50:41so moving on to the next question what
- 00:50:43is mongodb replication and sharding now
- 00:50:46if I talk about replication replication
- 00:50:48means duplicating the same data across
- 00:50:51multiple mongodb servers so the main use
- 00:50:53of replication is the data is available
- 00:50:56at an instant way that is high
- 00:50:58availability of data and it also
- 00:51:00supports data redundancy and multiple
- 00:51:03copies of of the data are being saved
- 00:51:06across servers and also it provides data
- 00:51:09recovery and backup options as well so
- 00:51:12in a nutshell you can say that database
- 00:51:13replication is the process of copying
- 00:51:16data from one database in one server to
- 00:51:20another database in another server
- 00:51:22ensuring that the same data is available
- 00:51:24on more than one mongodb server so again
- 00:51:28the main purpose of using replication is
- 00:51:30data redundancy and high availability so
- 00:51:33by keeping data several copies or
- 00:51:35replica stored on physically separate
- 00:51:37servers it will ensure that the data is
- 00:51:40protected and it is also accessible
- 00:51:43whenever we need and also by generating
- 00:51:45multiple copies of your data replication
- 00:51:47enables you to increase data
- 00:51:49availability which is also another
- 00:51:50important factor this is especially
- 00:51:52helpful if a server fails so in that
- 00:51:55case you can use the replication and
- 00:51:57finally you can also recover the data
- 00:52:00that is lost due to any uninterrupted or
- 00:52:02any hardware failure issues
- 00:52:05now if I talk about sharding sharding is
- 00:52:08also similar to that of replication but
- 00:52:10it is a method of Distributing data
- 00:52:12across multiple databases and mongodb
- 00:52:15supports this deployment of data with
- 00:52:18having large data sets and high
- 00:52:20throughput via sharding
- 00:52:22so let's take an example so you can give
- 00:52:24an example to the recruiter like this
- 00:52:27let's say I have a database having 2
- 00:52:29million users and it has a capacity
- 00:52:31which is 2 million records now what I'm
- 00:52:34doing is I'm basically Distributing the
- 00:52:36data across multiple databases and I'm
- 00:52:38storing different data in different
- 00:52:41databases now we have two machines which
- 00:52:43has one million user capacity and
- 00:52:45another one million user capacity
- 00:52:48so in this way you can add more and more
- 00:52:51multiple databases in order to store
- 00:52:53your data
- 00:52:55so by adding more capacity to a single
- 00:52:58server such as adding more memory and
- 00:53:00processing units or adding more RAM on a
- 00:53:02single server that can be done using
- 00:53:05sharding
- 00:53:06let us now to move on to the next
- 00:53:08question which is explain horizontal and
- 00:53:10vertical scaling now vertical scaling
- 00:53:12refers to adding more resources like CPU
- 00:53:15Ram or any hardware or hard drive disk
- 00:53:19space to your server which is again a
- 00:53:21database or an application server which
- 00:53:23is done on demand on the other hand
- 00:53:26horizontal scaling refers or involves
- 00:53:28adding more processing units or physical
- 00:53:30machines to your server or databases now
- 00:53:33mongodb which is a nosql database
- 00:53:36handles horizontal scaling through
- 00:53:37sharding so in a nutshell you can say
- 00:53:40that vertical scaling can be used in
- 00:53:41order to increase or decrease the
- 00:53:43capacity of existing Services whereas
- 00:53:45horizontal scaling adds more resources
- 00:53:47like virtual machines to your system to
- 00:53:50spread out the workload across them the
- 00:53:52next question is when should we embed
- 00:53:54one document with another so you should
- 00:53:56consider embedded document that is sub
- 00:53:58document whenever you rely on these four
- 00:54:02factors that is when the relationship is
- 00:54:04one to few that is it can be one two one
- 00:54:06too many but not one to one so for
- 00:54:09unlimited use case you should start
- 00:54:11considering separating sub documents
- 00:54:13into another collection the next
- 00:54:15situation is when retrieval is likely to
- 00:54:17happen together which will improve the
- 00:54:20performance in such case you can embed
- 00:54:22one document with another the next
- 00:54:24factor is when updates are likely to
- 00:54:26happen at the same time you can use this
- 00:54:29multi-document transaction by embedding
- 00:54:31data model and finally when the field is
- 00:54:34rarely updated in such case you can use
- 00:54:37the embedded document
- 00:54:39well let us now move on to the next
- 00:54:40question which is what are replica cells
- 00:54:43and explain primary and secondary
- 00:54:45replica sets in mongodb the process of
- 00:54:48replication as we discussed earlier is
- 00:54:51done via using replica sets in simple
- 00:54:54words it is a group of mongod processes
- 00:54:57to keep the same data across different
- 00:54:59servers now a replica set is basically a
- 00:55:03collection of related mongodb nodes
- 00:55:05which must have three notes at least now
- 00:55:08one of them must be a primary and the
- 00:55:10rest secondary ones and a replication
- 00:55:12structure can have up to 50 nodes so the
- 00:55:16main types of nodes that we have is
- 00:55:18primary and the secondary or you can
- 00:55:20call it them as primary and secondary
- 00:55:22replica sets now when I talk about
- 00:55:24primary replica set it is the primer is
- 00:55:27the member in the replica set that
- 00:55:29receives the write and read operations
- 00:55:31but read operations can be pointed out
- 00:55:33to secondary nodes changing the
- 00:55:35configuration at the moment to perform
- 00:55:37the query beside is the replica set can
- 00:55:40have only one primary node at most and
- 00:55:43talking about secondary the secondary is
- 00:55:45the node where the data is replicated to
- 00:55:48maintain a copy a replica set can have
- 00:55:50one or more secondary nodes and the
- 00:55:53clients cannot write data to secondary
- 00:55:55ones only they can read from them and if
- 00:55:58at all there is any failed node it works
- 00:56:01as a secondary node again until it is
- 00:56:03until a new primary node will be
- 00:56:06replaced with that so this is what a
- 00:56:09replica set means and the type of
- 00:56:11replica set which is the primary and
- 00:56:13secondary I hope you understood this
- 00:56:15so moving on to the next question which
- 00:56:17is what is the use of capped collections
- 00:56:21now the size of collection in mongodb is
- 00:56:23typically unrestricted right so the
- 00:56:25collection increases its size as more
- 00:56:27documents are being added to that now a
- 00:56:30capped collection is a special type of
- 00:56:32collection that has either a fixed
- 00:56:34number of documents in a collection or
- 00:56:36fixed number of elements so it creates
- 00:56:39new documents by overriding the oldest
- 00:56:42documents present in that collection so
- 00:56:44collections can have maximum size or
- 00:56:47document counts that prevent them from
- 00:56:49growing beyond the maximum threshold
- 00:56:51that is being allocated and all capped
- 00:56:54collections must specify a maximum size
- 00:56:56and may also specify a maximum document
- 00:56:59count only now mongodb removes older
- 00:57:02documents if a collection reaches the
- 00:57:04maximum size limit before it reaches the
- 00:57:06maximum document count so overall the
- 00:57:09structure and functionality of a capped
- 00:57:12collection supports high performance for
- 00:57:14credit operations like create read and
- 00:57:17delete so this is what cap collection
- 00:57:20says and some of it characteristics and
- 00:57:22why we use it
- 00:57:24let us now move on to the next question
- 00:57:25which is how can you store images videos
- 00:57:28and other large files now we often need
- 00:57:31to store files in our databases but
- 00:57:33mongodb sometimes or it doesn't let you
- 00:57:36store any file larger than 16 MB in a
- 00:57:39normal document so what you have to do
- 00:57:41instead mongodb has a functionality
- 00:57:43specifically for storing large files and
- 00:57:45it goes by the name gridfs yes you have
- 00:57:48heard it right grid FS is a driver
- 00:57:50specification for uploading and
- 00:57:52retrieval of mongodb files which are
- 00:57:54larger than 16 MP in order to store
- 00:57:56images videos and other large files it
- 00:58:00is one of the most popular
- 00:58:01specifications and it it has a size
- 00:58:04limit of more than 16 MB so you can
- 00:58:07store images videos that have size more
- 00:58:09than of 16 MB now chunks of files like
- 00:58:13be it and audio it update of PDF file or
- 00:58:16anything it is being streamed as a
- 00:58:18chunks so these are streamed into the
- 00:58:21database and each chunk is limited 255
- 00:58:25KB in this size this means that the last
- 00:58:28chunk is normally either equal to or
- 00:58:30less than 255 KB so whenever you read
- 00:58:32from grade FS the driver resembles all
- 00:58:35the chunks as needed this means that you
- 00:58:37can read sections of a file as per your
- 00:58:40query range
- 00:58:42so I hope you understood uh what is grid
- 00:58:44fs and what is the process to store
- 00:58:47images videos and other large files
- 00:58:49which is of more than 16 MB so basically
- 00:58:51the interviewer want to know that
- 00:58:53whether you are not familiar with the
- 00:58:55concept of grid FS so that is the reason
- 00:58:58he might ask you this question so you
- 00:59:00have to be well prepared for it
- 00:59:02well the next question is explain
- 00:59:03aggregation in mongodb mongodb
- 00:59:06aggregation process the data records
- 00:59:08during an aggregation operation and
- 00:59:10returns a single competent result just
- 00:59:13like any other operations that are
- 00:59:15performed in a relational database
- 00:59:16similar to that aggregation is also used
- 00:59:18in order to act on a group of values
- 00:59:21from multiple documents present in a
- 00:59:23collection to perform operations for
- 00:59:25this grouped values and return a single
- 00:59:27competed results now it actually groups
- 00:59:31multiple documents which applies an
- 00:59:33aggregation operation and it is
- 00:59:35basically returning as the particular
- 00:59:37value that we want from that operation
- 00:59:40now there are various ways on how you
- 00:59:42can perform aggregation we have three
- 00:59:44different ways of carrying the
- 00:59:46aggregation process in mongodb the first
- 00:59:48one is aggregation pipeline next we have
- 00:59:51mapreduce and finally we have single
- 00:59:53purpose aggregation so you can further
- 00:59:56explain each of these aggregation uh
- 00:59:58depending upon the interviewer's
- 01:00:00preference so basically I will
- 01:00:01irrigation process in mongodb is modeled
- 01:00:04on the concepts of data processing
- 01:00:06pipeline so multiple document enter the
- 01:00:09pipeline and then these documents are
- 01:00:11being transformed into the aggregated
- 01:00:13results next we have the map reduce as
- 01:00:16the name suggests it does to operation
- 01:00:17which is mapping and then reducing that
- 01:00:20operation so it will map each document
- 01:00:23and process along with one or more
- 01:00:25objects for each document and reduce
- 01:00:28phase in which output of map operations
- 01:00:31are being combined together and finally
- 01:00:33we have single purpose aggregation
- 01:00:35operation where these operations
- 01:00:37aggregate all the documents from a
- 01:00:39single collection in mongodb now even
- 01:00:42though they provide a simple access to
- 01:00:44the basic aggregation operations they
- 01:00:47lack the flexibility that are being
- 01:00:49provided by the aggregation Pipeline and
- 01:00:51map reduce operation
- 01:00:54so these are the three uh aggregation
- 01:00:57pipeline method which they go through
- 01:00:59first is basically the math stage which
- 01:01:01will filter the records or the documents
- 01:01:03we need to work with uh and next it
- 01:01:06performs the group operation which
- 01:01:08basically is the aggregation and finally
- 01:01:10it will sort the data so it will sort
- 01:01:12the resulting documents the way we
- 01:01:14require that is an ascending and
- 01:01:16descending order now just like uh any
- 01:01:19other operations given by aggregation in
- 01:01:21mongodb we also have five different
- 01:01:23types of operations that we can perform
- 01:01:25which is sum which will add up the
- 01:01:28values of every document next we have
- 01:01:30average which will complete the average
- 01:01:31value of every document and we have Min
- 01:01:34which returns a minimum value from a
- 01:01:36document and we have Max which will
- 01:01:38written the maximum value within a
- 01:01:40collection and finally we have Push
- 01:01:42which will add the value to an array in
- 01:01:44the document moving on to the next
- 01:01:46question what is mean by ID field in
- 01:01:49mongodb ide is the field that uniquely
- 01:01:52identifies a document present in the
- 01:01:54mongod EB collection so when you are
- 01:01:56trying to insert a new document into the
- 01:01:58database mongodb will automatically
- 01:02:02create a unique ID field which will have
- 01:02:05a unique value to its name now by
- 01:02:07default mongodb creates a unique index
- 01:02:09for the ID field during the creation of
- 01:02:12any collection and the ID field is
- 01:02:14always the first field in the document
- 01:02:16and if the server receives a document
- 01:02:18that does not have any ID field first
- 01:02:20then the server will move the field at
- 01:02:22the beginning and also ID field can be
- 01:02:25avoided in the document that you want to
- 01:02:27return by setting the value of the ID
- 01:02:29field as 0 in the query
- 01:02:32so what are some utilities for backup
- 01:02:34and restoring in mongodb now by default
- 01:02:38mongodb shell does not include any
- 01:02:40import export of data or even
- 01:02:42duplication or retrieval of uh data from
- 01:02:46other uh you know applications but
- 01:02:48however mongodb provides the utilities
- 01:02:51and database tools to take backup and
- 01:02:54perform the restore operations now
- 01:02:56mainly we have four type of backup and
- 01:02:58restoring options which are import
- 01:03:01export term and malware
- 01:03:04restore so you can use one of these
- 01:03:06utilities like Dom import export
- 01:03:10and restore to move your data in and out
- 01:03:13of your mongodb database now the most
- 01:03:15commonly used are mongodum and
- 01:03:18restore the mongodon utility creates a
- 01:03:20binary backup you know of a mongodb
- 01:03:22database the mongodom tool is the
- 01:03:25preferred method of dumping data from
- 01:03:27your Source mongodb deployment and if
- 01:03:29you're trying uh to restore the data
- 01:03:32that you have basically deleted or
- 01:03:34dumped you can use the Monger register
- 01:03:36in order to fetch back the data that you
- 01:03:39have dumped
- 01:03:42so the next question is can you explain
- 01:03:44about mapreduce process in mongodb
- 01:03:48mapreduce is basically a data processing
- 01:03:51Paradigm for condensing large volumes of
- 01:03:53data into useful aggregated results so
- 01:03:57basically mongodb provides the map
- 01:03:58reduce features for only aggregation
- 01:04:00purposes and generally there are two
- 01:04:03phases of the map reduce as you can see
- 01:04:05in the name which is mapping and
- 01:04:06reducing so in the first phase each
- 01:04:09document is processed and emits common
- 01:04:11and redundant part of the document to
- 01:04:13pass a unique record for the next phase
- 01:04:16and in the next phase all the unique
- 01:04:18part gets together and aggregated to
- 01:04:20produce a single result and finally we
- 01:04:23have a query here we'll pass the query
- 01:04:25to filter the resultant set so with the
- 01:04:28help of map reduce user can perform
- 01:04:30sorting filtering and document
- 01:04:32modification as per their need
- 01:04:35so moving on to the next question which
- 01:04:37is how does mongodb Ensure High
- 01:04:39availability of data
- 01:04:42in general High availability refers to
- 01:04:45the uh you know Improvement of a system
- 01:04:47or any applications availability by
- 01:04:49minimizing the downtime caused by
- 01:04:51routine maintenance or any hardware
- 01:04:54related uh you know issues so mongodb
- 01:04:57automatically stores copy sets and
- 01:04:59multiple copies of data distributed
- 01:05:01across servers and data centers now in
- 01:05:05general mongodb is one such database
- 01:05:07which can provide High availability for
- 01:05:09the users by using features like
- 01:05:11replication and sharding now in
- 01:05:13replication the replica sets help
- 01:05:15prevent website downtime using native
- 01:05:17duplication and automatic failures now
- 01:05:20mongodb has a great support for high
- 01:05:22availability without no thought through
- 01:05:25replication set but replica set is not
- 01:05:27enough for a production ready system
- 01:05:29that is it requires a bit of planning in
- 01:05:32order to deploy this so sometimes it
- 01:05:35might be an issue but in most of the
- 01:05:37cases if the system crashes or the
- 01:05:39hardware or software faces any issues uh
- 01:05:41you know ODB in the data mongodb helps
- 01:05:44you recover and backup your data in the
- 01:05:47system
- 01:05:49so the next question is what is the role
- 01:05:51of profiler in mongodb now so far we
- 01:05:54have discussed some of the basic to
- 01:05:56moderate uh level questions guys now
- 01:05:58from here on you will find some
- 01:06:00practical as well as you know advanced
- 01:06:02level questions so you might need to
- 01:06:05focus a little bit and even if you're
- 01:06:07not confident and if you don't know the
- 01:06:09answer which we are discussing now you
- 01:06:11can directly tell to the recruiter of
- 01:06:13the interviewer that you do not know the
- 01:06:16answer but you hope that you have an
- 01:06:17idea on this and you can work on that
- 01:06:19and you can get back to him so again
- 01:06:22let's get back to the question which is
- 01:06:23what is the role of profiler in mongodb
- 01:06:26now database profiler is used to collect
- 01:06:28information regarding the queries which
- 01:06:30are executed on an individual database
- 01:06:32instance so basically this uh profiler
- 01:06:36in mongodb database allows you to
- 01:06:37collect performance data about
- 01:06:39operations occurring on a mongodb
- 01:06:42instance
- 01:06:47the next question is can we use regular
- 01:06:49expressions in mongodb now in SQL we do
- 01:06:52have regular Expressions where we need
- 01:06:54uh where we write a query to find
- 01:06:57certain patterns that are present in our
- 01:06:59database table right in a similar way
- 01:07:02regular expressions are also used to
- 01:07:04match patterns in a document just like
- 01:07:06finding a pattern in an SQL tables so
- 01:07:09regular expression basically provides
- 01:07:11patterns a sequence of characters for
- 01:07:13matching and defining a search pattern
- 01:07:15and also retrieving an unidentified
- 01:07:17field using a certain pattern becomes
- 01:07:20easily within a document and querying a
- 01:07:22database in order to find a smaller
- 01:07:24subset of data within a collection we
- 01:07:27can use regular expression so regex
- 01:07:29operator in mongodb provides regular
- 01:07:32expression capabilities from pattern
- 01:07:34matching strings in the queries and the
- 01:07:36syntax is followed as DB dot collection
- 01:07:39name dot file mention the field name and
- 01:07:42mention the reex keyword and mention the
- 01:07:44pattern now the pattern can be of any uh
- 01:07:48of your choice
- 01:07:51so the next question is how do you
- 01:07:53search for documents in which a specific
- 01:07:55field has one or more values now you can
- 01:07:58say this is a bit of practical question
- 01:08:00guys the interviewer wants to know
- 01:08:02whether you are not uh whether or not
- 01:08:05you are comfortable and have an idea of
- 01:08:08using various operators in mongodb so
- 01:08:11you can use the DB dot collection file
- 01:08:13operation and also use a query operator
- 01:08:16which is dollar in in order to specify
- 01:08:18the field and the values that you want
- 01:08:20to retrieve or you want to search for
- 01:08:22inert document so for example I have
- 01:08:24given an example which says that in
- 01:08:26order to return all employees whose
- 01:08:29title is product manager or executive
- 01:08:31director in such case the query would be
- 01:08:34DB dot employees dot find mention the
- 01:08:37field which is title mention the uh in
- 01:08:39which is a query operator here mention
- 01:08:41the product manager and executive
- 01:08:43director which we are trying to find so
- 01:08:45if there is any record or the person who
- 01:08:49is associated associated with this title
- 01:08:51of product manager or executive director
- 01:08:54it will retrieve the record now we have
- 01:08:56a person name whose first name is Rahul
- 01:08:58and last name is Kumar whose ages 29 and
- 01:09:01title is product manager so this is how
- 01:09:04you can search for a document with a
- 01:09:06specific field which has one or more
- 01:09:08values
- 01:09:11so the next question is which command
- 01:09:13are used to insert single and multiple
- 01:09:15documents into a collection now we
- 01:09:18basically have two types of commands
- 01:09:20which is DB dot collection dot insert1
- 01:09:22which will insert a single document into
- 01:09:24a mongodb collection and it returns a
- 01:09:27document containing the inserted
- 01:09:28documents ID field and next we have the
- 01:09:31same uh command but the keyword changes
- 01:09:35which is insert mini which is insert a
- 01:09:37single or even multiple records uh into
- 01:09:40a mongodb collection again it returns a
- 01:09:43document containing each inserted
- 01:09:45document's ID
- 01:09:48well the next question is what is the
- 01:09:50difference between
- 01:09:51all and in operator in mongodb now both
- 01:09:55all and in operator are used to filter
- 01:09:57documents in a sub array based on a
- 01:10:00conditional statement so but there are
- 01:10:03some differences or subtle differences
- 01:10:05between all and in operator now when I
- 01:10:08talk about all operator all operator
- 01:10:10retrieves all the documents which
- 01:10:12contains a subset of the value we pass
- 01:10:14and this subset might be in any order
- 01:10:17but whereas in operator retrieves all
- 01:10:20the documents which contains the either
- 01:10:23of the values we pass
- 01:10:25moving on what is the next question is
- 01:10:28both rights and rates become faster when
- 01:10:31you add more slaves to replica set as
- 01:10:34the statement true or false explain the
- 01:10:36reason well this statement is false now
- 01:10:38a replica set can only have a primary uh
- 01:10:42at any particular time that is having a
- 01:10:44one master with other nodes the
- 01:10:46secondary nodes being slaves so all
- 01:10:49right operations are performed only on
- 01:10:51the master node read operations on the
- 01:10:53other hand can be performed on any
- 01:10:55instance which can be a slave or a
- 01:10:57master node so as a result adding more
- 01:11:00slaves to a replica set accelerates only
- 01:11:02reads operation and nods the and not the
- 01:11:05rights operation so the statement is not
- 01:11:09valid and it is a false statement we
- 01:11:11cannot uh you know write and read both
- 01:11:13uh operation when you add more slave to
- 01:11:16replica set
- 01:11:18the next question is what is Shard e and
- 01:11:21mention the components of mongodb
- 01:11:22sharded cluster now what is a short key
- 01:11:25chart key is used by mongodb to
- 01:11:27distribute the documents of a collection
- 01:11:29across charts now on charting a mongodb
- 01:11:32data set a Shard key is automatically
- 01:11:35created by default so the short key can
- 01:11:37be in the form of indexed field or
- 01:11:39indexed compound fields that will be
- 01:11:41used to distribute the data among the
- 01:11:43shots generally The Shard key is used to
- 01:11:46distribute the mongodb's collections
- 01:11:48documents across all the shots where the
- 01:11:50key consists of a single field or
- 01:11:52multiple fields in every document now
- 01:11:54the idea is to have multiple replica set
- 01:11:57with multiple primaries which would
- 01:11:59basically divide data and load it among
- 01:12:01themselves and each of these replica set
- 01:12:04is called as shard
- 01:12:06chat basically has three components
- 01:12:09which is basically Shard Mongoose and
- 01:12:13config serger all this together
- 01:12:15comprises of a mongodb sharded cluster
- 01:12:19now when I talk about Shard what is a
- 01:12:21Shard Shard contains a subset of the
- 01:12:24sharded data okay A Shard is basically a
- 01:12:28single mongodb server or a replica set
- 01:12:30that stores a partition of the
- 01:12:32application data that you have divided
- 01:12:34now next we have the mongos Mongoose
- 01:12:38router or the it is a router of
- 01:12:40operations now because each chart
- 01:12:42contains only part of the cluster data
- 01:12:45you need something to root operations to
- 01:12:47the appropriate charts that's where
- 01:12:49mongos comes in the Mongoose process is
- 01:12:52a router that directs all the reads
- 01:12:54writes and commands to the appropriate
- 01:12:57shard in this way mongos provides client
- 01:13:00with a single point of contact with the
- 01:13:02cluster and finally we have config
- 01:13:04servers now Mongo's process are
- 01:13:07basically a durable should be durable
- 01:13:10that means it must be in a position to
- 01:13:13store the metadata in order to properly
- 01:13:16manage the cluster right which we have
- 01:13:19formed with the short key so that's the
- 01:13:21job of the config server this metadata
- 01:13:24includes the cluster configuration the
- 01:13:27location of each database collection and
- 01:13:30the particular range of data there so
- 01:13:32this is what basically shark Key is and
- 01:13:35multiple components that are included in
- 01:13:37the mongodb sharded cluster
- 01:13:41so moving on to the next question which
- 01:13:43is the joint plus is a key feature of
- 01:13:45relational database systems what is the
- 01:13:47mongodb equivalent if any and are there
- 01:13:50any limitations now whenever we hear
- 01:13:52about joints we have like different
- 01:13:55operations like inner join after join
- 01:13:58left join and uh you know cross join so
- 01:14:02similarly we have a question here that
- 01:14:04means if we talk about no SQL that means
- 01:14:06we do not have no joints that means we
- 01:14:08do have joints or we do not have joints
- 01:14:10that's the main question but the thing
- 01:14:12is we have a joint equivalent in mongodb
- 01:14:15also which is the lookup operator which
- 01:14:18is a significant disadvantages that is
- 01:14:21it does not work in charted collection
- 01:14:23right so it's worth noting that rather
- 01:14:25than looking for a direct equivalent to
- 01:14:27join mongodb developers often simply
- 01:14:30denormalize the data and which
- 01:14:33eliminates the need for a join you know
- 01:14:35operation in a mongodb database so in a
- 01:14:38nutshell you can say it performs an
- 01:14:40outer join to a collection in the same
- 01:14:43database to filter the documents from
- 01:14:45The Joint collection for processing now
- 01:14:47the lookup operator adds a new array
- 01:14:50field to each input document and this
- 01:14:52new array field contains the matching
- 01:14:54documents from The Joint collection
- 01:14:59so the next question is mention some
- 01:15:00pros and cons of normalizing data in
- 01:15:03mongodb database now normalizing data is
- 01:15:06a key factor in relational database but
- 01:15:08what about mongodb now updated documents
- 01:15:11is fast for raw normalized data and it
- 01:15:13is relatively so slower for denormalized
- 01:15:16data well on the other hand reading
- 01:15:18documents is fast in denormalized data
- 01:15:20and slower for normalized data so
- 01:15:23denormalized data is hard to keep in
- 01:15:25sync and takes up more space so rdbms
- 01:15:28generally have this organic support
- 01:15:31for normalization and a lot of data to
- 01:15:34be managed as a separate entity whereas
- 01:15:36nosql dbmss like mongodb do not have
- 01:15:40this active support for normalization
- 01:15:44so the next question is what are the
- 01:15:46advantages of using mongodb now there
- 01:15:49are various advantages of using mongodb
- 01:15:51for example it is an open source DB that
- 01:15:54is it is ready readily available for
- 01:15:56everyone to download and perform the
- 01:15:58operations right away and it is also
- 01:16:00easy to use the syntax is also user
- 01:16:03friendly just like SQL it is also highly
- 01:16:06flexible which allows you to store and
- 01:16:08work on different data types and allows
- 01:16:11you to store unstructured data of
- 01:16:12different types in one or more documents
- 01:16:14and the security is also a Paramount
- 01:16:17Feature for any user right so mongodb
- 01:16:19provides Advanced security features as
- 01:16:22well and we also talked about high
- 01:16:24availability in our previous question
- 01:16:25and it also has reliable indexing for a
- 01:16:28faster retrieval of data it has a
- 01:16:30flexible schema design unlike the uh
- 01:16:33predefined schema in relational
- 01:16:35databases so this flexible or the
- 01:16:38dynamic schema design allows you to meet
- 01:16:40the ever-changing conditions of the Big
- 01:16:42Data applications uh you know with the
- 01:16:45vast amount of data that is being
- 01:16:46incorporated into the documents you can
- 01:16:49have a better Edge on the data if you're
- 01:16:52working on large scale applications then
- 01:16:54moment DB can be a great choice for you
- 01:16:56with all this it also gives you high
- 01:16:59performance which is another key feature
- 01:17:01of mongodb and one of its greatest
- 01:17:04advantage of a noiseql database
- 01:17:06and that gives us the last question of
- 01:17:09our interview question uh which is what
- 01:17:12are some applications of mongodb now
- 01:17:15mongodb being a nosql database is widely
- 01:17:18popular in many uh sectors nowadays and
- 01:17:21some of the major applications or
- 01:17:23real-time use case of mongodb is it is
- 01:17:26used in iot which is internet of things
- 01:17:28with the world rapidly uh advancing in
- 01:17:32uh you know in technology iot plays a
- 01:17:34crucial role and it is important that we
- 01:17:37uh as a user you know have these uh
- 01:17:41intention to store that data and have
- 01:17:44that data predicted in any sense now the
- 01:17:46data is only getting larger and larger
- 01:17:49and we also heard this phrase that data
- 01:17:52is the new oil so with the coming in the
- 01:17:54coming years the data is exceptionally
- 01:17:56going to rise and we need mongodbs to
- 01:17:59store this uh huge or huge volumes of
- 01:18:02data into our uh databases right so it
- 01:18:06is one of the applications of mongodb
- 01:18:08and we also have mobile applications and
- 01:18:10in order to perform real-time analysis
- 01:18:12and we also have uh it is also used in
- 01:18:15catalog management content management
- 01:18:17and for product management and various
- 01:18:20others sectors as well now companies
- 01:18:23also like to use noise databases uh
- 01:18:26because of its flexible uh design and
- 01:18:30the need of you know storing data
- 01:18:33without any uh predefined schema makes
- 01:18:36it a best nosql database like companies
- 01:18:41like eBay Shutterfly New York Times
- 01:18:44Verizon and many other big companies use
- 01:18:47uh mongodb nowadays and also the one of
- 01:18:50the real life application or use cases
- 01:18:54the best example you can give is aadhar
- 01:18:56card which is India's unique
- 01:18:58identification which is uh based on
- 01:19:00identifying a person's you know identity
- 01:19:04so the other uses mongodb to store this
- 01:19:06massive amounts of demographic and
- 01:19:08biography biometric data of over more
- 01:19:11than 1.5 billion uh you Indian users so
- 01:19:15other users mongodb in order to store
- 01:19:17the images QR code details you know the
- 01:19:21personal details of the user in its
- 01:19:23database so these are some of the
- 01:19:25applications of well that's a wrap on a
- 01:19:27moon stack interview question we hope
- 01:19:30you found this video informative and
- 01:19:32helpful by now you should have a good
- 01:19:34understanding of the different types of
- 01:19:36interview questions frequently Asked in
- 01:19:38month interviews
- 01:19:40and if you are interested in learning
- 01:19:41more about web development there are
- 01:19:44plenty of resources available online you
- 01:19:46can also check out our website for more
- 01:19:48information on full stack web
- 01:19:50development training courses and
- 01:19:52certifications
- 01:19:53thank you for watching and we'll see you
- 01:19:56next time
- 01:20:00hi there if you like this video
- 01:20:03subscribe to the simply learned YouTube
- 01:20:04channel and click here to watch similar
- 01:20:07videos turn it up and get certified
- 01:20:09click here
- MERN stack
- MongoDB
- Express.js
- React.js
- Node.js
- web development
- database management
- full stack development
- virtual DOM
- JSX