0% found this document useful (0 votes)
8 views65 pages

23121 Ritesh

This document is a practical file for the Software Lab course at Maharshi Dayanand University, detailing various programming exercises related to Advanced Database Systems, Data Warehousing, Operating Systems, and Shell Programming. It includes tasks such as implementing DDL, DML, and TCL commands, creating shell scripts, and performing database operations like joins and triggers. The file is submitted by a student and outlines the structure and content of the practical exercises for the academic session 2023-2025.

Uploaded by

Ritesh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views65 pages

23121 Ritesh

This document is a practical file for the Software Lab course at Maharshi Dayanand University, detailing various programming exercises related to Advanced Database Systems, Data Warehousing, Operating Systems, and Shell Programming. It includes tasks such as implementing DDL, DML, and TCL commands, creating shell scripts, and performing database operations like joins and triggers. The file is submitted by a student and outlines the structure and content of the practical exercises for the academic session 2023-2025.

Uploaded by

Ritesh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 65

MAHARSHI DAYANAND UNIVERSITY

ROHTAK, HARYANA (124001)

Department of Computer Science & Applications

PRACTICAL FILE BASED ON


SOFTWARE LAB : 20MCA22CL2
(PAPER CODE : 20MCA22C2,20MCA22C3 )
(Session : 2023-2025)

Submitted By Submitted To
Ritesh Dr. Pooja Mittal
MCA , 2nd sem Dr. Preeti Gulia
Roll: 23121
ADVANCE DATABASE SYSTEMS & DATA WAREHOUSE

SR NO. Program Page no. Remarks


1. Run and implement DDL Commands 5-8
2. Run and implement DML Commands 9-10
3. Run and implement TCL Commands 11-13
4. Run and implement Numeric Functions
1. Absolute
2. Power 14-16
3. Round
4. Squareroot
5. Exponential
5. Run and implement String Functions
1. Lower
2. Upper
3. Init char 17-19
4. Substring
5. Instring
6. ASCII
6. Run and implement Aggregate Function
1. Min
2. Max 20-22
3. Count
4. Average
7. Perform the following exercises:
1. Order by
2. Group by 23-25
3. Where
4. And or

8. Pattern matching and range searching 26-29


9. Joins 30-35
10. Triggers 30-38
11. Constraints 39-40
OPERATING SYSTEMS AND SHELL PROGRAMMING
Sr.no Program
Page.no Remarks
1. Run and implement 5 utilities
1.File handling
2.Process utility 41-52
3.Text Processing
4.Disk Utility
5.Network utility
2. Write a shell Script to Enter your name
,your course name and your roll no in
the following ways 53-53
1.Output on different lines read-p
2.output on same line
3. Write a shell Script to enter and display
names of any ten student of your class 54-54
by using single variable .
4. Write a shell Script to accept 4 integer
from the user and print its sum 55-55
,average and product.
5. Write a shell Script to find the largest
among three given number and also 56-56
smallest.
6. Write a shell Script to extract a
Substring from the given string 57-56
according to user’s choice
7. Write a shell Script to generate 58-59
Fibonacci series.
8. Write a shell Script to find whether 60-60
given number is palindrome or not.
9. Write a shell Script to print alternate
given digits from an integer entered by 61-62
the user.
10. Write a shell Script to count number of
words ,character and special from the 63-64
given text.
11. Write a shell Script to find an element 64-65
from an array
1. Write Data Definition Language(DDL) commands to:
a) Create a table
b) Alter the table
c) Truncate the table
d) Drop the table
e) Rename the table

1.Create table
2. Alter the table

3. Truncate the table


4. Rename the table

5. Drop the table


2. Create a table shown below and use Data Manipulation
Language Command to Insert, Update and Delete Records
from the Table.

Insert
Update

Delete
3. Run and implement numeric functions
1.Absolute

2. Power
3.round

4.squareroot
5.exponential
4. Run and implement string functions
1)lower

2)upper

3)initchar
4)substring

5)instring
6)ascii
5. Run and implement aggregate functions

1)min

2)max
3)count

4)average
7. Perform the following exercises

1)orderby

2)groupby
3)where
5)and / or
8. Pattern matching and range searching

