0% found this document useful (0 votes)
7 views

Milan vashisth web development and ADAS

The document contains an assignment by a student named Milan Vashisth, detailing tasks related to HTML5, JavaScript, SQL, and database management. It includes code snippets for an HTML page embedding a YouTube video and audio file, a JavaScript program for calculating factorials using both recursive and iterative approaches, and SQL queries for creating a library database. Additionally, it discusses data independence in DBMS architecture, covering logical and physical data independence, their benefits, and challenges.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

Milan vashisth web development and ADAS

The document contains an assignment by a student named Milan Vashisth, detailing tasks related to HTML5, JavaScript, SQL, and database management. It includes code snippets for an HTML page embedding a YouTube video and audio file, a JavaScript program for calculating factorials using both recursive and iterative approaches, and SQL queries for creating a library database. Additionally, it discusses data independence in DBMS architecture, covering logical and physical data independence, their benefits, and challenges.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 14

Name:- Milan vashisth

Student Id:- 10776048

Sem:- MCA 2nd


Enrollment No:- 241MCA1/0838

Assignment:- 2 Lab
Q1- Develop a simple HTML5 page that embeds a YouTube video and
an audio file. Use CSS3 to style the media elements with custom
controls, backgrounds, and borders.

Answer:- Code

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>You Tube </title>
<style>
Body
{
font-family: Arial, sans-serif;
background-color: #f0f0f0;
margin: 0;
padding: 0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
.media-container
{
background-color: #f4f1f8;
border: 2px solid #060101; border-radius: 10px;
padding: 20px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
text-align: center;
}
.media-container h1
{
margin-bottom: 20px;
color: #333333;
}
.video-wrapper,
.audio-wrapper {
margin-bottom: 20px;
}
.video-wrapper iframe
{
border: 3px solid #007BFF;
border-radius: 8px;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
}
.audio-wrapper audio
{
width: 100%;
border: 2px solid #28a745;
border-radius: 8px;
background-color: #f8f9fa;
}
.footer
{
font-size: 0.9em;
color: #666666;
}

</style>
</head>
<body>
<div class="media-container">
<h1>You Tube</h1>
<!-- Embedded YouTube Video -->
<div class="video-wrapper"> <iframe
width="560"
height="315"
src="https://www.youtube.com/embed/dQw4w9WgXcQ"
title="YouTube video player"
frameborder="0"
allow="accelerometer; autoplay; clipboard-write; encrypted-media;
gyroscope; picture-in
picture"
allowfullscreen>
</iframe>
</div>
<!-- Embedded Audio File -->
<div class="audio-wrapper">
<audio controls>
<source src="Bapu.mp3" type="audio/mpeg">
Your browser does not support the audio element.
</audio>
</div>
<div class="footer">Designed with HTML5 and CSS3</div>
</div>
</body>
</html>
Q2 - Write a JavaScript program that uses recursion to calculate the
factorial of a given number. Compare the recursive approach with an
iterative approach and explain the differences.

Answer:- JavaScript Program for Factorial Calculation

// Recursive Approach

function factorialRecursive(n)
{
if (n < 0)
{
return "Invalid input"; // Factorial is not defined for negative numbers
}
if (n === 0 || n === 1)
{
return 1; // Base case
}
return n * factorialRecursive(n - 1); // Recursive call
}
// Iterative Approach
function factorialIterative(n)
{
if (n < 0)
{
return "Invalid input"; // Factorial is not defined for negative numbers
}
let result = 1;
for (let i = 2; i <= n; i++)
{
result *= i; // Multiplying the result by each number up to n
}
return result;
}

// Testing the functions

const number = 5;
console.log(`Factorial of ${number} using recursion: $
{factorialRecursive(number)}`);
console.log(`Factorial of ${number} using iteration: $
{factorialIterative(number)}`);
Certainly! Below is a JavaScript program that calculates the factorial of a
given number using both a recursive approach and an iterative approach.
Along with that, I will explain the differences between these two methods.

JavaScript Program for Factorial Calculation

```javascript
// Recursive Approach

function factorialRecursive(n)
{
if (n < 0)
{
return "Invalid input"; // Factorial is not defined for negative numbers
}
if (n === 0 || n === 1)
{
return 1; // Base case
}
return n * factorialRecursive(n - 1); // Recursive call
}

// Iterative Approach

function factorialIterative(n)
{
if (n < 0)
{
return "Invalid input"; // Factorial is not defined for negative numbers
}
let result = 1;
for (let i = 2; i <= n; i++)
{
result *= i; // Multiplying the result by each number up to n
}
return result;
}

// Testing the functions

const number = 5;
console.log(`Factorial of ${number} using recursion: $
{factorialRecursive(number)}`);
console.log(`Factorial of ${number} using iteration: $
{factorialIterative(number)}`);

``` Explanation:- Recursive Approach


1. Base Case: The recursion needs a base case to stop; in this case, when
`n` is 0 or 1, the factorial is defined as 1.

2. Recursive Call: For any number greater than 1, it multiplies `n` by the
factorial of `n-1`. This breaks the problem down into smaller sub problems.

3. Stack Depth: Each function call adds to the call stack, so for large values
of `n`, there could be a risk of a stack overflow due to too many frames in
the call stack.

 Iterative Approach

1. Looping: The iterative solution uses a loop which continues until it has
multiplied all integers from 2 to `n`.

2. Resource Usage: This approach generally uses less memory compared


to the recursive approach since it does not add multiple frames to the call
stack.

3. Performance: In many cases, the iterative approach can be slightly more


efficient because it avoids the overhead of multiple function calls.

 Differences:-

1. Memory Usage: Recursion uses more memory because each recursive


call consumes stack space. In contrast, iteration uses a single space in
memory since it operates within a loop.

2. Readability: Recursive solutions can be more readable and easier to


express mathematically, as they closely follow the defined mathematical
definition of factorial.

3. Performance: Iterative approaches can be more efficient for large values


of `n`, as recursive functions can lead to function call overhead and
potentially stack overflow errors.

4. State Handling: Recursive functions maintain state through function


parameters, while iterative functions maintain state through loop variables.
Both approaches provide valid solutions, and the choice of which to use can
depend on the specific use case, the size of `n`, and performance
considerations.
Q3 – Compare and contrast Online Transaction Processing (OLTP)
and Online Analytical Processing (OLAP) systems. Provide examples
of scenarios where each type of system.

Answer:- Online Transaction Processing (OLTP) vs. Online Analytical


Processing (OLAP)

Online Transaction Processing (OLTP) and Online Analytical Processing


(OLAP) are two distinct approaches to managing and analysing data in a
database. While both systems involve processing large amounts of data,
they have different design principles, purposes, and use cases.

Online Transaction Processing (OLTP):-

Purpose:- OLTP is designed to support the day-to-day operations of an


organization, handling a high volume of transactions, such as customer
orders, payments, and inventory updates.

Characteristics:-

1. High-Performance: OLTP systems prioritize speed and efficiency to


handle a large number of concurrent transactions.

2. Low Latency: Transactions are processed quickly to ensure real-time


updates.

3. Data Integrity: OLTP systems enforce data consistency and accuracy.

4. ACID Compliance: Follows the Atomicity, Consistency, Isolation, and


Durability properties to ensure transactional integrity.

Examples of OLTP Systems:-

1. Banking Systems: Processing customer transactions, account updates,


and payment settlements.

2. E-commerce Platforms: Handling online orders, payments, and inventory


management.

2. Point-of-Sale (POS) Systems: Processing sales transactions in retail


environments.

Online Analytical Processing (OLAP):-

Purpose:- OLAP is designed for data analysis, providing insights into


business operations by aggregating and analyzing large datasets.
Characteristics:-
1. Data Aggregation: OLAP systems focus on aggregating data to support
business decision-making.

2. Data Analysis: Enables data exploration, filtering, and reporting.

3. Data Visualization: Provides interactive visualizations to facilitate


understanding complex data relationships.

4. Query Performance: Optimized for complex queries and ad-hoc analysis.

Examples of OLAP Systems:-

1. Business Intelligence (BI) Tools: Reporting, dashboards, and data


visualization platforms like Tableau, Power BI, or QlikView.

2 Data Warehousing: Centralized repositories for storing historical data for


analysis and reporting.

Criteria OLTP / OLAP

Purpose:-

Transactional operations Data analysis

Data Integrity

High priority on data consistency

Performance High-speed transaction processing

Complex query optimization.

Use Cases Customer order.

Payments.

Inventory updates.

System Design Real-time updates.

data visualization.

business intelligence .

Q4- Write SQL queries to create a database for a library system,


including tables for Books, Authors, Members, and Loans. Specify the
data types for each column and define primary and foreign
keys.Provide example queries for inserting, updating, and deleting
records in the database.

Answer:- In this answer we will have to create a library database with four
main tables: Books, Authors, Members, and Loans. Each table has a unique
primary key and foreign key referencing other tables as needed.

Code:-

Create the database

CREATE DATABASE LibraryDatabase;

Use the library database

USE LibraryDatabase;

Create Books table

CREATE TABLE Books ( BookID INT PRIMARY KEY IDENTITY(1,1),


Title VARCHAR(255) NOT NULL, Publisher VARCHAR(255) NOT NULL,
ISBN VARCHAR(20) NOT NULL, Genre VARCHAR(50) NOT NULL );

Create Authors table

CREATE TABLE Authors ( AuthorID INT PRIMARY KEY IDENTITY(1,1),


FirstName VARCHAR(100) NOT NULL, LastName VARCHAR(100) NOT
NULL );

Create Members table

CREATE TABLE Members ( MemberID INT PRIMARY KEY IDENTITY(1,1),


FirstName VARCHAR(100) NOT NULL, LastName VARCHAR(100) NOT
NULL, Email VARCHAR(255) NOT NULL );

Create Loans table

CREATE TABLE Loans ( LoanID INT PRIMARY KEY IDENTITY(1,1),


MemberID INT NOT NULL FOREIGN KEY REFERENCES
Members(MemberID), BookID INT NOT NULL FOREIGN KEY
REFERENCES Books(BookID), LoanDate DATE NOT NULL, ReturnDate
DATE NOT NULL DEFAULT '2023-12-31' );

Inserting records into the Books table


INSERT INTO Books (Title, Publisher, ISBN, Genre) VALUES ('The Great
Gatsby', 'Charles Scribner''s Sons', '1234567890', 'Classic'), ('To Kill a
Mockingbird', 'J.B. Lippincott & Co.', '2345678901', 'Classic'), ('1984',
'Secker & Warburg', '3456789012', 'Science Fiction');

Inserting records into the Authors table

INSERT INTO Authors (FirstName, LastName) VALUES ('F. Scott',


'Fitzgerald'), ('Harper', 'Lee'), ('George', 'Orwell');

Inserting records into the Members table

INSERT INTO Members (FirstName, LastName, Email) VALUES ('John',


'Doe', '[email protected]'), ('Jane', 'Doe', '[email protected]'),
('Alice', 'Smith', '[email protected]');

Updating a record in the Books table

UPDATE Books SET Title = 'The Great Gatsby (Updated)' WHERE BookID
= 1;

Deleting a record in the Loans table

DELETE FROM Loans WHERE LoanID = 1;

Inserting a record into the Loans table

INSERT INTO Loans (MemberID, BookID, LoanDate, ReturnDate) VALUES


(1, 1, '2023-01-01', '2023-01-31');

Retrieving all records from the Books table

SELECT * FROM Books;

Retrieving all authors with more than one book

SELECT * FROM Authors a JOIN Books b ON a.AuthorID = b.AuthorID


GROUP BY a.AuthorID HAVING COUNT(a.AuthorID) > 1;

Explanation:-The above SQL code creates a library database with four


main tables:-

1) Books

