You are on page 1of 161

INFORMATION MANAGEMENT SYSTEM

LAB FILE

Submitted In Partial Fulfillment for the Award


of The Degree of B.Com(H) 2019-2022

Under the Guidance of: Submitted by:


Mr. Praveen Kumar Singh Sarthak Goel
(Assistant Professor) 02061188819
B.Com 5B

Maharaja Agrasen Institute of Management Studies Affiliated to Guru Gobind Singh


Indraprastha University, Delhi PSP Area, Plot No. 1, Sector 22, Rohini, Delhi 110086, India
INTRODUCTION TO MY SQL
MySQL is an Oracle-backed open source relationaldatabase management system (RDBMS) based on Structured Query
Language (SQL). MySQL runs on virtually all platforms, including Linux,UNIX and Windows. Although it can be used in a
wide range of applications, MySQL is most often associated with web applications and online publishing.

MySQL is an important component of an open source enterprise stack called LAMP. LAMP is a web development platform
that uses Linux as the operating system, Apache as the web server, MySQL as the relational database management system
and PHP as the object-oriented scripting language.
(Sometimes Perl or Python is used instead of PHP.)
MySQL is based on a client-server model. The core of MySQL is MySQL server, which handles all of the database
instructions (or commands). MySQL server is available as a separate program for use in a client-server networked
environment and as a library that can be embedded (or linked) into separate applications.
MySQL operates along with several utility programs which support the administration of MySQL databases. Commands are
sent to MySQL Server via the MySQL client, which is installed on a computer.
MySQL enables data to be stored and accessed across multiple storage engines, including InnoDB, CSV, and NDB. MySQL
is also capable of replicating data and partitioning tables for better performance and durability. MySQL users aren't required
to learn new commands; they can access their data using standard SQL commands.
MySQL is written in C and C++ and accessible and available across over 20 platforms, including Mac, Windows, Linux and
Unix. The RDBMS supports large databases with millions records and supports many data types including signed or
unsigned integers 1, 2, 3, 4, and 8 bytes long; FLOAT; DOUBLE; CHAR; VARCHAR; BINARY; VARBINARY; TEXT;
BLOB; DATE; TIME; DATETIME; TIMESTAMP; YEAR;.
DECLARATION

I, Sarthak Goel hereby declare that the present project report is submitted in partial fulfillment of my B.com (Hons.)
degree. The work was carried out with sincerity and complete dedication. All the assignments done are completed by me
only and has not been copied from anywhere else.

Name of Student: Sarthak Goel


Class & Section: B.Com 5B
Enrolment Number: 02061188819
ACKNOWLEDGEMENT

"I have taken efforts in this project. However, it would not have been possible without the kind support and help of many
individuals. I would like to extend my sincere thanks to all of them.
I am highly indebted to Mr. Praveen Kumar Singh, Assistant Professor, Department of Commerce for his guidance and
constant supervision as well as for providing necessary information regarding the project & also for his support in
completing the project.
I would also like to express my gratitude towards my parents &Dr.Manju Gupta, HOD, Department of Commerce for
their kind co-operation and encouragement which helped me in completion of this project.
My thanks and appreciations also go to my colleagues in developing the project and people who have willingly helped me
out with their abilities.

Name of Student: Sarthak Goel


Class & Section: B.Com 5B
Enrolment Number: 02061188819
INDEX

S.No. Title Page No.


1 Assign. 1 (Create table, insert and select the values intoSQL command) 01

2 Assign. 2 (SQL Where Clause) 04


3 Assign. 3 ( DELETE, AND, OR, NOT, DISTINCT 09
SQL Clause)
4 Assign.4 (NOT NULL, UNIQUE and PRIMARY KEY 13
SQL Constraint)
5 Assign.5 ( FOREIGN KEY, CHECK constraint) 17
6 Assign.6 (All constraints) 22
7 Assign.7 (Alter statement, sql not null constraint onalter table, sql unique 27
constraint on alter table and check constraint on alter table)

8 Assign.8 (Update command) 33


9 Assign.9 (Creating a table from another table, truncatecommand, rename 42
command)
10 Assign.10 (Range searching, pattern matching, IN andNOT IN predicate) 48

11 Assign.11 (Adddate, Month and Count commands inSQL) 54

12 Assign.12 60
13 Assign.13 Aggregate functions in SQL 68
14 Assign.14 Order by, group by and having clause 75
15 Assign.15 nested queries 81
16 Assign.16 JOIN SQL STATEMENT (INNER JOIN) 86
17 Assign.17 92
18 Assign.18 (OUTER JOIN) 95
19 Assign.19 (CROSS JOIN & SELF JOIN) 100
20 Assign.20 104
21 Assign.21 108
22 Assign.22 117
23 Assign.23 (E-R DIAGRAM) 121
24 Assign.24 124
25 Assign.25 (E-R DIAGRAM) 129
26 Assign.26 133
27 Assign.27 139
28 Assign.28 144
29 Assign.29 148
30 Assign.30( E-R DIAGRAM) 152
Maharaja Agrasen Institute of Management Studies
Affiliated to GGS IP University; Recognized u/s 2(f) of UGC
Recognized by Bar Council of India; ISO 9001: 2015
Certified Institution Sector 22, Rohini, Delhi -110086, India;
www.maims.ac.in

Department of Commerce Academic Year: 2020-21 Semester: Vth


Assignment No.1

Course/ Subject Code:BCOM307 Subject Title: Information System Management Lab

Instructions for Students:


1. All Questions are Compulsory.
2. The student should attach proper cover page for each assignment clearly mentioning the
Assignment No.
3. Each assignment should be prepared by the student individually with proper explaination
and screenshots.
4. A4 size ruled sheets should be used for the assignment.
5. Assignment pages should be serially numbered at the bottom of page.

During online education mode, upload scanned copy of the complete assignment
including cover page latest by due date.
Question CO
Question
No. No.
1 CO1
Create a table called “Persons” that contains five columns:
a) PersonID INT
b) FirstName Char(20)
c) LastName Char(20)
d) Address Varchar(25)
e) City char(10)
2 Insert any 5 values in the table “Persons”
3 View All records of the table “Persons”

1
ASSIGNMENT – 1
SQL CREATE TABLE COMMAND
Q1. Create a table named “Persons” with the following columns – person id, first name, last
name, address, city.

 Syntax:
Create table table_name(
Column 1 data type,
Column 2 data type,
Column 3 data type);

Q2. Insert 5 rows into the table name Persons:

The “insert into” command is used to insert new records in a table.

 Syntax:
INSERT INTO table_name (column1, column2, column3,….) VALUES (value1,
value2, value3,….);

2
Q3. To view all records from the table name persons

 Syntax: Select * table_name;

3
Maharaja Agrasen Institute of Management Studies
Affiliated to GGS IP University; Recognized u/s 2(f) of UGC
Recognized by Bar Council of India; ISO 9001: 2015
Certified Institution Sector 22, Rohini, Delhi -110086, India;
www.maims.ac.in

Department of Commerce Academic Year: 2020-21 Semester: Vth


Assignment No.2

Course/ Subject Code:BCOM307 Subject Title: Information System Management Lab

Instructions for Students:


1. All Questions are Compulsory.
2. The student should attach proper cover page for each assignment clearly mentioning the
Assignment No.
3. Each assignment should be prepared by the student individually with proper explaination
and screenshots.
4. A4 size ruled sheets should be used for the assignment.
5. Assignment pages should be serially numbered at the bottom of page.

During online education mode, upload scanned copy of the complete assignment
including cover page latest by due date.
Question CO
Question No.
No.
1 Create a table named Client_Master with the following columns: a. CO1,CO4
Client_No.
b. Name
c. Address
d. City
e. Pincode
f. State
g. Baldue
2 Insert any 5 rows in the above columns

3 Select the whole table.


4 Display all the details where the city is “Delhi”.
5 Display the names of the client who belongs to “Haryana”.
6 Display the Client_No. and name whose Baldue is greater than “5000”.

7 Display the client_no., city and pincode who belongs to Delhi.


8 Display the name and Baldue of those clients who belongs to Rajasthan.

4
ASSIGNMENT – 2
Q1. Create a table named client_master with the following columns:

 Client_no
 Name
 Address
 City
 Pincode
 State
 Baldue

Q2. Insert any 5 rows:

5
SQL WHERE CLAUSE

 Use every time with the ‘select’ SQL command.


 Used to filter records.
 Used to extract only those records that fulfill the specifies conditions.
Where Syntax:
SELECT column1, column2,…. FROM table_name WHERE conditions;
Q3. Select the whole table.

Q4. To display the details of all clients who belong to New Delhi

6
Q5. To display the names of the clients who belong to Haryana.

Q6. To display the client number and name whose balance due is greater than 5000.

7
Q7. To display the client number, city and pin code who belongs to New Delhi.

Q8. To display the name and balance due of those clients who belongs to Rajasthan.

8
Maharaja Agrasen Institute of Management
Studies Affiliated to GGS IP University; Recognized u/s 2(f)
of UGC Recognized by Bar Council of India; ISO 9001:
2015 Certified Institution Sector 22, Rohini, Delhi -110086,
India; www.maims.ac.in

Department of Commerce Academic Year: 2020-21 Semester: Vth


Assignment No.3

Course/ Subject Code:BCOM307 Subject Title: Information System Management Lab

Instructions for Students:


1. All Questions are Compulsory.
2. The student should attach proper cover page for each assignment clearly mentioning the
Assignment No.
3. Each assignment should be prepared by the student individually with proper explaination
and screenshots.
4. A4 size ruled sheets should be used for the assignment.
5. Assignment pages should be serially numbered at the bottom of page.

During online education mode, upload scanned copy of the complete assignment
including cover page latest by due date.
Question CO
Question
No. No.
Delete all the records from Persons table who belong to Delhi CO4
1
Display all the records from Client_Master table who belongs to
2
Delhi and the Baldue is less than 5000.
3 Display all the records from Client_Master table where city= delhi
or gurugram.
4 Display all those records from Client_Master Table whose state
is Uttarpradesh and city must be Noida or Ghaziabad.
5 Display all the records from Client_Master table who don’t belong
to Delhi
6 Display distinct city values from Client_Master table.

9
ASSIGNMENT – 3
Q1. To delete persons from persons table who belongs to New Delhi.

 Syntax:
DELETE from persons where city=’New Delhi;

Q2. To display from all records from client_master who belongs to Delhi and his or her
baldue is less than 5000.

 Syntax:
select * from client_master where state='delhi' and baldue<5000;

10
Q3. To display all record from table client_master whose city belongs to new Delhi or Hisar.

 Syntax:
select * from client_master where city='new delhi' or city='hisar';

Q4. To display all record from table client_master whose states belongs to Uttar Pradesh and
city belongs to Noida and Ghaziabad.

 Syntax:
select * from client_master where State= 'uttar pradesh' and City = 'Noida' or State =
'uttar pradesh' and City = 'Ghaziabad';