Pattern Matching with LIKE:


Range Searching:
9. Consider the two tables below:
a. Write a query to perform Inner Join and show the ‘names
and ‘age’ of students enrolled in different courses where
Student.ROLL_NO = StudentCourse.ROLL_NO
b. Write a query to perform Left Outer Join and
showStudent.NAME,StudentCourse.COURSE_ID where
Student.ROLL_NO = StudentCourse.ROLL_NO
c. Write a query to perform Right Outer Joinand
showStudent.NAME,StudentCourse.COURSE_ID where
Student.ROLL_NO = StudentCourse.ROLL_NO
Write a query to perform Full Joinand
showStudent.NAME,StudentCourse.COURSE_ID where
Student.ROLL_NO = StudentCourse.ROLL_NO.

Table: Student

Table: StudentCourse
a. Write a query to perform Inner Join and show the ‘names’ and ‘age’ of
students enrolled in different courses where Student.ROLL_NO =
StudentCourse.ROLL_NO
b. Write a query to perform Left Outer Join and
showStudent.NAME,StudentCourse.COURSE_ID where
Student.ROLL_NO = StudentCourse.ROLL_NO

c. Write a query to perform Right Outer Joinand


showStudent.NAME,StudentCourse.COURSE_ID where
Student.ROLL_NO = StudentCourse.ROLL_NO

d. Write a query to perform Full Joinand


showStudent.NAME,StudentCourse.COURSE_ID where Student.ROLL_NO =
StudentCourse.ROLL_NO.
10. Creating a Database Schema
AIM:- Create the following database schema for Student table
FIE TYPE NU KEY DEFA EXTRA
LD LL ULT
Tid Int(4) NO Prim NULL Auto-
ary Increment
Nam Varchar(2 Yes NULL
e )
Subj Int(2) Yes NULL
1
Subj Int(2) Yes NULL
2
Subj Int(2) Yes NULL
3
Tota Int(2) Yes NULL
l
Per Int(2) Yes NULL

a. Create a trigger in the student database in which whenever subjects


marks are entered, before inserting this data into the database, trigger
will compute values Student.total = Student.subj1 + Student.subj2
+ Student.subj3 and Student.per = Student.total * 60 / 100 and
insert with the entered values.
b. Create statement level trigger and Row level trigger.
c. How the trigger can be updated and deleted i.e., execution of PL/SQL
block for updation and deletion of trigger.
d. Apply Before, After and instead of mechanism at the time of
creation and updation of trigger.

CREATE A TABLE STUDENTT:


a)

B)STATEMENT LEVEL TRIGGER:


ROW LEVEL TRIGGER:
B)
C)AFTER
BEFORE:
INSTEAD OF:
11. Creating Constraints
AIM:- Creation of tables with different constraints and how the tables are
referenced with each other.
Solution: The NOT NULL constraint enforces a column to NOT accept NULL values.

Unique: SQL UNIQUE Constraint on create table or alter table


SQL PRIMARY KEY on CREATE TABLE or alter table
1. Run and explain any five utility in Linux Environment
for the following :-
(a) File handling
1. ls: List directory contents.
• Example: ls

• Explanation: Lists files and directories in the current directory with


detailed information.

2. Touch: Create a new file


• Example: touch first.txt

• Explanation : Touch command is used for create a new empty file


3. cp: Copy files and directories.
• Example: cp file1.txt file2.txt

• Explanation: Copies file1.txt to file2.txt.

4. cat: Use for view the file


• Example : cat text.txt

• Explanation: Text.txt file open and show’s its content


5. rm: Remove files or directories.
• Example: rm first.txt

• Explanation: Deletes file.txt.

(b) Process utilities


1) ps: Report a snapshot of the current processes.
a) Example: ps aux

b) Explanation: Shows a list of all processes running on the system.


2) top: Display and update sorted information about processes.
a) Example: top

b) Explanation: Shows real-time information about processes and their resource


usage.

3) kill: Send a signal to a process.


a) Example: kill 3908 PID

b) Explanation: Sends a SIGKILL signal to process with PID PID, forcing it to


terminate.
4) pgrep: List processes based on name or other attributes.
a) Example: pgrep -l firefox

