ARREAR Updated FSWD Ans Key 26.06.2023
ARREAR Updated FSWD Ans Key 26.06.2023
PART A
Page 1 of 12
5. What is sharding in MongoDB?
Sharding in MongoDB is a method for distributing data across multiple machines to support
deployments with very large data sets and high throughput operations. It allows MongoDB
to horizontally scale, ensuring that the system can handle increased load and store large
amounts of data efficiently. 2
Key Components
Shards
Config Servers
Query Routers (mongos)
6. Create a simple server in Node js that returns Hello World.
Creating a Collection
db.createCollection(name, options)
Example
db.createCollection("myCollection") 2
Dropping a Collection
db.collectionName.drop()
Example
db.myCollection.drop()
7. Define TypeScript.
TypeScript is a statically typed superset of JavaScript that adds optional type checking and 2
other features to the language.
8. How does an Angular application work?
Structure of an Angular Application
Bootstrapping the Application
Components and Templates
Data Binding 2
Services and Dependency Injection
Routing
HTTP Client
Lifecycle Hooks
Page 2 of 12
10. Name the features of RESTful web services.
Stateless 2
Client-Server Architecture
Uniform Interface
Cacheable
Layered System
PART B
11. (a) (i)
Explain web development framework with suitable block diagram. Also explain
the components of it.
(Or)
11 (b) (i) Describe the Model-View-Controller (MVC) architecture, including its features. (13)
Components, and how it works with an example.
Page 3 of 12
Controllers
Routes
Templates
Middleware
Validation
Block Diagram :
def blog_list(request):
posts = Post.objects.all()
return render(request, 'blog_list.html', {'posts': posts})
12. (a) (i) Examine the concept of callbacks in Node.js. Provide a brief explanation of (8)
passing additional parameters to callback functions with an example.
Callbacks are a fundamental concept in Node.js and are used to handle asynchronous
operations. A callback is a function passed into another function as an argument, which
Page 4 of 12
is then invoked inside the outer function to complete some kind of routine or action.
This allows Node.js to continue executing other code while waiting for the
asynchronous operation to complete, thus providing non-blocking behavior.
When defining a callback function, you can include additional parameters to pass data.
These parameters can be passed along when invoking the callback.
const fs = require('fs');
// Define a function that reads a file and passes additional parameters to the callback
if (err) {
return callback(err);
// Invoke the callback with the file data and the additional parameter
});
if (err) {
} else {
Page 5 of 12
(ii) Provide an overview of the built-in modules that come with Node.js and their (5)
purposes.
http:
https:
Similar to the http module but provides functionalities for HTTPS servers and
clients.
path:
12 (b) (i) Determine how Node.js supports working with JSON data. Provide a brief 8
explanation of converting JSON to JavaScript objects and vice versa, along with a
code example for each.
To convert JSON data (which is a string) into JavaScript objects, you can use the
JSON.parse() method. This method parses a JSON-formatted string and converts it
into a JavaScript object.
To convert JavaScript objects into JSON format (as a string), you can use the
JSON.stringify() method. This method serializes a JavaScript object into a JSON-
formatted string. 5
(ii) Elaborate the process of compressing and decompressing data using the Zlib
module in Node.js.
To compress data using the zlib module, you typically use the zlib.deflate() or
zlib.gzip() methods. These methods take input data as a Buffer or string and return a
compressed Buffer or stream.
Page 6 of 12
Using zlib.deflate()
The zlib.deflate() method compresses the input data using the deflate algorithm.
To decompress data in Node.js using the zlib module, you use the zlib.inflate() or
zlib.gunzip() methods. These methods take compressed data as input and return the
decompressed data as a Buffer or stream.
Using zlib.inflate()
The zlib.inflate() method decompresses data that was compressed using the deflate
algorithm.
13. (a) (i) Carry out the below mentioned operations in collections by using the MongoDB (10)
shell.
a) Display
b) Create
c) Delete
Display (Read)
Connect to MongoDB:
Mongo
Switch to Database:
use your_database_name
db.your_collection_name.find()
Create (Insert)
Ensure you are connected to MongoDB and have selected the appropriate database (use
your_database_name).
Insert Documents:
Use the insertOne() or insertMany() methods to insert documents into the collection.
Page 7 of 12
insertOne(): Inserts a single document into the collection.
Delete (Remove)
Ensure you are connected to MongoDB and have selected the appropriate database (use
your_database_name).
Delete Documents:
Use the deleteOne() or deleteMany() methods to delete documents from the collection.
NoSQL (Not Only SQL) is a broad term used to describe databases that provide a
flexible approach to storing and managing data that is not necessarily structured in the
traditional rows and columns like relational databases (SQL databases). NoSQL
databases are designed to handle large volumes of unstructured, semi-structured, or
structured data, making them suitable for modern applications that require scalable and
high-performance data storage solutions
(b) (i) Analyze the db object and the methods associated with it. (10)
Accessing Collections:
Syntax: db.collectionName
Page 8 of 12
Listing Collections:
Method: db.getCollectionNames()
Switching Database:
Querying Documents
Inserting Documents:
Method: db.collection.insertOne(document) or
db.collection.insertMany(documents)
(ii) Articulate the various roles of the users in MongoDB.
(3)
Built-in Roles
Custom Roles
Roles in Action:
Managing Access
Ensuring Security
Supporting Compliance
14. (a) (i) Analyze the various Key Components of Angular with a neat diagram. (8)
Page 9 of 12
(ii) What is interface? Explain the use of interface in TypeScript with suitable (5)
example.
In TypeScript, an interface is a way to define a contract for objects. It specifies the
structure that an object must adhere to, including the types of properties and methods it
should have. Interfaces are purely a compile-time construct and do not have any impact
on the generated JavaScript code; they are used solely for type-checking during
development.
(b) (i) Apply the various binding available in Angular to dynamically add or (10)
remove CSS class from an element.
These techniques include property binding ([class]), interpolation ({{}}), and structural
directives like ngClass and ngStyle. Each approach has its use case depending on the
complexity of conditions and the type of data you need to bind.
Using Property Binding ([class.class-name])
Using Interpolation ({{expression}})
Using ngClass Directive
Using ngStyle Directive (3)
(ii) Explain the syntax for defining routes in Express.
Basic Route Syntax
Routes in Express are defined using the app.METHOD(PATH, HANDLER) syntax,
where:
app is an instance of Express.
15. (a) (i) Outline the React component lifecycle, and what are the three main phases that (13)
components go through?
In React, the component lifecycle refers to the series of stages that a component goes
through from its initialization to its removal from the DOM
Mounting
Updating
Unmounting
Additional Lifecycle Methods (Deprecated)
componentWillMount()
componentWillReceiveProps()
componentWillUpdate()
Page 10 of 12
15 (b) (i) Explain the concept of passing data between in React the this.props.children (10)
technique with an example.
Using this.props.children
Ex:
// Card.js
import React from 'react';
Page 11 of 12
3) Create the Server
4) Create a Signup Form (Frontend)
5) Run the Application
6) Test the Application
Page 12 of 12