11
Q5. To display all record from table client_master who don’t belong to city New Delhi

 Syntax
select * from client_master where not city='new delhi';

Q6. To display distinct city values from client_master.

 Syntax
select distinct city from client_master;

12
Maharaja Agrasen Institute of Management Studies
Affiliated to GGS IP University; Recognized u/s 2(f) of UGC
Recognized by Bar Council of India; ISO 9001: 2015
Certified Institution Sector 22, Rohini, Delhi -110086, India;
www.maims.ac.in

Department of Commerce Academic Year: 2020-21 Semester: Vth


Assignment No.4

Course/ Subject Code: BCOM307 Subject Title: Information System Management Lab

Instructions for Students:


1. All Questions are Compulsory.
2. The student should attach proper cover page for each assignment clearly mentioning the
Assignment No.
3. Each assignment should be prepared by the student individually with proper explaination
and screenshots.
4. A4 size ruled sheets should be used for the assignment.
5. Assignment pages should be serially numbered at the bottom of page.

During online education mode, upload scanned copy of the complete assignment
including cover page latest by due date.
Question CO
Question
No. No.
1 Create a table with the following column names using NOT NULL: CO1,CO3,C
• Col1 O4
• Col2

2 Create a table using UNIQUE Constraint in one of the column

3 Create a table table_1 using PRIMARY KEY and show that it doesn’t
accept any duplicate values. Also use a command to DESCRIBE the
table.
4 Show all the records from table_1.
5 Delete a row from a table whose Col1 value is “234”.
6 Show the distinct values of Col1.

13
ASSIGNMENT – 4
QUES 1 Create a table with the following column names using NOT NULL:

 Col1
 Col2

QUES 2 Create a table using UNIQUE Constraint in one of the column

14
QUES 3 Create a table table_1 using PRIMARY KEY and show that it doesn’t accept any
duplicate values. Also use a command to DESCRIBE the table.

QUES 4 Show all records from the table table_name1

15
QUES 5 Delete a row from table whose col1 value is 204

QUES 6 To show distinct values of col1

16
Maharaja Agrasen Institute of Management Studies
Affiliated to GGS IP University; Recognized u/s 2(f) of UGC
Recognized by Bar Council of India; ISO 9001: 2015
Certified Institution Sector 22, Rohini, Delhi -110086, India; www.maims.ac.in

Department of Commerce Academic Year: 2020-21 Semester: Vth


Assignment No.5

Course/ Subject Code:BCOM307 Subject Title: Information System Management Lab


Instructions for Students:
1. All Questions are Compulsory.
2. The student should attach proper cover page for each assignment clearly mentioning the
Assignment No.
3. Each assignment should be prepared by the student individually with proper explaination
and screenshots.
4. A4 size ruled sheets should be used for the assignment.
5. Assignment pages should be serially numbered at the bottom of page.
During online education mode, upload scanned copy of the complete assignment
including cover page latest by due date.

Questi Question CO
on
No.
No.

1 1Create a table called “Persons” that contains four columns: P LastName, rsonID CO1,C
FirstName and Age and a table called “Orders” that c three columns:, O3
OrderID, OrderNumber and PersonID. ontains

PersonID LastName FirstName Age


(Primary Key) (Not Null) (Not Null)
(Not Null)

1 Hansen Ola 30

2 Svendson Tove 23

3 Petterson Kari 20

OrderID (Primary Key) OrderNumber (Not Null) PersonID

1 77895 3

2 44678 3

3 22456 2

4 24562 1

17
. Insert values in Order table with personID= ‘4’.
2
3 Insert values in Order table as:
● OrderID = 5
● OrderNumber = 12345
Also show all the values of the Order table.

4 Create a table Person_CHECK with the following values:


● ID INT NOT NULL
● LastName VARCHAR(20) NOT NULL
● FirstName VARCHAR(20) ● Age INT
Make sure to check that Age should be “>=18”.

5 . Insert value in the table Person_CHECK and age should be “17”.

6 . Delete the value from orders table where OrderID is 4.

7 Delete from Persons table where personID is 3. Justify the error if any.

18
ASSIGNMENT – 5
Q1 Create a table called “Persons” that contains four columns: PersonID, LastName,
FirstName and Age and a table called “Orders” that contains three columns: OrderID,
OrderNumber and PersonID.

PersonID LastName FirstName Age


(Primary Key) (Not Null) (Not Null) (Not Null)
1 Hansen Ola 30
2 Svendson Tove 23
3 Petterson Kari 20

OrderID (Primary Key) OrderNumber (Not Null) PersonID


1 77895 3
2 44678 3
3 22456 2
4 24562 1

19
Q2 Insert values in Order table with personID= ‘4’.

Q3 Create a table Person_CHECK with the following values:

 ID INT NOT NULL

20
Q4 Show all the values of order table and delete row where order ID is 4

Q5 Delete row from person table where person is 3

21
Maharaja Agrasen Institute of Management Studies
Affiliated to GGS IP University; Recognized u/s 2(f) of UGC
Recognized by Bar Council of India; ISO 9001: 2015
Certified Institution Sector 22, Rohini, Delhi -110086, India;
www.maims.ac.in

Department of Commerce Academic Year: 2020-21 Semester: Vth


Assignment No.6

Course/ Subject Code:BCOM307 Subject Title: Information System Management Lab


Issue Date: Last Date of Submission:

Instructions for Students:


1. All Questions are Compulsory.
2. The student should attach proper cover page for each assignment clearly mentioning the
Assignment No.
3. Each assignment should be prepared by the student individually with proper explaination
and screenshots.
4. A4 size ruled sheets should be used for the assignment.
5. Assignment pages should be serially numbered at the bottom of page.

During online education mode, upload scanned copy of the complete assignment including
cover page latest by due date.

Questi Question CO
on No.
No.

1 Create the table departments using the following the following columns and CO1
insert any 4 values in the table:

● Dept_No INT (make this as primary key)


● Dept_NameVARCHAR(20), CHECK that the department name should
among the following:
▪ Sales
▪ Marketing
▪ IT

22
▪ Accounting
● Location VARCHAR(20), CHECK that the location should be among the
following:
▪ Delhi
▪ Mumbai
▪ Noida
▪ Gurugram

2 Create a table Employees using the following columns and insert any 3 values
in it:

● Emp_No INT (make this as primary key), also CHECK that the
Employee number should be between 1000 and 2000.
● Emp_NameVARCHAR(20)
● DesgVARCHAR(20), CHECK that the designation should be among the
following:
▪ Saleman
▪ Analyst
▪ Manager
▪ President
● Hire_date DATE
● Salary INT, CHECK that the salary should be >=1000 and <=5000. ●
Commission INT
● Dept_No INT (make this as the foreign key with reference to the
department table), CHECK that the dept_no should be among the
following:
▪ 10
▪ 20
▪ 30
▪ 40

23
ASSIGNMENT – 6
Q1. Create a table with the following columns: -
1. Dept_No (Primary key).
2. Dept_Name with the constraints that it should Sales, Marketing, IT, or Accounting.
3. Location with the constraints that it should be Delhi, Mumbai, Noida Gurgaon.
 Syntax:
Create table Department(
Dept_No int primary key,
Dept_Name varchar (25) not null check(Dept_Name=’Sales’ OR
Dept_Name=’Marketing’ OR Dept_Name=’IT’ OR Dept_Name=’Accounting’),
Location varchar (20) check(Location=’Delhi’ OR Location=’Mumbai’ OR
Location=’Noida’ OR Loaction=’Gurgaon’));

Q2. Create a table Employee with the following columns: -


1. Emp_No primary key with the constraint that it should be between 1000 and 2000.

2. Emp_Name.
3. Designation with the constraint that it should be Clerk, Salesman, Analyst, Manager or
President.

4. Hire_Date.
5. Salary with the constraint that it should be between 1000 and 5000.

6. Commission.
7. Dept_No with the constraint that it should be 10, 20, 30, or 40 and it should be foreign key
with reference to Dept_No in Department table.

24
 SYNTAX:
create table Employee(

Emp_No int primary key check(Emp_No>=1000 and Emp_No<=2000),


Emp_Name varchar(20),
Designation varchar(20) check(Designation='Clerk' or Designation='Manager' or
Designation='President' or Designation='Salesman' or Designation='Analyst'),

Hire_Date Date,

Salary int check(Salary>1000 or Salary<5000),


Commission int,

Dept_No int check(Dept_No=10 or Dept_No=20 or Dept_No=30 or Dept_No=40),


foreign key(Dept_No) references Department(Dept_No));

25
Q3. Insert any 3 rows in table department

Q4. Insert 3 rows in table employees

26
Maharaja Agrasen Institute of Management Studies
Affiliated to GGS IP University; Recognized u/s 2(f) of UGC
Recognized by Bar Council of India; ISO 9001: 2015
Certified Institution Sector 22, Rohini, Delhi -110086, India;
www.maims.ac.in

Department of Commerce Academic Year: 2020-21 Semester: Vth


Assignment No.7

Course/ Subject Code:BCOM307 Subject Title: Information System Management Lab


Instructions for Students:
1. All Questions are Compulsory.
2. The student should attach proper cover page for each assignment clearly mentioning the
Assignment No.
3. Each assignment should be prepared by the student individually with proper explaination
and screenshots.
4. A4 size ruled sheets should be used for the assignment.
5. Assignment pages should be serially numbered at the bottom of page.

.
Question CO
Question
No. No.
Add email column in the Persons table. CO1,CO2
1
Drop the column email from the persons table.
2

3 Drop the column age from the persons table.

4 Add column DOB in Persons table.

5 Change the column DOB datatype to year in the persons table.

6 Delete all the values from persons table.

7 Add the NOT NULL constraint on DOB column in Persons table

Use UNIQUE constraint in the DOB column of the Persons table.


8

9 Change the column DOB datatype to date in the persons table.

Create a CHECK constraint on DOB column of persons table where the


10
persons DOB is greater than 1 JAN 1995.

27
ASSIGNMENT 7
Q1 Add email column in the Persons table.

Q2 Drop email column in the Persons table.

28
Q3 Drop the column age from the persons table.

Q4 Add column DOB in Persons table.

29
Q5 Change the column DOB datatype to year in the persons table.

Q6 Delete all records from table

Q7 Add not null constraint to the column name ‘Date of Birth’.

30
Q8 Add unique constraint on the column name ‘Date of Birth’ of person table

Q9 Change the datatype of column DOB to date

31
Q10 Create a check constrain on the column name "Date_of_birth" of ‘persons’ table. for
which the DOB is greater than 1 Jan. 1995.

32
Maharaja Agrasen Institute of Management Studies
Affiliated to GGS IP University; Recognized u/s 2(f) of UGC
Recognized by Bar Council of India; ISO 9001: 2015
Certified Institution Sector 22, Rohini, Delhi -110086, India;
www.maims.ac.in

Department of Commerce Academic Year: 2020-21 Semester: Vth