b) Explanation: Lists the PIDs and names of processes matching firefox.

5) pkill: Send a signal to a process based on name or other attributes.


a) Example: pkill -SIGTERM process_name

b) Explanation: Sends a SIGTERM signal to processes matching process_name.


(c) Text processing

1) grep: Search text using patterns.


a) Example: grep 'pattern' file.txt

b) Explanation: Searches for pattern in file.txt and prints matching lines.

2) sed: Stream editor for filtering and transforming text.


a) Example: sed 's/old/new/' file.txt

b) Explanation: Replaces old with new in first.txt.


3) awk: Pattern scanning and processing language.
a) Example: awk '{print $1}' file.txt

b) Explanation: Prints the first field of each line in file.txt.

4) cut: Remove sections from each line of files.


a) Example: cut -d',' -f1 file.csv

b) Explanation: Extracts the first field from a comma-separated file.


5) sort: Sort lines of text files.
a) Example: sort first.txt

b) Explanation: Sorts the lines of first.txt alphabetically.

(d) Disk utilities


1) df: Report file system disk space usage.
a) Example: df -h

b) Explanation: Shows disk space usage in a human-readable format.


2) du: Estimate file space usage.
a) Example: du -sh directory/

b) Explanation: Shows the total size of the directory/.

3) fdisk: Partition table manipulator for Linux.


a) Example: fdisk -l /dev/sda

b) Explanation: Lists partition information for the /dev/sda disk.

4) mkfs: Build a Linux file system.


a) Example: mkfs.ext4 /dev/sdb1
b) Explanation: Creates an ext4 file system on the /dev/sdb1 partition.
5) badblocks: Search a device for bad blocks.
a) Example: badblocks -v /dev/sdc
b) Explanation: Checks for bad blocks on the /dev/sdc device.

(e) Network utilities

1) ifconfig: Configure a network interface.


a) Example: ifconfig eth0

b) Explanation: Displays information about the eth0 network interface.


2) ping: Send ICMP ECHO_REQUEST to network hosts.
a) Example: ping google.com

b) Explanation: Sends ICMP packets to google.com to check connectivity.

3) netstat: Print network connections, routing tables, interface statistics, etc.


a) Example: netstat -tuln

b) Explanation: Shows listening TCP and UDP connections.


4) traceroute: Print the route packets trace to network host.
a) Example: traceroute google.com

b) Explanation: Shows the path packets take to reach google.com.

5) hostname: Prints or sets the system's host name.


2. Write a Shell Script to enter your NAME, COURSE and
RollNo.
(a) Output on different lines.
(b) Output on same line.

#!/bin/bash

# Output on different lines


echo "Enter your name:"
read name
echo "Enter your course:"
read course
echo "Enter your roll number:"
read rollno

echo "Name: $name"


echo "Course: $course"
echo "Roll No: $rollno"

# Output on the same line


echo -n "Enter your name: "
read name
echo -n "Enter your course: "
read course
echo -n "Enter your roll number: "
read rollno

echo "Name: $name, Course: $course, Roll No: $rollno"


Output
3. Write a Shell Script to enter and display name of any
10 student of your class by using single variable.

#!/bin/bash

# Array to store student names


students=()

# Function to enter student names


enter_student_names() {
echo "Enter the names of 10 students:"
for ((i=0; i<10; i++))
do
echo -n "Student $((i+1)): "
read name
students+=("$name")
done
}
# Function to display student names
display_student_names() {
echo "Student names:"
for name in "${students[@]}"
do
echo "$name"
done
}
# Main program
enter_student_names
display_student_names

Output
4. Write a Shell Script to accept 4 integers from the user
and print it’s Sum, Average, and Product.

#!/bin/bash

# Prompt the user to enter 4 integers


echo "Enter four integers: "
read num1 num2 num3 num4

# Calculate the sum


sum=$((num1 + num2 + num3 + num4))

# Calculate the average


average=$(echo "scale=2; $sum / 4" | bc)

# Calculate the product


product=$((num1 * num2 * num3 * num4))

# Print the results


echo "Sum: $sum"
echo "Average: $average"
echo "Product: $product"