2) Authors
3) Members

4) Loans.

The Books table has columns for BookID, Title, Publisher, ISBN, and
Genre.

The Authors table has columns for AuthorID and FirstName and LastName.

The Members table has columns for MemberID, FirstName, LastName, and
Email.

The Loans table has columns for LoanID, MemberID (foreign key
referencing MemberID in Members), BookID (foreign key referencing
BookID in Books), LoanDate, and ReturnDate.

Data Types:-

The data types used are: INT for whole numbers (e.g., BookID, MemberID,
AuthorID, LoanID) VARCHAR for variable-length strings (e.g.Title,
Publisher, ISBN, Genre, FirstName, LastName, Email) DATE for dates
(e.g., LoanDate, ReturnDate).

Primary Keys:-Primary keys are used to uniquely identify each record in a


table. The primary keys used are:-

BookID in the Books table.

AuthorID in the Authors table.

MemberID in the Members table.

LoanID in the Loans table.


Q5- Explain the concept of data independence in DBMS architecture.
Provide examples of how logical and physical data independence can
be achieved in a database system. Discuss the benefits and
challenges associated with implementing data independence.

Answer:- Data Independence in DBMS Architecture Data independence is


a fundamental concept in Database Management System (DBMS)
architecture that refers to the ability of a database to continue functioning
properly even. when changes are made to the physical storage or logical
structure of the data. It ensures that the application programs and users do
not need to be modified when the database schema or physical storage
layout changes.