Assignment No.8

Course/ Subject Code:BCOM307 Subject Title: Information System Management Lab


Issue Date: Last Date of Submission:

Instructions for Students:


1. All Questions are Compulsory.
2. The student should attach proper cover page for each assignment clearly mentioning the
Assignment No.
3. Each assignment should be prepared by the student individually with proper explaination
and screenshots.
4. A4 size ruled sheets should be used for the assignment.
5. Assignment pages should be serially numbered at the bottom of page.

During online education mode, upload scanned copy of the complete


assignment including cover page latest by due date.

Questi Question CO
on
No.
No.

Update the city to mumbai of client from client master whose ClientID is 1001. CO2,C
1 O3,CO
4
2 Update the baldue to 10000 of all clients whose city is delhi from client
master.

3 Update the baldue to 10000 for all the clients from client master.

Drop pincode from Client master.


4

Add a new column of salary with datatype INT in client master table.
5
6 To insert a new row in client master table.

33
Update the salary to 10000 for ClientID 1001 in client master.
7

Increase the baldue of all employees by 10% in client master.


8
9 Change the size of name column of client master table to 50.

. Display distinct city name in client master table.


1
0

1 Delete record from client master table where baldue is less than 10000.
1

1 To delete all those records from client master where city is Mumbai and
2 baldue is greater than 10000.

1 . Update the following of ClientID 2002 from client master table:


3
● Name- SMITH
● City- CHANDIGARH
● Baldue- 5000

34
ASSIGNMENT 8
QUES 1 Update the city to Mumbai of client from client master whose ClientID is 1001.

QUES 2 Update the baldue to 10000 of all clients whose city is delhi from client
master.

35
QUES 3 Update the baldue to 10000 for all the clients from client master.

QUES 4 Drop a column name pincode from client_master table

36
QUES 5 Add a new column of salary with datatype INT in client master table.

QUES 6 To insert a new row in client master table.

37
QUES 7 Update the salary for client_no 101 to 10000

QUES 8 Increase the balance due of all clients by 10%

38
QUES 9 Change the size of name column of client master to 50

QUES 10 Show distinct city names

39
QUES 11 To delete a record of a client from table client_master where baldue is less than
10000

QUES 12 Delete all records from client_master table where city is Mumbai and baldue is
greater than 10000

40
QUES 13 Update the name to smith city to Chandigarh and baldue to 5000 where client_no
is 102

41
Maharaja Agrasen Institute of Management Studies
Affiliated to GGS IP University; Recognized u/s 2(f) of UGC
Recognized by Bar Council of India; ISO 9001: 2015
Certified Institution Sector 22, Rohini, Delhi -110086, India;
www.maims.ac.in

Department of Commerce Academic Year: 2020-21 Semester: Vth


Assignment No.9

Course/ Subject Code:BCOM307 Subject Title: Information System Management Lab


Instructions for Students:
1. All Questions are Compulsory.
2. The student should attach proper cover page for each assignment clearly mentioning the
Assignment No.
3. Each assignment should be prepared by the student individually with proper explaination
and screenshots.
4. A4 size ruled sheets should be used for the assignment.
5. Assignment pages should be serially numbered at the bottom of page.

Question CO
Question
No. No.
1 Create a table name client_test having fields: CO1,CO2,C
• Name O3
• City
• Basic Salary
From the source table name Client_Master.
2 Truncate table client_test

3 Rename the table client_test to client_dummy.

4 Find out all the names of all the clients from table client_master.

5 Retrieve the entire contents of client_master table.

6 Change the city of client 2002 to Banglore of client_master table.

7 Add a new column Desg. In client_master table.

Delete from client_master where column state holds the value Haryana.
8

9 Add a column called telephone of datatype INT in client_master

Change the name of client_master table to client_bcom5B.


10

42
ASSIGNMENT 9
Q1. Create a table name client_test having 3 fields i.e. name, city and salary from the source
table name client_master and rename salary to basis salary

Truncate table empties a table completely logically it is equivalent to delete statement that
deletes all row but there are some differences
1 Truncate draw and recreate the table which is much faster than deleting rows 1 by 1

2 Truncate operations are not transaction safe


3 The number of deleted rows is not returned
Q2 Truncate table client_test

43
Q3 Renaming tables

Q4 find out the name of all client

44
Q5 retrive the entire content of client_master table

Q6 change the city of client number 102 to bangalore

45
Q7 add a new column name designation in the table client_master

Q8 delete from client_master where column state holds the value haryana

46
Q9 add a column called telephone of data type int in the client_master table

Q10 change the name of client_master table to client_bcom5A

47
Maharaja Agrasen Institute of Management Studies
Affiliated to GGS IP University; Recognized u/s 2(f) of UGC
Recognized by Bar Council of India; ISO 9001: 2015
Certified Institution Sector 22, Rohini, Delhi -110086, India;
www.maims.ac.in

Department of Commerce Academic Year: 2020-21 Semester: Vth


Assignment No.10

Course/ Subject Code:BCOM307 Subject Title: Information System Management Lab


Instructions for Students:
1. All Questions are Compulsory.
2. The student should attach proper cover page for each assignment clearly mentioning the
Assignment No.
3. Each assignment should be prepared by the student individually with proper explaination
and screenshots.
4. A4 size ruled sheets should be used for the assignment.
5. Assignment pages should be serially numbered at the bottom of page.

Question CO
Question
No. No.
List all the clients whose salary is between 5000 to 10000. CO4
1

2 List the customers whose names begin with ‘k’.

3 List the customers whose names have the second character as ‘a’.

List the customers whose names have the second character as ‘a’ OR
4
‘r’.
List the customers whose name begin with the letters ‘ab’ and it a four
5
letter word.
6 . List the customer details of the costumers named RISHUB, KRITI,
ABHI and RAHUL.

. List the customer details of the customer named other than RISHUB,
7 KRITI, ABHI and RAHUL.

8 List the client who stay in a city whose first letter is ‘m’.

List all clients who stay in BANGLORE or DELHI.


9

List all clients whose baldue is greater than 1000 OR less than equal to
10
5000.

48
ASSIGNMENT 10

Q1 List all the clients whose salaries is between 5000 to 10000

Q2 List the customers whose names begin with the letter A

49
Q3 List the customers whose name have the second character as A

Q4 List the customers whose names have the second character as A or H

50
Q5 List the customers whose name begins with the letter A or B and it is a four-letter word

IN or NOT IN predicate

The arithmetic operate equal compare the


In case the value needs to be compared to a list of values the IN PREDICATE is used
The IN PREDICATE helps reduce the need to use multiple or conditions

Q6 list the customer details of the customers name smith, shivam, rohan, manav

Syntax – Select * from client_bcom5a where name IN(‘smith’,’shivam’,’rohan’,’manav’);

51
Q7 list the customer details of the customers not name smith, shivam, rohan, manav

Q8 List the client who stay in a city whose first letter is m

52
Q9 List all clients who stay in Bangalore or Delhi

Q10 List all clients whose baldue is greater than 1000 and less than or equal to 5000

53
Maharaja Agrasen Institute of Management Studies
Affiliated to GGS IP University; Recognized u/s 2(f) of UGC
Recognized by Bar Council of India; ISO 9001: 2015
Certified Institution Sector 22, Rohini, Delhi -110086, India;
www.maims.ac.in

Department of Commerce Academic Year: 2020-21 Semester: Vth


Assignment No.11

Course/ Subject Code:BCOM307 Subject Title: Information System Management Lab


Instructions for Students:
1. All Questions are Compulsory.
2. The student should attach proper cover page for each assignment clearly mentioning the
Assignment No.
3. Each assignment should be prepared by the student individually with proper explaination
and screenshots.
4. A4 size ruled sheets should be used for the assignment.
5. Assignment pages should be serially numbered at the bottom of page.

Question CO
Question
No. No.
Add 10 more days to the date 2017-06-15 and return the date. CO2,CO3,C
1 O4

2 Subtract 3hours to a date 2017-06-15 and return the date.

Subtract 2 months to a date 2017-06-15 and return the date.


3

List the emp_no, emp_name and hire_date when they have joined the
4
organization from the employees table.
. List the month of the employees hire date from the employees table.
5

6 Subtract 15 days from the employees hire date from the employees table.

7 List the employees whose salary is more than 1000 from the employees
table.

Rename the Employees table to Employees_bcom.


8

Count the number of employees in the Employees_bcom table.


9

10 Count the no. of designation in the employees_bcom table.

54
ASSIGNMENT 11
Ques 1 Add 10 more days to the date 2017-06-15 and return the date.

Ques 2 subtract 3 hours from the date “2017-06-15 09:34:21”

55
Ques 3 Subtract 2 months to the date & return the date

Ques 4 List the employee number, name, hire date from table employees

56
Ques 5 List the month of employees hire date from table employees;

Ques 6 Subtract 15 days from the employees hire date from the employees table.

57
Ques 7 List the employees whose salary is more than 1000

Ques 8 Rename the employees table to employee_bcom

58
Ques 9 Count employees from table employee_bcom

Ques 10 Select distinct designation from table employee_bcom

59
Maharaja Agrasen Institute of Management Studies
Affiliated to GGS IP University; Recognized u/s 2(f) of UGC
Recognized by Bar Council of India; ISO 9001: 2015
Certified Institution Sector 22, Rohini, Delhi -110086, India;
www.maims.ac.in

Department of Commerce Academic Year: 2020-21 Semester: Vth


Assignment No.12

Course/ Subject Code:BCOM307 Subject Title: Information System Management Lab


Instructions for Students:
1. All Questions are Compulsory.
2. The student should attach proper cover page for each assignment clearly mentioning the
Assignment No.
3. Each assignment should be prepared by the student individually with proper explaination
and screenshots.
4. A4 size ruled sheets should be used for the assignment.
5. Assignment pages should be serially numbered at the bottom of page.

During online education mode, upload scanned copy of the complete assignment
including cover page latest by due date.
Questi Question CO
on
No.
No.

1 Create table client_master5b with the following columns: CO1,C


O2,CO
● Client_no 3,CO4
● Name
● City
● Pincode
● State
● Baldue

60
2 . Insert 3 rows into client_master5b table with the following values:
(1strow )

● C00001 primary key,


● Ivan Bayross
● Mumbai
● 40054
● Maharashtra
● 15000
(2nd row)

● Baldue should be 0
(3rd row)

● Baldue should be 5000

Change the city of client no. C00001 to banglore from client_master5b.


3
Change the baldue of client_no. C00001 to 1000 from client_master5b.
4
Add a column called telephone of datatype INT to the client_master5b table.
5
6 Delete from client_master5b where the column state holds the value tamilnadu

7 Display all records from client_master5b table for those clients whose name
starts with ‘I’.

Retreive the entire content of client_master5b table.


8
Display all distinct city in client_master5b table.
9
Rename the table client_master5b to client_master_test.
1
0