Output
5. Write a Shell Script to find largest and smallest among
3 given numbers.

#!/bin/bash

# Prompt the user to enter three numbers


echo "Enter three numbers: "
read num1 num2 num3

# Assume num1 is both largest and smallest initially


largest=$num1
smallest=$num1

# Compare num2 with largest and smallest


if [ $num2 -gt $largest ]; then
largest=$num2
fi
if [ $num2 -lt $smallest ]; then
smallest=$num2
fi

# Compare num3 with largest and smallest


if [ $num3 -gt $largest ]; then
largest=$num3
fi
if [ $num3 -lt $smallest ]; then
smallest=$num3
fi

# Print the largest and smallest numbers


echo "Largest: $largest"
echo "Smallest: $smallest"
Output
6. Write a Shell Script to extract a substring from the
given string according to user choice.

#!/bin/bash

# Prompt the user to enter a string


echo "Enter a string: "
read input_string

# Prompt the user for the start index


echo "Enter the start index (0-based): "
read start_index

# Prompt the user for the length of the substring


echo "Enter the length of the substring: "
read substring_length

# Extract the substring


substring=${input_string:start_index:substring_length}

# Print the extracted substring


echo "Substring: $substring"

Output:-
7. Write a Shell Script to generate a Fibonacci series.

#!/bin/bash

# Function to generate Fibonacci series


fibonacci() {
n=$1
a=0
b=1
echo "Fibonacci series up to $n terms:"
for ((i=0;i<n;i++))
do
echo -n "$a "
fn=$((a + b))
a=$b
b=$fn
done
echo ""
}

# Prompt the user for the number of terms


echo "Enter the number of terms for Fibonacci series:"
read num_terms

# Call the function with user input


fibonacci $num_terms

Output:-
8. Write a Shell Script to find whether given number is
palindrome or not.

#!/bin/bash

# Function to check if a number is palindrome


is_palindrome() {
num=$1
reverse=0
original_num=$num

while [ $num -gt 0 ]


do
remainder=$((num % 10))
reverse=$((reverse * 10 + remainder))
num=$((num / 10))
done

if [ $original_num -eq $reverse ]


then
echo "$original_num is a palindrome"
else
echo "$original_num is not a palindrome"
fi
}

# Prompt the user to enter a number


echo "Enter a number:"
read number

# Call the function with user input


is_palindrome $number

Output:-
9. Write a Shell Script to print alternate digits from an
integer enter by the use.

#!/bin/bash

# Function to print alternate digits


print_alternate_digits() {
num=$1
length=${#num}

echo "Alternate digits from $num are:"


for (( i=0; i<length; i+=2 ))
do
digit=${num:i:1}
echo -n "$digit "
done
echo ""
}

# Prompt the user to enter an integer


echo "Enter an integer:"
read number

# Call the function with user input


print_alternate_digits $number

Output:-
10.Write a Shell Script to count number of words,
characters, and special symbols from the given string.

#!/bin/bash

# Function to count words, characters, and special symbols


count_text_stats() {
text=$1

# Count words
words=$(echo "$text" | wc -w)

# Count characters
characters=$(echo "$text" | wc -c)

# Count special symbols


special_symbols=$(echo "$text" | tr -d '[:alnum:]' | wc -c)

# Subtract newline character count


characters=$((characters - 1))

echo "Number of words: $words"


echo "Number of characters: $characters"
echo "Number of special symbols: $special_symbols"
}

# Prompt the user to enter text


echo "Enter text:"
read input_text

# Call the function with user input


count_text_stats "$input_text"

Output:-
11.Write a Shell Script for linear search.

#!/bin/bash

# Array of numbers
numbers=(10 20 30 40 50 60 70 80 90 100)

# Function for linear search


linear_search() {
local search_num=$1
local found=0

for num in ${numbers[@]}; do


if [ $num -eq $search_num ]; then
found=1
break
fi
done

if [ $found -eq 1 ]; then


echo "$search_num is found in the list."
else
echo "$search_num is not found in the list."
fi
}

# Main script
echo "Available numbers: ${numbers[@]}"
echo -n "Enter a number to search: "
read search_num

linear_search $search_num
Output

You might also like