Types of Data Independence:-

There are two types of data independence:-

1. Logical Data Independence:- This refers to the ability of a database to


adapt to changes in the conceptual schema without affecting the application
programs that use the data. It ensures that the logical structure of the data
remains unchanged, even if the physical storage layout or database
management system changes.

2. Physical Data Independence:- This refers to the ability of a database to


adapt to changes in the physical storage layout or storage device without
affecting the application programs that use the data.

Logical Data Independence:-

Data Normalization: Normalization helps to reduce data redundancy and


improve data integrity, making it easier to modify the database schema
without affecting the application programs.

View Mechanism: Views provide a virtual representation of data, allowing


users to access data without being aware of the underlying physical
structure.

Abstraction: Abstraction techniques, such as abstract data types and


object-oriented programming, help to hide the implementation details of
data storage and retrieval.

Physical Data Independence: -

Data Redundancy: Redundancy helps to ensure that data is still accessible


even if the physical storage device fails.
Data Replication: Replication involves maintaining multiple copies of data
on different storage devices, ensuring that data is always available.

Storage Hierarchy: Using a hierarchical storage system, with primary


storage (RAM) and secondary storage (hard disk), helps to ensure that
critical data is always accessible.

Benefits and Challenges:-

Benefits:-

Improved flexibility: Data independence allows for changes to be made to


the database schema or physical storage layout without affecting
application programs.

Increased scalability: Data independence enables databases to grow and


adapt to changing requirements without requiring major modifications. 
Reduced maintenance costs: Data independence reduces the need for
frequent updates and maintenance, saving time and resources.
Challenges:

Complexity: Achieving data independence can be complex, requiring


significant expertise and resources.

Performance overhead: Data independence can introduce performance


overhead, particularly if not implemented efficiently.

Data consistency: Ensuring data consistency across different storage


devices and systems can be challenging. In conclusion, data independence
is a crucial concept in DBMS architecture that enables databases to adapt
to changing requirements without affecting application programs. Achieving
logical and physical data independence requires careful planning, expertise,
and resources. While there are benefits to data independence, such as
improved flexibility and scalability, there are also challenges, including
complexity, performance overhead, and ensuring data consistency.

You might also like