61
ASSIGNMENT 12
Q1 Create table client_master5b with the following columns:

 Client_no
 Name
 City
 Pincodex
 State
 Baldue

Q2 insert 3 rows into the client_master table with the following values
Client no – C00001
Name – Ivan Biros
City – Mumbai
Pin code – 400054

State – Maharashtra
Bal due – 15000, 0 & 5000
And here the client no is primary key

62
Q3 change the city of client_no C00001 to Bangalore

63
Q4 change the bal due of client number C0001 to 1000

Q5 add a column telephone of data type int to the client_master table

64
Q6 delete from client_master where the column state holds the value Tamil nadu

Q7 display all records from the client_master table for those clients whose name start with I

65
Q8 retrieve the entire contents of client_master table

Q9 display all distinct city in client_master table

66
Q10 rename the table client_master to client_master_test

67
Maharaja Agrasen Institute of Management Studies
Affiliated to GGS IP University; Recognized u/s 2(f) of UGC
Recognized by Bar Council of India; ISO 9001: 2015
Certified Institution Sector 22, Rohini, Delhi -110086, India;
www.maims.ac.in

Department of Commerce Academic Year: 2020-21 Semester: Vth


Assignment No.13

Course/ Subject Code:BCOM307 Subject Title: Information System Management Lab


Instructions for Students:
1. All Questions are Compulsory.
2. The student should attach proper cover page for each assignment clearly mentioning the
Assignment No.
3. Each assignment should be prepared by the student individually with proper explaination
and screenshots.
4. A4 size ruled sheets should be used for the assignment.
5. Assignment pages should be serially numbered at the bottom of page.

During online education mode, upload scanned copy of the complete


assignment including cover page latest by due date.
Question Question CO
No.
No.

Find the average salary of employees from the employees_bcom table. CO4
1

2 Find the average salary of all distinct values of employees from the
employees_bcom table.

3 Find the minimum salary of employees from the employee_bcom table.

4 Find the maximum salary of employees from the employee_bcom table.

5 Find the sum of the commission from the employee_bcom table.

6 Display the average salary of all the employees whose hire_date is


greater than 01-01-2010 from employees_bcom table

7 List the name of all the employees whose salary is greater than 1000 and
commission is greater than 500.

68
8 List the name of all the employees having ‘a’ as a second letter of their
name and whose salary is more than 1000 in employees_bcom table.

9 Count employee name whose commission is less than of equal to 500 in


the employees_bcom table.

10 Determine the maximum and minimum commission of


employees_bcom table rename the output as max_commission and
min_commission respectively.

11 List the employees whose salary is more than 1000, calculate a new
salary as original salary x 0.15, rename the new column in the output of
above query as new salary in the employees_bcom table.

69
ASSIGNMENT 13
AVERAGE FUNDTION – Returns an average value of n ignoring null values
SYNTAX – AVG([DISTINCT

QUES 1 To find the average salary of all employees from employee_bcom table

MIN FUNCTION – Return a minimum value of expression

MIN([<DISTINCT>
QUES 2 To find the average salary of all distinct values

70
QUES 3 To display the minimum salary from the employee_bcom table

QUES 4 To display the maximum salary from the employee_bcom table

71
SUM FUNCTION – Returns the sum of the values of ‘n’;

QUES 5 To display the sum of all commission of employee_bcom table

QUES 6 To display the average salary of all employee whose hire date is greater than 1st jan
2011

72
QUES 7 list the name of all employees whose salary is greater than 2000 and commission
value equals to 1000

QUES 8 list the name of all employees having ‘h’ as second letter in their name and whose
salary is greater than 4000

73
QUES 9 To count the number of employees having commission less than or equal to 500

QUES 10 Determine the maximum and minimum commission of employee_bcom table and
rename the output as max_commission & min_commission

74
Maharaja Agrasen Institute of Management Studies
Affiliated to GGS IP University; Recognized u/s 2(f) of UGC
Recognized by Bar Council of India; ISO 9001: 2015
Certified Institution Sector 22, Rohini, Delhi -110086, India;
www.maims.ac.in

Department of Commerce Academic Year: 2020-21 Semester: Vth


Assignment No.14

Course/ Subject Code:BCOM307 Subject Title: Information System Management Lab


Instructions for Students:
1. All Questions are Compulsory.
2. The student should attach proper cover page for each assignment clearly mentioning the
Assignment No.
3. Each assignment should be prepared by the student individually with proper explaination
and screenshots.
4. A4 size ruled sheets should be used for the assignment.
5. Assignment pages should be serially numbered at the bottom of page.

Questi on Question CO
No.
No.

1 list the employees from the employees table whose salary is more than 1000 CO4,C
calculate a new salary as original salary into .15 rename the new column in the O5
output of above query as new salary

2 Show the employee name in ascending order of their names in the employees table.

3 select all records from the employee table sorted in descending order by the name of
the employee

4 Find out how many employees are there in each designation in the employees table

5 To count the no. Of clients in each city from client _master table.

75
6 To show all designation from employees table where the no. Of employees is more than
3.

7 To count the no. Of employees in each designation where the designation name start
with “p” and the no. Of employees is more than 1 in the employees table.

8 To count the no. Of clients in each city where the baldue is more than 1000 from
client master table

76
ASSIGNMENT 14
Ques 1 List the employees whose salary is more than 3500 and calculate a new salary as
original salary * 0.15, rename the new column in the output of above query as new_salary

QUES 2 Show the employee names in ascending order of their names

ORDER BY CLAUSE, Syntax – select col1, col2 from table name order by ASC/DESC;

77
QUES 3 Select all record from the employee table sorted descending order by the name of
employee

QUES 4 Find out how many employees are there in each designation
GROUP BY CLAUSE – The group by clause is another section of select statement, this
optional clause tells DBMS to group rows based on distinct values that exist for specified
columns. The group by clause creates a dataset containing several sets of records grouped
together based on a condition.

Syntax – Select <col1>, <col2>, <col3> Aggregate function (<expression>) from table name
where <condition> group by <col1>, <col2>, <col3>;

78
QUES 5 To count the no. of clients in each city from the client_bcom5a table

QUES 6 To show all designation from employee table where no of employee is more than 1
HAVING CLAUSE – The having clause can be used with consumption with group by clause,
having imposes a condition on the group by clause which further filters the group created by
the group by clause

79
QUES 7 To count the number of employees in each designation where the designation name
starts with s and the number of employees is more than 1

QUES 8 To count the no of client in each city where whose balance due is more than 1000

80
Maharaja Agrasen Institute of Management Studies
Affiliated to GGS IP University; Recognized u/s 2(f) of UGC
Recognized by Bar Council of India; ISO 9001: 2015
Certified Institution Sector 22, Rohini, Delhi -110086, India;
www.maims.ac.in

Department of Commerce Academic Year: 2020-21 Semester: Vth


Assignment No.15

Course/ Subject Code:BCOM307 Subject Title: Information System Management Lab


Instructions for Students:
1. All Questions are Compulsory.
2. The student should attach proper cover page for each assignment clearly mentioning the
Assignment No.
3. Each assignment should be prepared by the student individually with proper explaination
and screenshots.
4. A4 size ruled sheets should be used for the assignment.
5. Assignment pages should be serially numbered at the bottom of page.

During online education mode, upload scanned copy of the complete assignment
including cover page latest by due date.
Question CO
Question
No. No.
1 Retrieve the details of employees whose department location is Delhi. CO4,CO5

.
To count the number of employees in each department location.
2

Find out the name of employees whose department does not belongs to
3
Delhi.
To display the number of employees in each department location.
4

To display the number of employees in each department number where


5
average salary of employee is more than 5000.
6 To display the name of employees whose department location is either Delhi
or Mumbai

81
ASSIGNMENT – 15
Sub queries (nested queries)
A sub query is a form of a SQL statement that appears inside another sql statement. It is also
termed as nested query. The statement containing a sub query is called a parent statement.
The parent statement uses the rows (that is the result set returned by the sub query).

It can be used for the following:


• To insert records in a target table.
• To create tables and insert records in the table created.
• To update records in a target table.
• To provide values for conditions in where, having, in, with select, update and delete
statements.

Q 1 retrieve the details of employee whose department location is Delhi

82
Q2 Count the number of employees in each department no

Q3 Find out the name of Employees whose department does not belong to Delhi

83
Q4 To display the number of employees in each department Location.

Q5 To display the number of employees in each department no, where average salary of
employee is more than 2000

84
Q6 To display the name of employees whose department location is either Delhi or Mumbai.

85
Maharaja Agrasen Institute of Management Studies
Affiliated to GGS IP University; Recognized u/s 2(f) of UGC
Recognized by Bar Council of India; ISO 9001: 2015
Certified Institution Sector 22, Rohini, Delhi -110086, India;
www.maims.ac.in

Department of Commerce Academic Year: 2020-21 Semester: Vth


Assignment No.16

Course/ Subject Code:BCOM307 Subject Title: Information System Management Lab


Instructions for Students:
1. All Questions are Compulsory.
2. The student should attach proper cover page for each assignment clearly mentioning the
Assignment No.
3. Each assignment should be prepared by the student individually with proper explaination
and screenshots.
4. A4 size ruled sheets should be used for the assignment.
5. Assignment pages should be serially numbered at the bottom of page.

During online education mode, upload scanned copy of the complete assignment
including cover page latest by due date.
Questi Question CO
on
No.
No.

1 List the employee details along with the department to which they CO1,C
belong. O2,CO
3,CO4

.
2 To show the employee name and dept name for those employees whose
name start with a.

3 To display the employee details along with department details for those
employees whose name second letter is “I” and order by dept name.

4 Add a new column location in the employee table with values

5 To display the employee details whose location is same as the department


location

86
6 Write a sql command to display the name for those employees who get
more salary than the employee where id is 1003.

7 Write a sql command to display the name, salary, dept_id for those
employees who work in the same designation as the employee work
whose employee id is 1001

8 Write the sql command to display the name, salary, dept_no for those
employees who earn such amount of salary which is smallest salary of
any of the department.

9 Display all information of employees whose employee no is any of the no.


1001, 1002, 1003.

1 Write sql command to display all info of the employees whose salary is
0 within the range 1000 and 5000.

87
ASSIGNMENT-16
Join Statement:

A single SQL sentence can manipulate data from more than one tables. Joins are used to
achieve this.
i. Tables are joined on columns that have the same datatype and data width in the
tables.
ii. Tables in a database can be related to each other with ease.
iii. A primary key is a column with a unique value for each row.
iv. The purpose is to bind data together across tables without repeating all of the data
in every table.

Types of Join:

1. Inner Join
2. Outer Join (left, right and full):
3. Cross Join

Inner join:
Inner Join are also known as equi-join because the where statement generally compares two
columns from two tables with equivalence operator. The syntax is given below:

SELECT col1, col2, col3 from table_name1


INNER JOIN table_name2
ON table_name1.col1= table_name2.col2
WHERE condition
ORDER BY col1, col2, col3

 Col1 in table_name1 is usually Primary Key.


 Col2 in table_name2 is usually Foreign Key.
 Col1 and Col2 must have the same datatype and for certain datatypes, the same size.

TASK 1
List the employee details along with the department names to which they belong.

88
TASK 2
Show the employee name and department name for those employees whose names start with
C.

TASK 3
Display the Employee details along with the department details for those employees whose
names’ second letter is A and order by department name.

TASK 4
Add a new column location in Employee table.

Steps:

1. Use the alter command to insert a new column as shown below.

89
2. Use the update command to insert names of cities for the location column.

TASK 5
Display the employee details whose location is same as the department location.

TASK 6
Write the SQL command to display the name for those employees who get more salary than
the employees where Employee No is 1001.

90
TASK 7
Write SQL command to display the name, salary, department ID for those employees who
shares the same designation as the employee whose Employee No is 1001.

TASK 8
Write SQL command to display the name, salary, department no of those employees who
earn such amount of salary which is the least in every department.

TASK 9
Display all the information of employees whose employee no is any of the numbers
1001,1002,1003.

TASK 10
Display all the information of employees whose salary is within the range 1000 and 5000.

91
Maharaja Agrasen Institute of Management Studies
Affiliated to GGS IP University; Recognized u/s 2(f) of UGC
Recognized by Bar Council of India; ISO 9001: 2015
Certified Institution Sector 22, Rohini, Delhi -110086, India;
www.maims.ac.in

Department of Commerce Academic Year: 2020-21 Semester: Vth


Assignment No.17

Course/ Subject Code:BCOM307 Subject Title: Information System Management Lab


Instructions for Students:
1. All Questions are Compulsory.
2. The student should attach proper cover page for each assignment clearly mentioning the
Assignment No.
3. Each assignment should be prepared by the student individually with proper explaination
and screenshots.
4. A4 size ruled sheets should be used for the assignment.
5. Assignment pages should be serially numbered at the bottom of page.

Question CO
Question
No. No.
1 Display all the information of the employees whose salary is within the CO2,CO3,C
range of smallest salary and 2500. O4

.
2 To display the no of employees in each department with their department name

3 Display the emp name, emp id and job title for all employees whose dept
location is delhi.

4 Write sql command to display query name and job title for all employees
whose salary is more than average salary of any department.

To display the emp name whose location is same as the dept location
5

92
ASSIGNMENT – 17
TASK 1
Display all information of employees whose salary is within the range of least salary and
2500.

TASK 2
Display the no of employees in each dept with their dept names.

TASK 3
Display the employee name, employee id and designation for all employees whose
department location is Delhi.

93
TASK 4
Employee name and job title for all employees whose salary is more than average salary of
any department.

TASK 5
Display the employee name whose location is same as the Department location.

94
Maharaja Agrasen Institute of Management Studies
Affiliated to GGSIP University; Recognized u/s 2(f) of UGC
Recognized by Bar Council of India; ISO 9001: 2015 Certified
Institution Sector 22, Rohini, Delhi -110086, India;
www.maims.ac.in

Department of Commerce Academic Year: 2020-21 Semester: Vth

Assignment No.18

Course/ Subject Code:BCOM307 Subject Title: Information System Management Lab

Issue Date: Last Date of Submission:

Instructions for Students:


1. All Questions are Compulsory.
2. The student should attach proper cover page for each assignment clearly
mentioning the Assignment No.
3. Each assignment should be prepared by the student individually with proper
explaination and screenshots.
4. A4 size ruled sheets should be used for the assignment.
5. Assignment pages should be serially numbered at the bottom of page.

During online education mode, upload scanned copy of the complete


assignment including cover page latest by due date.

Questi on Question CO
No.
No.

1 CO
1,C
CustomerID CustomerName Address City Cou O2
ntry

ContactNa me PostalC ode

Ger
1 AlfredsFutterkiste Maria Obere Str.
Berlin 12209 man
Anders 57
y

95
05021 Mexi
co

Avda. de la
2 Ana Trujillo Ana Trujillo México
Constitución
Emparedados y helados D.F.
2222

3 Antonio Moreno Antonio Mataderos México Mexi


05023
Taquería Moreno 2312 D.F. co

To create the table of customers and order with following values


2

Shi
pp
OrderID CustomerID EmployeeID OrderDate
erI
D

10308 2 7 1996-09-18 3

10309 2 3 1996-09-19 1

10310 1 8 1996-09-20 2

3 Write a sql statement that will select all the customers and any orders they
might have

4 To display the department location and employee location which have matched
with employee location or not.

List the employee details who have the same location as department location.
5

List all customer name who has placed order after jan 1996.
6

96
ASSIGNMENT-18
Outer join

i. Outer joins are similar to inner joins but give more flexibility when selecting data
from related tables.
ii. This type of joins can be used in situations where it is desired to select all rows
from the table on the left or right regardless of whether the other has values in
common and usually enter null where data is missing.

Left join
i. The left join keyword returns all records from the left table (table1), and the
matched records from the right table (table2).
ii. The result is null from the right side if there is no match.
The syntax for left join is:
SELECT column_name(s)
FROM table1

LEFT JOIN table2


ON table1.column_name=table2.column_name;

TASK 1
Create the two tables given below, assigning respective Primary and Foreign keys and giving
the required datatype.

97
TASK 2
Write a SQL statement that will select all customers and any orders they might have.

Right Join
i. The right join keyword returns all records from the right table (table1), and the
matched records from the left table (table2).
ii. The result is null from the left side if there is no match.

The syntax for right join is given below


SELECT column_name(s)

FROM table1
RIGHT JOIN table2
ON table1.column_name=table2.column_name;

98
TASK 3
To display the department location and employee location who have matched with employee
location or not.

TASK 4
List the employee details who have same location as of department location.

TASK 5
List all customer names who have placed order before January 1996.

99
Maharaja Agrasen Institute of Management Studies
Affiliated to GGS IP University; Recognized u/s 2(f) of UGC
Recognized by Bar Council of India; ISO 9001: 2015
Certified Institution Sector 22, Rohini, Delhi -110086, India;
www.maims.ac.in

Department of Commerce Academic Year: 2020-21 Semester: Vth


Assignment No.19

Course/ Subject Code:BCOM307 Subject Title: Information System Management Lab


Issue Date: Last Date of Submission:

Instructions for Students:


1. All Questions are Compulsory.
2. The student should attach proper cover page for each assignment clearly mentioning the
Assignment No.
3. Each assignment should be prepared by the student individually with proper explaination
and screenshots.
4. A4 size ruled sheets should be used for the assignment.
5. Assignment pages should be serially numbered at the bottom of page.

During online education mode, upload scanned copy of the complete assignment
including cover page latest by due date.
Question CO
Question
No. No.
To display Cartesian product of employee table (self-employee table). CO3,CO4.C
1 O5
To display all the employees who locate in the same city
2

3 Emp_No Dept_No Since


1001 10 1996
1002 20 2000
1003 30 2007
1004 40 2015
1005 10 1990
Create table r3
4 Find out the emp_id who is enrolled atleast two departments

Calculate avg salary for each department.


5

100
ASSIGNMENT-19
Cross join

It is also called cartesian product. In this, all the records of the first table comes with all the
records from the second table.

Self join
in self-join, a table is joined with itself. For this, two copies of the table have to be opened in
the memory. In the FROM clause, the table name needs to be mentioned twice. Since the
table names are the same, the second table will overwrite the first table and in effect result in
only one table being in memory.

Syntax:
SELECT * or column_name FROM
<table_name>[<alias1>],<table_name>[<alias2>] ............. ;

TASK 1
Display the Cartesian product of Employees_Bcom table. (Self-join)

101
TASK 2
Display all details of the employees who are located in the same city.

TASK 3
Create a table with the columns Emp_No, Dept_No and Since. Assign foreign keys to the
first two columns and insert 5 rows into it.

102
TASK 4
Find the Emp_No who is enrolled in at least two departments.

TASK 5
Calculate the average salary for each department.

103
Maharaja Agrasen Institute of Management Studies
Affiliated to GGS IP University; Recognized u/s 2(f) of UGC
Recognized by Bar Council of India; ISO 9001: 2015
Certified Institution Sector 22, Rohini, Delhi -110086, India;
www.maims.ac.in

Department of Commerce Academic Year: 2020-21 Semester: Vth


Assignment No.20

Course/ Subject Code:BCOM307 Subject Title: Information System Management Lab


Instructions for Students:
1. All Questions are Compulsory.
2. The student should attach proper cover page for each assignment clearly mentioning the
Assignment No.
3. Each assignment should be prepared by the student individually with proper explaination
and screenshots.
4. A4 size ruled sheets should be used for the assignment.
5. Assignment pages should be serially numbered at the bottom of page.

During online education mode, upload scanned copy of the complete assignment
including cover page latest by due date.
Question CO
Question
No. No.
Write sql query to print the details of all employees order by employee name CO2,CO3,C
1 ascending and department descending O4,CO5
write sql query to print details of all employees excluding names Ananaya
2
and Himanshi from employee table.

3 write sql query to print the details of all employees whose name contain a.

write sql query to print details of all employees Whose name ends with
4
h and contains 6 alphabets.
write sql query to fetch no of employees in each department in the descending
5
order

6 write sql query to fetch the list of employees with same salary.

7
write sql query to show second highest salary from the employee table

8 write sql query to fetch the departments that have less than 2 people in it.

104
ASSIGNMENT-20
TASK 1
Write an SQL query to print the details of all employees ordered by employee name in
ascending and department name in descending order.

TASK 2
Write SQL query to print the details of all employees excluding names Ruby and Caleb from
Employees_Bcom table.

TASK 3
Write SQL query to print the details of all employees whose name contains ‘a’.

105
TASK 4
Write SQL query to print the details of all employees whose name ends with h and contains
6 alphabets.

TASK 5
Write SQL query to fetch number of employees in each department in descending order.

TASK 6
Write an SQL query to fetch the list of employees with the same salary.
Steps:

Since my table does not have employees with same salary, I used the update command to
make their salaries same first.

106
TASK 7
Write an SQL query to show the second-highest salary from the Employee table.

TASK 8
Write an SQL query to fetch the departments that have less than 2 people in it.

107
Maharaja Agrasen Institute of Management Studies
Affiliated to GGS IP University; Recognized u/s 2(f) of UGC
Recognized by Bar Council of India; ISO 9001: 2015
Certified Institution Sector 22, Rohini, Delhi -110086, India;
www.maims.ac.in

Department of Commerce Academic Year: 2020-21 Semester: Vth


Assignment No.21

Course/ Subject Code:BCOM307 Subject Title: Information System Management Lab


Issue Date: Last Date of Submission:

Instructions for Students:


1. All Questions are Compulsory.
2. The student should attach proper cover page for each assignment clearly
mentioning the Assignment No.
3. Each assignment should be prepared by the student individually with proper
explaination and screenshots.
4. A4 size ruled sheets should be used for the assignment.
5. Assignment pages should be serially numbered at the bottom of page.

During online education mode, upload scanned copy of the complete


assignment including cover page latest by due date.

Questi on Question CO
No. No.

1 CO1,C
O2
Column_Name Data Type Size Default Attributes

CLIENT_NO VARCHAR 6 Primary key/


first letter must

start with C

NAME VARCHAR 20 NOT NULL

CITY VARCHAR 15

PINCODE INTEGER

STATE VARCHAR 15

BALDUE INTEGER

108
Create the following table with the given attributes:
Table Name: CLIENT_MASTER
2
CLIENT_ NAME CITY PINC STATE BALD
NO ODE UE

C0001 Ivan Mum 4000 Mahar 1500


Bayross bai 5 ashtra 0
4
C0002 MamtaM Madr 7800 Tamil 0
uzumdar as 0 Nadu
1
C0003 ChhayaBa Mum 4000 Mahar 5000
nkar bai 5 ashtra
7
C0004 Ashwini Bang 5600 Karnat 0
Joshi lore 0 aka
1
Insert the following values in the CLIENT_MASTER table
3

Column_Name Data Type Size Default Attributes

PRODUCT_NO VARCHAR 6 Primary key/


first letter
must start
with P
DESCRIPTION VARCHAR 15 NOT NULL

QTY_ON_HAND INTEGER NOT NULL

REORDER_LEVEL INTEGER NOT NULL

SELL PRICE INTEGER NOT NULL,


CANNOT BE 0

COST PRICE INTEGER NOT NULL,


CANNOT BE 0

Create the following table with the given attributes:


Table Name: PRODUCT_MASTER

109
4
PRODUCT DESCRIPTIO QTY_O REORD SELL COST
_NO N N_HA ER PRICE PRICE
ND LEVEL

P00001 T-shirts 200 50 350 250

P0345 Shirts 150 50 500 350

P06734 Cotton Jeans 100 20 600 450

P07865 Jeans 100 20 750 500

Insert the following values in the PRODUCT_MASTER table:


5
Column_Name Data Type Size Default Attributes

SALESMAN_NO VARCHAR 6 Primary key/


first letter must
start with S

SALESMAN_NAME VARCHAR 20 NOT NULL

CITY VARCHAR 20

PINCODE INTEGER

STATE VARCHAR 20

SALES_AMOUNT INTEGER NOT NULL,


CANNOT BE 0

Create the following table with the given attributes:

Table Name: SALESMAN_MASTER

110
6
SALESM SALESMA CITY PINC STATE SALE
AN_NO N_NAME ODE S_A
MT

S00001 AMAN MU 40000 Mahar 3000


MBA 2 ashtra
I

S00002 Omkar MU 40000 Mahar 3000


MBA 1 ashtra
I

S00003 Raj MU 40003 Mahar 3000


MBA 2 ashtra
I

S00004 Ashish MU 40004 Mahar 3500


MBA 4 ashtra
I

Insert the following values in the SALESMAN_MASTER table:


7

Column_Name Data Type Size Default Attributes

ORDER_NO VARCHAR 6 Primary key/


first letter must
start with O

CLIENT_NO VARCHAR 6 REFER


CLIENT_MASTER

Order_date DATE NOT NULL

Salesman_NO VARCHAR 6 REFER


SALESMAN_MASTER

ORDER_STATUS VARCHAR 10 IN_PROCESS,

CANCELLED,
FULFILLED, BACK_
ORDER

111
Create the following table with the given attributes:
Table Name: SALES_ORDER
8

ORDER_NO CLIENT_NO OrderDate Salesman No Orders t

O19001 C00001 12-JUNE-2004 S00001 IN_PRO


L
O19002 C00002 25-JUNE-2004 S00002 CANCE

O46865 C00003 18-FEB-2004 S00003 FULFILL

O19003 C00001 03-APR-2004 S00001 FULFILL

Insert the following values in the SALES_ORDER table:


9

Column_Name Data Type Size Default Attributes

ORDER_NO VARCHAR 6 REFER


SALES_ORDER

PRODUCT_NO VARCHAR 6 REFER


PRODUCT_MASTER

QTYORDERED INTEGER

Create the following table with the given attributes:


Table Name: SALES_ORDER_DETAILS
1
0
ORDER_NO PRODUCT_NO QTY_ORDERED

O19001 P00001 4

O19002 P00001 10

O19003 P0345 4

O46865 P07865 1

Insert the following values in the SALES_ORDER_DETAILS table:

112
ASSIGNMENT – 21
Q1 Create table Client_master with columns Client_No, Name, City, Pincode, State and
Baldue.
Syntax:
Create table Client_master(
Client_No Varchar (6) Primary key Check (Client_No like 'C%'),
Name Varchar (20) Not null,
City Varchar (15),
Pincode INT,
State Varchar (15),
Baldue INT);
Output:

Q2. Create table Product_master with columns Product_No, Description,


QT_on_hand, Record_level, Sell_price and Cost_Price.
Syntax:
Create table Product_master(
Product_No Varchar (6) Primary key Check (Product_No like 'P%'),
Description Varchar (15) Not Null,
QT_on_hand INT Not Null,
Record_level INT Not Null,
Sell_price INT Not Null Check(Sell_price <>0),
Cost_Price INT Not Null Check(Cost_Price <>0));
Output:

113
O3. Create table salesman_master with columns Salesman_No, Salesman_Name, City,
Pincode, State and Sales_Amount.
Syntax:
Create table Salesman_master(
Salesman_No Varchar (6) Primary Key Check (Salesman_No like 'S%'),
Salesman_Name Varchar (20) Not Null,
City Varchar (20),
Pincode INT,
State Varchar (20),
Sales_Amount INT Check (Sales_Amount <>0));
Output:

O4. Create table Sales_order with columns Order_No, Client_No, Order_date,


Salesman_No and Order_Status.
Syntax:
Create table Sales_order(
Order_No Varchar (6) Primary Key Check (Order_No like 'O%'),
Client_No Varchar (6),
Order_date Date Not Null,
Salesman_No Varchar (6),
Order_Status Varchar (10) Check(Order_Status='In Process' or Order_Status='Fulfilled' or
Order_Status='Back order' or Order_Status='Canceled'),
Foreign key (Client_No) References Client_master(Client_No),
Foreign key (Salesman_No) References Salesman_master(Salesman_No));
Output:

114
Q5. Create table Sales_order_details with columns Order_No, Product_No and
QTY_Ordered.
Syntax:
Create table Sales_order_Details(
Order_No Varchar (6),
Product_No Varchar(6),
QTY_Ordered INT,
Foreign key (Order_No) References Sales_order(Order_No),
Foreign key (Product_No) References Product_master(Product_No));
Output:

Q6. Insert rows in Client_master.


Syntax: Insert into Client_master( Cloumn1,Column2,..) Values(Valeue1, Value2,…);
Output:

O7. Insert Rows in Product_matser.


Syntax: Insert into Product_master( Cloumn1,Column2,..) Values(Valeue1, Value2,…);
Output:

115
Q8. Insert Rows in Salesman_master.
Syntax: Insert into Salesman _master( Cloumn1,Column2,..) Values(Valeue1, Value2,…);
Output:

Q9. Insert Rows in Sales_order.


Syntax: Insert into Sales_order ( Cloumn1,Column2,..) Values(Valeue1, Value2,…);
Output:

Q10. Insert rows in sales_orders_details


Syntax: Insert into sales_orders_details ( Cloumn1,Column2,..) Values(Valeue1,
Value2,…);
Output:

116
Maharaja Agrasen Institute of Management Studies
Affiliated to GGS IP University; Recognized u/s 2(f) of UGC
Recognized by Bar Council of India; ISO 9001: 2015
Certified Institution Sector 22, Rohini, Delhi -110086, India;
www.maims.ac.in

Department of Commerce Academic Year: 2020-21 Semester: Vth


Assignment No.22

Course/ Subject Code:BCOM307 Subject Title: Information System Management Lab


Instructions for Students:
1. All Questions are Compulsory.
2. The student should attach proper cover page for each assignment clearly mentioning the
Assignment No.
3. Each assignment should be prepared by the student individually with proper explaination
and screenshots.
4. A4 size ruled sheets should be used for the assignment.
5. Assignment pages should be serially numbered at the bottom of page.

During online education mode, upload scanned copy of the complete assignment
including cover page latest by due date.
Question CO
Question
No. No.
Print the description and total qty sold for each product. CO3,CO4,C
1 O5
listing of product whose selling price is more than 500 with the
2
new selling price calculated as original selling price + .15%.
listing of name, city and state of client who are not in the state of
Maharashtra.
3

4 Count the total no of orders

5 Calculate the avg price of all the products

6 Count the no of product having price greater than or equal to 500.

7 Determine the max and min price for the product prices.

117
ASSIGNMENT – 22
Using Having and Group by Clauses
Q1. Print the description and total quantities sold for each product.
Syntax:
-> SELECT PM .DESCRIPTION, SUM(SOD.QTY_Ordered) FROM
PRODUCT_MASTER PM,
-> SALES_ORDER_DETAILS SOD
-> WHERE PM.PRODUCT_NO = SOD.PRODUCT_NO
-> GROUP BY DESCRIPTION;
Output:

Q2. Listing of Product whose selling price is more than 500 with the new selling price
calculated as original selling price +15%;
Syntax: Select Description, Sell_Price*0.15 “NEW_PRICE” From Product_master where
sell_price>500;
Output:

118
Q3. Listing the name city and state of client who are not in the state of Maharashtra.
Syntax: Select Name,City,state from client_master where NOT(State='Maharashtra');
Output:

Q4. Count the total No. of order.


Syntax: Select Count(Order_No) from sales_order;
Output:

Q5. Calculating the average price of all products.


Syntax: Select AVG(Sell_price) "Average price" from Product_master;
Output:

119
Q6. Count the number of products having price greater than or equal to 500.
Syntax: Select Count(Product_No) from product_master where Sell_price>=500;
Output:

Q7. Determine the max and min for the product prices.
Syntax: Select Max(Sell_price),Min(Sell_price) from product_master;
Output:

120
Maharaja Agrasen Institute of Management Studies
Affiliated to GGS IP University; Recognized u/s 2(f) of UGC
Recognized by Bar Council of India; ISO 9001: 2015
Certified Institution Sector 22, Rohini, Delhi -110086, India;
www.maims.ac.in

Department of Commerce Academic Year: 2020-21 Semester: Vth


Assignment No.23

Course/ Subject Code:BCOM307 Subject Title: Information System Management Lab


Instructions for Students:
1. All Questions are Compulsory.
2. The student should attach proper cover page for each assignment clearly mentioning the
Assignment No.
3. Each assignment should be prepared by the student individually with proper explaination
and screenshots.
4. A4 size ruled sheets should be used for the assignment.
5. Assignment pages should be serially numbered at the bottom of page.

During online education mode, upload scanned copy of the complete assignment
including cover page latest by due date.
Question CO
Question
No. No.
1 Draw an E-R diagram for an university database application where – A CO6
university has many departments, Each department has multiple
instructors, one among them is the head of the department, an instructor
belongs to only one department, each department offers multiple courses,
each of which is taught by a single instructor, A student may enroll for
many courses offered by different departments.

Now convert this diagram into separate tables.


2

3 Create these tables in MySQL.

121
ASSIGNMENT – 23
Q1: Draw an E-R diagram for a university database application where – A university has
many departments, each department has multiple instructors, one among them is the head of
the department, an instructor belongs to only one department, each department offers
multiple courses, each of which is taught by a single instructor, A student may enroll for
many courses offered by different departments

Table:
Département table: ID(Primary key), name, Course ID(For.)
Course table: Course ID (Primary key), NAME
Instructor table: ID (Primary key), name, Course ID(For.), Department ID(For.)
Student table: ID (Primary key), Name, Course ID(For.)
Syntax:
Course table: Create table Course(
-> CourseID INT Primary Key,
-> Name Char (20));
Department Table: Create table Department_ER(
-> DeptID INT Primary key,
-> Dept_Name Char(20),
122
-> CourseID INT,
-> Foreign Key (CourseID) References Course(CourseID));
Instructor table: Create table Instructor(
-> InstrctorID INT Primary key,
-> Name Char (20),
-> CourseID INT,
-> DeptID INT,
-> Foreign Key (CourseID) References Course(CourseID),
-> Foreign Key (DeptID) References Department_ER(DeptID));
Student table: Create table Student(
-> Student_ID INT Primary Key,
-> Name Char(20),
-> CourseID INT,
-> Foreign Key (CourseID) References Course(CourseID));
Output:

123
Maharaja Agrasen Institute of Management Studies
Affiliated to GGS IP University; Recognized u/s 2(f) of UGC
Recognized by Bar Council of India; ISO 9001: 2015
Certified Institution Sector 22, Rohini, Delhi -110086, India;
www.maims.ac.in

Department of Commerce Academic Year: 2020-21 Semester: Vth


Assignment No.24

Course/ Subject Code:BCOM307 Subject Title: Information System Management Lab


Instructions for Students:
1. All Questions are Compulsory.
2. The student should attach proper cover page for each assignment clearly mentioning the
Assignment No.
3. Each assignment should be prepared by the student individually with proper explaination
and screenshots.
4. A4 size ruled sheets should be used for the assignment.
5. Assignment pages should be serially numbered at the bottom of page.

Question CO
Question
No. No.
1 Insert the two values in each of the following tables. CO1,CO2,C
• Courses table O3
• Department table
• Instructor table
• Student table

2 To delete a record from instructor table where name= ‘Ayur’

3 To delete a course from a course table.

4 Show the student names who belongs to the course content writing.

5 To show the no of courses in each department.

6 List the customer name, address, city, pincode for the clients who has
placed orderno. ‘O19001’.

Create a new column ‘QTYDISP’in the table sales_order_details and


7
update the rows accordingly
Print the description and the total quantity sold for each product.
8

124
ASSIGNMENT – 24
Q1 Insert into 2 rows sin each table in database college
Syntax: Insert into table_name(Col1,Col2..) Values(Val1,Val2..);
Output:

Q2 To delete a reord from instructor name ‘Rohit’ from the instructor table
Syntax: Delete from instructor where Name='Rohit';
Output:

125
Note: ON DELETE SET NULL
A foreign Key with a SET NULL ON DELETE Means that if a record in the parent table is
deleted then the corresponding record in the child table will have will have the foreign key
field set to NULL. The records in the child table will not be deleted.
Q3. To delete a course from course table.
Syntax: Delete from course where CourseID=1001;

Q4 Show the student name who belong to the course English.


Syntax: Select Name from student where CourseID =(select CourseID from course where
Name='English');

126
Q5 To show the no. Of course in each department
Syntax: Select Dept_Name,Count(CourseID) from department_ER Group by Dept_Name;

Q6 List the customer name, city and pincode for the client who has places order Number
019001
Syntax: select name,city,pincode from client_master,sales_order where order_no = 'O19001'
and sales_order.client_no = client_master.client_no;
OR
select name,city,pincode from client_master where Client_No In(select client_No from
sales_order where Order_No='O19001');

127
Q7 To add a new column QtyDisc in sales_order_details table and update the values
accordingly.
Syntax:
Alter table: Alter table sales_order_details
-> Add Column QtyDisc INT;
Update table: Update sales_order_details
-> Set QtyDisc= 7
-> where Order_No='O19001';

Q8. Print the description and total quantity sold for each product.
Syntax: select Description, Sum(Qtydisc) from product_master PM, Sales_order_details
SOD
-> Where PM.product_no= SOD.Product_No
-> Group by Description;

128
Maharaja Agrasen Institute of Management Studies
Affiliated to GGS IP University; Recognized u/s 2(f) of UGC
Recognized by Bar Council of India; ISO 9001: 2015
Certified Institution Sector 22, Rohini, Delhi -110086, India;
www.maims.ac.in

Department of Commerce Academic Year: 2020-21 Semester: Vth


Assignment No.25

Course/ Subject Code:BCOM307 Subject Title: Information System Management Lab


Issue Date: Last Date of Submission:

Instructions for Students:


1. All Questions are Compulsory.
2. The student should attach proper cover page for each assignment clearly mentioning the
Assignment No.
3. Each assignment should be prepared by the student individually with proper explaination
and screenshots.
4. A4 size ruled sheets should be used for the assignment.
5. Assignment pages should be serially numbered at the bottom of page.

During online education mode, upload scanned copy of the complete assignment
including cover page latest by due date.
Question CO
No. Question No.
1 Create an E-R diagram of ‘LIBRARY MANAGEMENT SYSTEM’. CO6

.
Convert this ER diagram into the relational tables.
2

129
ASSIGNMENT – 25
Q1. To design an ER diagram for library management system.

ER Diagram:

130
Tables:
Books: ISBN(Primary Key), Title, Price, Staff_ID (Foreign Key), Reader_ID (Foreign Key)
Publisher: Publisher_ID (Primary Key),Name ,Year, ISBN(Foreign Key)
Reader: Reader_ID (Primary Key), name ,address
Staff: Staff_ID (Primary Key),name,
Reports: Reg_no(Primary key),book no, Issue/return, Staff_ID (Foreign Key)
Tracking Reader: Staff_ID (Foreign Key) and reader_ID (Foreign Key)
Syntax's:
1) Reader table:
Create table Reader(
Reader_ID INT Primary Key,
Name Char (20),
Address Varchar (25));
2) Staff table:
Create table Staff(
Staff_ID INT Primary Key,
Name Char (20));
3) Reports Table:
Create table Reports(
Registration_No INT Primary Key,
Book_No INT,
Issue_or_Return Date,
Staff_ID INT,
Foreign Key (Staff_ID) References Staff(Staff_ID));
4) Books Table:
Create table Books(
ISBN INT Primary Key,
Title Varchar (25),
Price INT,
Staff_ID INT,
Reader_ID INT,
Foreign Key (Staff_ID) References Staff(Staff_ID),
Foreign Key (Reader_ID) References Reader(Reader_ID));
5)Publisher Table:
Create table Publisher(
Publisher_ID INT Primary Key,
Name Varchar (25),
Year Date,
ISBN INT,
Foreign Key (ISBN) References Books(ISBN));
6) Tracking Reader table:
Create table Tracking_Reader(
Staff_ID INT,
Reader_ID INT,

131
Foreign Key (Staff_ID) References Staff(Staff_ID),
Foreign Key (Reader_ID) References Reader(Reader_ID));
Output:

132
Maharaja Agrasen Institute of Management Studies
Affiliated to GGS IP University; Recognized u/s 2(f) of UGC
Recognized by Bar Council of India; ISO 9001: 2015
Certified Institution Sector 22, Rohini, Delhi -110086, India;
www.maims.ac.in

Department of Commerce Academic Year: 2020-21 Semester: Vth


Assignment No.26

Course/ Subject Code:BCOM307 Subject Title: Information System Management Lab


Issue Date: Last Date of Submission:

Instructions for Students:


1. All Questions are Compulsory.
2. The student should attach proper cover page for each assignment clearly mentioning the
Assignment No.
3. Each assignment should be prepared by the student individually with proper explaination
and screenshots.
4. A4 size ruled sheets should be used for the assignment.
5. Assignment pages should be serially numbered at the bottom of page.

Question CO
Question
No. No.
Write a sql query for printing the first three characters of the column CO2,CO3,C
1 employee name. O4,CO5
Write a sql query for fetching the unique values of the column city from the
2
employee table.
Write a sql query for printing the name from employee table after the removal of
3
white spaces from right side.
Write a sql query for printing the name from employee table after the removal of
4
white spaces from left side.
Write a sql query for printing the name after replacing A with a.
5

6 Write a sql query for printing all details of employee which ordered by name
ascending.

7 Write a sql query for printing all details of employee which order by name
ascending and department in descending.

Write a sql query printing all details of employee excluding the names of ananya
8
and himanshi
Write a sql query to print name of employee whose name ends with a
9

Write an sql query for printing the details of employee whose hired in may 2017.
10

To find the second highest salary of employee from employee table.


11

133
ASSIGNMENT – 26
Q1 Write an SQL query for printing the first 3 characters of the column employee name.
Syntax: Select SUBSTRING(Emp_Name,1,3) from employee_bcom;
Output:

Q2 Write an SQL query for fetching the unique values of the column Location from the
employee table.
Syntax: Select Distinct(Location) from employee_bcom;
Output:

\
Q3 Write an SQL query for fetching the name of employee from employee table after
removing the white spaces from the right side
Syntax: Select RTRIM(Emp_name) from employee_bcom;
Output:

134
Q4 Write an SQL query for fetching the name of employee from employee table after
removing the white spaces from the left side
Syntax: Select LTRIM (Emp_name) from employee_bcom;
Output:

Q5 write a sql query for printing the name after replacing captial A with small a.
Syntax: select Replace(Emp_Name,'a','A') from employee_bcom;
Ouput:

135
Q6 write a sql query all details of employee which order by name ascending.
Syntax: select * from employee_bcom order by emp_name asc;
Output:

Q7 write a sql query all details of employee with order by name ascending and department
in descending.
Syntax: Select E.Emp_Name, D.Dept_Name
-> From employee_bcom E

-> left join Department D


-> on E.dept_no=D.Dept_no
-> order by emp_name ASC, dept_name DESC;
Output:

136
Q8 write an SQL query printing all details of employee excluding the names of Rohit and
Sumit.
Syntax: select * from employee_bcom where emp_name NOT IN ('Rohit','Sumit');
Output:

137
Q9 write an sql query to print the names of employees whose name ends with “T”.
Syntax: Select Emp_name from employee_bcom where emp_name like '%T';
Output:

Q10 write an sql query for printing the details of employees who were hired in JULY 2019.
Syntax: select * from employee_bcom where hire_date like '2019-07%';
Output:

Q11 To find the second highest salary from employee table.


Syntax: SELECT Emp_name, MAX(salary) AS salary FROM employee_bcom WHERE
salary < (SELECT MAX(salary) FROM employee_bcom);
Output:

138
Maharaja Agrasen Institute of Management Studies
Affiliated to GGS IP University; Recognized u/s 2(f) of UGC
Recognized by Bar Council of India; ISO 9001: 2015
Certified Institution Sector 22, Rohini, Delhi -110086, India;
www.maims.ac.in

Department of Commerce Academic Year: 2020-21 Semester: Vth


Assignment No.27

Course/ Subject Code:BCOM307 Subject Title: Information System Management Lab


Issue Date: Last Date of Submission:

Instructions for Students:


1. All Questions are Compulsory.
2. The student should attach proper cover page for each assignment clearly mentioning the
Assignment No.
3. Each assignment should be prepared by the student individually with proper explaination
and screenshots.
4. A4 size ruled sheets should be used for the assignment.
5. Assignment pages should be serially numbered at the bottom of page.

During online education mode, upload scanned copy of the complete assignment
including cover page latest by due date.
Question CO
Question
No. No.
List the various product available from the product_master table. CO2,CO3,C
1 O4,CO5
List the clients who are located in Mumbai.
2

Change the city of client_no c00005 to banglore.


3

Change the cost price of trousers to rs. 950.


4

Add a column called telephone of datatype INT to client_master table.


5

Change the name of salesman_master table to sales_master.


6

Listing of products whose selling price is more than 500 with the new selling price
7
calculated as original selling price + 15%.
Count the no of products having price>=500.
8

Find all products whose qty_on_hand is less than reorder level.


9

Determining the maximum and minimum price for the product prices.
10

139
ASSIGNMENT – 27
Q1. List the various product available from the product_master table.
Syntax: select Description from product_master;

Q2. List the clients who are located in Mumbai.


Syntax: select * from client_master where City='Mumbai';

Q3. Change the city of client No, C0001 to Banglore.


Syntax: Update client_master
-> set City='Banglore'
-> where Client_No='C0001';

140
Q4 Change the cost price of Jeans to Rs. 600
Syntax: Update Product_master
-> Set Cost_price=600
-> where Description='Jeans';

Q5 Add a coloumn called telephone of datatype INT to client_master table.


Syntax: Alter table Client_master
-> Add column Telephone INT;

141
Q6 Change the name of salesman_master table to sales_master.
Syntax: Rename table salesman_master to sales_master;

Q7 Listing of product whose selling price is more than 500 with the new selling price
calculated as orginal selling price +15%.
Syntax: select product_No, description,sell_price,(sell_price)*1.15 "new SP" from
product_master where sell_price>500;

Q8. Count the no. Of product having price >=500.


Syntax: select count(Sell_price) from product_master where Sell_price>=500;

142
Q9. Find all product whose Quantity on hand is less reorder level.
Syntax: select * from product_master where QT_on_hand<Record_level;

Q10. Determining the maximum and minimum price for the product prices.
Syntax: select Max(Sell_price)"Max Sp", Min(Sell_price)"Min SP", Max(Cost_Price) "Max
CP", MIN(Cost_Price) "MIN CP" from product_master;

143
Maharaja Agrasen Institute of Management Studies
Affiliated to GGS IP University; Recognized u/s 2(f) of UGC
Recognized by Bar Council of India; ISO 9001: 2015
Certified Institution Sector 22, Rohini, Delhi -110086, India;
www.maims.ac.in

Department of Commerce Academic Year: 2020-21 Semester: Vth


Assignment No.28

Course/ Subject Code:BCOM307 Subject Title: Information System Management Lab


Issue Date: Last Date of Submission:

Instructions for Students:


1. All Questions are Compulsory.
2. The student should attach proper cover page for each assignment clearly mentioning the
Assignment No.
3. Each assignment should be prepared by the student individually with proper explaination
and screenshots.
4. A4 size ruled sheets should be used for the assignment.
5. Assignment pages should be serially numbered at the bottom of page.

During online education mode, upload scanned copy of the complete assignment
including cover page latest by due date.
Question CO
Question
No. No.
Printing the description and total qty sold for each product. CO2,CO3,C
1 O4,CO5
Finding the non moving products i.e product not being sold.
2

Find the name and complete address for the customer who have placed order no.
3
O19001.
Add a new column product rate in the table sales_order and update the values.
4

Find the names of clients who have placed order worth rs. 1000 or more.
5

144
ASSIGNMENT – 28
Q1. Printing the description and total quantity sold for each product.
Syntax: Select description, SUM(QTY_Ordered) from Product_master PM,
Sales_order_details SOD Where PM.Product_no =SOD.Product_No Group By Description;
Output:

Q2. Finding the Non-moving product I.e. product not being sold.
Syntax: Select Product_No, Description FROM Product_Master where Product_No NOT
IN(Select Product_No from Sales_Order_Details);
Output:

145
Q3. Find the name and complete address for the customer who has placed order number
O19001.
Syntax: select Name,city,State,Pincode FROM Client_Master Where Client_No IN(Select
Client_NO From Sales_Order where Order_No='O19001');

Q4 Add a new column product rate in the sales_order_details and update the values.
Syntax:
1) Alter table Sales_order_details Add column Product_Rate INT;
2) update sales_order_details SET Product_Rate = 800 where order_NO='O19002';
Output:

146
Q5 Find the names of clients who have placed worth rupees 1,000 or more.
Syntax: Select Distinct(name) from client_master where Client_No IN(select Client_No
from sales_order where order_No IN(select order_no from sales_order_details where
QTY_Ordered*Product_Rate >=1000));
Output:

147
Maharaja Agrasen Institute of Management Studies
Affiliated to GGS IP University; Recognized u/s 2(f) of UGC
Recognized by Bar Council of India; ISO 9001: 2015
Certified Institution Sector 22, Rohini, Delhi -110086, India;
www.maims.ac.in

Department of Commerce Academic Year: 2020-21 Semester: Vth


Assignment No.29

Course/ Subject Code:BCOM307 Subject Title: Information System Management Lab


Issue Date: 17-12-2020 Last Date of Submission: 17-12-2020

Instructions for Students:


1. All Questions are Compulsory.
2. The student should attach proper cover page for each assignment clearly mentioning the
Assignment No.
3. Each assignment should be prepared by the student individually with proper explaination
and screenshots.
4. A4 size ruled sheets should be used for the assignment.
5. Assignment pages should be serially numbered at the bottom of page.

During online education mode, upload scanned copy of the complete assignment
including cover page latest by due date.
Question CO
Question
No. No.
Prepare a list of employee name, dept name and their cities for the employee and CO4,CO5
1 department who belongs to the same city.
Prepare a list with orderno, clientname and their cities for those order which taken
2
between jan 2005- jan 2006.
Wwrite a sql statement to know which employee are working for which department.
3

List all information from the sales_order table for order placed in the month of June.
4

Write a sql command to prepare a list in ascending order for the salesman who have
5
either one or more order or not yet have any order.
Prepare a list of employee name, dept name and their cities for the employee and
6
department who belongs to the same city.

148
ASSIGNMENT – 29
Q1 Prepare a list of employee name, department name and their cities for the employee and
department who belong to the same city.
Syntax:
-> select e.Emp_name,D.Dept_name, D.Location
-> from employee_bcom E, Department D
-> where E.Location=D.Location;

Q2 Write a sql command to list the order no, client name and their cities for those order
whose which taken between jan,2003 to jan,2005.
Syntax: select C.Name,C.City,S.Order_No
-> from client_master C,sales_order S
-> where S.Client_No=C.Client_No
-> And S.Order_date Between '2003-01-01' and '2005-01-01';

149
Q3 Write a SQl Statement to know which employee are working for which department.

Syntax: Select E.Emp_Name, D.Dept_Name from employee_bcom E,department D


-> where E.Dept_No=D.Dept_No;

Q4 List all information from sales_order table for the order placed in the month of july.
Syntax: select * from sales_order where Month(Order_date)=07;

150
Q5 Write A SQL command to prepare a List in ascending order for the sales man who have
either one or more order or not yet have any order.
Syntax: select A.Salesman_Nmae,B.Order_No
-> from sales_master A Left Outer join sales_order B
-> On A.Salesman_No=B.Salesman_No;

151
Maharaja Agrasen Institute of Management Studies
Affiliated to GGS IP University; Recognized u/s 2(f) of UGC
Recognized by Bar Council of India; ISO 9001: 2015
Certified Institution Sector 22, Rohini, Delhi -110086, India;
www.maims.ac.in

Department of Commerce Academic Year: 2020-21 Semester: Vth


Assignment No.30

Course/ Subject Code:BCOM307 Subject Title: Information System Management Lab


Issue Date: Last Date of Submission:

Instructions for Students:


1. All Questions are Compulsory.
2. The student should attach proper cover page for each assignment clearly mentioning the
Assignment No.
3. Each assignment should be prepared by the student individually with proper explaination
and screenshots.
4. A4 size ruled sheets should be used for the assignment.
5. Assignment pages should be serially numbered at the bottom of page.

During online education mode, upload scanned copy of the complete assignment
including cover page latest by due date.
Question CO
Question
No. No.
Draw an E-R diagram for an e-commerce site who sells the product online. CO6
1
Convert the E-R diagram into tables accordingly.
2

Make these tables in MySQL.


3

152
ASSIGNMENT – 30
Q1. Draw an E-R diagram for an e-commerce site who sells the product online.

Q2. Convert the E-R diagram into tables accordingly.


1) Customer table
Customer_ID Name Adress Email_id

Primary key

2) Item Table

Item_No Name Price

Primary Key

3) Order Table

Order_No Item_No

Primary Key Foreign Key

4) Shopping Cart

Item_No Customer_ID

Foreign Key Foreign Key

5)Company

153
Name Item_No

Foreign Key

Q3. Make these tables in MySQL.


Syntax:

1) -> Create table Customer(


-> Customer_ID INT Primary key,
-> Name Char,

-> Address Varchar(25),

-> Email_id Varchar(30));

2)-> Create table Item(


-> Item_No int primary key,

-> name char (25),


-> price int);

3)- > Create table order_table(


-> Order_No INT Primary key,

-> Item_No INT,

-> Foreign key (Item_no) references item(Item_no));

4)-> Create table Shopping_Cart(

-> Item_no INT,


-> Customer_ID INT,
-> Foreign key (Item_no) references item(Item_no),

-> Foreign key (Customer_ID) references Customer(Customer_ID));

5)-> Create table Company(


-> Name Varchar(30),
-> Item_no INT,

154
-> Foreign key (Item_no) references item(Item_no));
Output:

155
156

You might also like