Você está na página 1de 16

GUJARAT TECHNOLOGICAL UNIVERSITY

Master of Computer Applications (Lateral)


Year II – (Semester-III) (w.e.f. July 2016)
Indicative Practical List
Subject Name: Basic Computer Science – I
Subject Code: 3630002

1) Applications of Data Structures

1 Write a program to implement STACK using array. Perform the following operations on the
STACK:
a. PUSH
b. POP
c. CHANGE
d. PEEP
e. TOP_OF_STACK
f. IS_EMPTY
g. IS_FULL

2 Write a program to convert an infix arithmetic expression (parenthesize/unparenthesized) into


postfix notation.
3 Write a program to convert an infix arithmetic expression (parenthesize/unparenthesized) into
postfix notation.
4 Write a program to implement QUEUE using array. Perform the following operations on the
QUEUE:
a. Insert an element in the QUEUE. (Enqueue)
b. Delete an element from the QUEUE. Dequeue
5 Write a program to perform the Bubble sort.
6 Write a program to perform the Selection sort.
7 Write a program to perform the Insertion sort.
8 Write a program to perform the heap sort.
9 Write a program to perform the Quick sort.
10 Write a program to perform the Merge Sort.
11 Write a program to perform the following types of Search:
a. Linear Search
b. Binary Search
12 Write a program to implement a Singly Linked List. Perform the following operations on
Singly Linked List:
a. Insert an element
b. Delete an element
c. Find the sum of elements of the list
d. Count number of the nodes in the linked list
e. Search a given elements in the linked list.
f. Reverse the linked list.
g. Make a copy of the given linked list
h. Concatenate two linked list
i. Merge two linked

2) Applications of SQL
Introduction to SQL, Advantages of using SQL
Database concepts
SQL concepts and tools
The generic SQL Sentence Construct
Create Table
The Create Table Command
Creating a table from a table
Insertion of Data into tables
Inserting of data into a table
Inserting of data into a table from another table
Viewing data in the tables
View all rows and columns
Selected columns and all rows
Select rows and all columns
Selected columns and selected rows
Elimination of duplicates from the select statement
Sorting of data in a table
Delete Operations
Remove of all rows
Removal of a specified row(s)
Update Operations
Updating of all rows
Updating records conditionally
Modifying the structure of tables
Adding new columns
Modifying existing columns
Renaming Tables
Destroying Tables
Examining Objects created by a User
Arithmetic Operators
Logical Operators
Range Searching
Pattern Matching
Column Alias
Aggregate Functions
Scalar Functions
Date Conversion Functions
Data Constraints
Defining integrity constraints in the alter table command
Dropping integrity constraints in the alter table command
Default Value Concept
Grouping Data from tables
Manipulating dates in SQL
Subqueries, Joins, Union, Intersect and Minus Clause
Index, View, Sequence

SQL Practical List

Question 1

EMPLOYEE( emp_id, emp_name, birth_date, gender, dept_no, address, designation, salary,

experience, email)

DEPARTMENT( dept_no, dept_name, total_employees, location )

1. Create the above given tables with all necessary constraints such as
In EMP TABLE : Employee id should be primary key, Department no should be
Foreign key, employee age (birth_date) should be greater than 18 years,

salary should be greater than zero, email should have (@ and dot) sign in address,
designation of employee can be “manager”, “clerk”, “leader”, “analyst”, “designer”,
“coder”, “tester”.

In DEPT TABLE: Department no should be primary key, department name should be


unique.

2. After creation of above tables, modify Employee table by adding the constraints as
‘Male’ or ‘Female’ in gender field and display the structure .
3. Insert proper data (at least 5 appropriate records) in all the tables.
4. List all records of each table in ascending order.
5. Delete the department whose total number of employees less than 1.
6. Find the names of the employee who has salary less than 5000 and greater than 2000.
7. Display the names and the designation of all female employee in descending order.
8. Display the names of all the employees who names starts with ‘A’ ends with ‘A’.
9. Find the name of employee and salary for those who had obtain minimum salary.
10. Add 10% raise in salary of all employees whose department is ‘IT’.
11. Count total number of employees of ‘MCA’ department.
12. List all employees who born in the current month.
13. Print the record of employee and dept table as “Employee works in department ‘MBA’.
14. List names of employees who are fresher’s ( less than 1 year of experience).
15. List department wise names of employees who has more than 5 years of experience.
Question 2:

CUSTOMER (cno, cust_name, cust_phone, location,gender)

ITEM (itemno, itemname, color, weight, expire_date, price)

CUST_ITEM (cno, itemno, quantity_purchased)

1. Create the above given tables with all necessary constraints.


2. Insert proper data (at least 5 appropriate records) in all the tables.
3. List records of each table.
4. Delete the items whose price is more than 50000. .
5. Find the names of the customer who is located in same location as that of other customer.
6. Display the names of items which is black, white & brown in color.
7. Display the names of all the items whose names lies between ‘p’ and ‘s’.
8. Find the item which is having less weight.
9. Add one month more to those items whose item no =40.
10. Count total number of items which is going to expire in next month
11. List all customers whose phone number starts with ‘99’.
12. Display total value (qty*price) for all items.
13. List customer details who has purchased maximum number of items
14. Display total price item wise.
15. List name of items, customer details and qty purchased.
Question 3

EMPLOYEE(emp_id, emp_name, skills, gender, date_birth, manager_id)

PROJECT(proj_id, type_of_project, status)

PROJ_ASSIGNED (emp_id, proj_id, starting_date, number_of_days)

1. Create the above given tables with all necessary constraints.


2. After creation of above tables, modify Project table by adding the constraints
‘Pending’,’Cancel’,’Incomplete’ in Status field and display the structure .
3. Insert proper data (at least 5 appropriate records) in all the tables.
4. Display all records (by joining all three tables).
5. Delete the project whose status is ‘cancel’ and display the records
6. Find the names of the employee who has same skills as that of manager
7. Display the name of all projects whose type is ‘HR’ in descending order
8. Display the project whose start date is todays date.
9. Find the name of employee who has assign project ‘ERP’.
10. As project no. 10 is extended, add 1 month more to project.
11. Count total number of projects which is going to start in next week
12. List all employee who has more than one project assigned
13. List the name of employee who has not assigned any project.
14. Find the name and age of all female employees
15. Find the projects which is assigned to an employee last week.

Question 4

CUSTOMER (Custno, cname, state, phone, gender)

ITEM (itemno, Itemname, Itemprice, Qty_onhand)

INVOICE (Invno, invDate, Custno)

INVITEM (Invno, Itemno, Qty_sold)


1. Create the above given tables with all necessary constraints.
2. Insert proper data (at least 5 appropriate records) in all the tables.
3. Display records of each table in ascending order.
4. Display Item name, Price in sentence form using concatenation.
5. Find total value of each item based on quantity on hand
6. Find customers who are from state of Gujarat.
7. Display items with unit price of at least Rs. 100
8. List items whose range lies between Rs. 200 and Rs. 500
9. Which customers are from lalbaug area of Ahmedabad, Baroda and Patan.
10. Find all customers whose name start with Letter ‘P’.
11. Find name of items with ‘W’ in their name.
12. Sort all customers alphabetically
13. Sort all items in descending order by their prices.
14. Display all customers from M.P alphabetically
15. Display invoices dates in ‘September 05, 2007’ format.
16. Find total, average, highest and lowest unit price
17. Count number of items ordered in each invoice
18. Find invoices in which three or more items are ordered.
19. Find all possible combination of customers and items ( use Cartesian product)
20. Display all item quantity and item price for invoices ( natural join)
21. Find total price amount for each invoice.
22. Use outer join to display items ordered as well as not ordered so far.
23. Find invoices with ‘Gear’ in their item name.
24. Display name of items ordered in invoice number 1001
25. Find the items that are cheaper than ‘Bullet’.
26. Create a table ( namely guj_cust) for all Gujarat customer based on existing
customer table

27. Copy all M.P customers to the table with Gujarat customers
28. Rename Guj_cust table to MP_cust table.
29. Find the customers who are not in Gujarat or M.P
30. Delete rows from customer table that are also in MP_cust table
31. Find the items with top three prices
32. Find two items with lowest quantity on hand
33. Create a simple view with item names and item price only
34. Create a sequence that can be used to enter new items into item table
35. Add a new item into item table with sequence just created.
36. Create a index file to speed up a search based on customer name
37. Lock customer Mr. Shah record to update the state and phone no.
38. Give everybody select and insert rights on your item table
39. Revoke the insert option on item table from user ‘Roshi’.
Question 5:

Consider the DUAL and data dictionary tables/views to solve the following Queries.

1. Write a query to add 15 days to the current date.


2. Find out the names of all the constraints associated with current tables in the system.
3. Write a query to Add and subtract 5 months from the current month.
4. Find out the ASCII equivalent of character ‘M’.
5. Write a query to calculate the Date difference between current date and 20/05/2015.
6. Write a query to Calculate the number of months between current date and 03/03/2016.
7. Write a query to find the last day of the month.
8. Find out the second occurrence of ‘or’ from third position in the string ‘corporate floor ‘.
9. Find out log to the base 3 of 81.
10. Find out how many days are left in the current month.
11. Convert the string ‘gujarat technological university’ so that first character of each work is
in capital.
12. Find out the character equivalent of ASCII 67, 65 and 84.
13. Convert the string ‘jack and jue’ Into ‘black and blue’.
14. Round off the date 27-July-2016 to the current year.
15. Find out the user name and user id off currently logged on user.
Question 6:
1) Create the following tables using the SQL create statement

Table Name: client_master

Description: Use to store information about clients.

Column Name Data Type Size Attribute

Client_no Varchar2 6 Primary key / First letter must


start with ‘C’

Not Null
Name Varchar2 20

Address1 Varchar2 30

Address2 Varchar2 30

City Varchar2 15

State Varchar2 15

Pincode Number 6

Bal_due Number 10,2

Table Name: product_master

Description: Use to store information about products.

Column Name Data Type Size Attributes

Product_no Varchar2 6 Primary key / First letter must


start with ‘P’

Not Null
Description Varchar2 5
Not Null
Profit_percent Number 2,2
Not Null
Unit_measure Varchar2 10
Not Null
Qty_on_hand Number 8
Not Null
Recover_lvl Number 8 Not Null, cannot be 0.

Sell_price Number 8,2 Not Null, cannot be 0.

Cost_price Number 8,2

Table Name: salesman_master

Description: Use to store information about salesman working in the company.

Column Name Data Type Size Attributes

Salesman_no Varchar2 6 Primary key / First letter must


start with ‘P’

Not Null
Salesman_name Varchar2 20
Not Null
Address1 Varchar2 30

Address2 Varchar2 30

City Varchar2 20

Pincode Varchar2 6

State Varchar2 20
Not Null, cannot be 0.
Sal_amt Varchar2 8,2
Not Null, cannot be 0.
Tgt_to_get Number 6,2
Not Null
Ytd_sales Number 6,2

Remarks Varchar2 60

Table Name: sales_order

Description: Use to store information about order.

Column Name Data Type Size Attributes

S_order_no Varchar2 6 Primary key / First letter must start with


‘O’
S_order_date Date Foreign Key reference client_no of
client_master table.
Client_no Varchar2 6

Foreign Key reference salesman_no of


Dely_addr Varchar2 25 salesman_master table.
Salesman_no Varchar2 6 Delivery : part (P) / Full (F) ,Default ‘F’

Dely_type Char 1 Cannot be less than s_order_date


Billed_yn Char 1 Values (‘In
Dely_date Char Process’,’Fulfilled’,BackOrder,’Canceled’)

Order_status Varchar2 10

1. Create the above given tables with all necessary constraints.


2. Insert proper data (at least 5 appropriate records) in all the tables.
3. Display records of each table in ascending order.
4. Find out the names of all the clients.
5. Retrieve the list of names and the cities of all the clients.
6. Find out the clients who stay in a city whose second letter is 'a'.
7. Find the list of all clients who stay in city 'Bombay' of city 'Delhi' or city 'Madras'
8. List all the clients who are located in Bombay.
9. Display the order information for client_no 'C00001' and 'C00002'.
10. Find the product with description as '1.44 Drive' and '1.22 Drive'.
1. Find the products whose selling price is grater than 2000 and less than or
11. Equal to 5000.
2. Find the products whose selling price is more than 1500 and also find the
12. New selling price as original selling price * 15.
3. Rename the new column in the above query as new_price.
4. Find the product s whose cost price are less than 1500.
5. List the products in sorted order of their description.
6. Calculate the square root of the price of each product.
7. Divide the cost of product '540 HDD' by difference between its price and 100.
8. List the names, city and state of clients not in the state of 'Maharashtra'.
9. List the product_no, description, sell_price of products whose description.
10. Count the total number of order.
11. Calculate the average price of all the products.
12. Calculate the minimum price of products
13. Find out the products which has been sold to 'Ivan Bayross'.
14. Find the product_no and description of non-moving products.
15. Change the selling price of '1.44 Floppy Drive' to Rs. 1150.00.
16. Delete the record with order number 'O19001' from the order table.
Question 7:

STUDENT ( SNO, SNAME, SPECIALISATION, LEVEL, AGE)

CLASS( CLASSNAME, CLASSTIME, ROOMNO, FNO)

ENROLLED(SNO, CLASSNAME)

FACULTY(FNO, FNAME, DEPTNM)

Primary key and foregin key should be added as per basic requirements and also Following
Constraints should be added.

a. Level fields has values like ‘JR’ for junior and ‘SR’ for senior.

b. Age cannot be more than 18 years.

c. Room number starts with ‘R’ e.g. R101 etc..

d. Specialization field has valid values like ‘Database’, ‘Networks’, ‘Multimedia’,’Maths’.

e. Class time should be in the range 10.00 am to 4.45 pm.

SOLVE THE FOLLOWING QUERIES

1. Find the name of the class in which Mr. Anil is teaching.


2. Find the name of faculty who is taking subject ‘ Network Security’.

3. Find the name of all seniors (SR) who are enrolled in class taught by Ms. Rekha.

4. Find the name of students who are not enrolled in any class.

5. Find the name of all the classes that meet in Room R105.
Question 8:

HOSTEL (HNO, HNAME, HADDR, TOTAL_CAPACITY, WARDEN)

ROOM (HNO, RNO, RTYPE, LOCATION, NO_OF_STUDENTS, STATUS)

CHARGES (HNO, RTYPE, CHARGES)

STUDENT (SID, SNAME, SADDR, FACULTY, DEPT, CLASS, HNO, RNO)

FEES (SID, FDATE, FAMOUNT)

The STATUS field tells us whether the room is occupied or vacant. The charges represent the
term fees to be paid half yearly. A student can pay either the annual fees at one time or the half
yearly fees twice a year.

1. Create the above given tables with all necessary constraints.


2. Insert proper data (at least 5 appropriate records) in all the tables.
3. Display records of each table.
4. Add a check constraint to the room table so that the room type allows the following
values only – ‘s’ for single, ‘d’ for double, ‘t’ for triple and ‘f’ for four-seater.
5. Display the total number of rooms that are presently vacant.
6. Display number of students of each faculty and department wise staying in each hostel.
7. Display hostels, which have at least one single-seated room.
8. Display the warden name and hostel address of students of Computer Science
department.
9. Display those hostel details where single seated or double-seated rooms are vacant.
10. Display details of hostels occupied by medical students.
11. Display hostels, which are totally occupied to its fullest capacity.
12. List details about students who are staying in the double-seated rooms of Chanakya
Hostel.
13. Display the total number of students staying in each room type of each hostel.
14. Display details about students who have paid fees in the month of Nov. 2015.
15. For those hostels where total capacity is more than 300, display details of students
studying in Science faculty.
16. Display hostel details where there are at least 10 vacant rooms.
17. Display details of students who have still not paid fees.
18. Display those hostels where single-seated room is the costliest.

Question 9:

DOCTOR(DNO, DNAME, SPECIALIZATION, CLINIC_ADDR)

MEDICINE(MNO, MNAME, TYPE, CONTENT, MANUFACTURER)

DISEASE(DISEASE_NAME, SYMPTOM1, SYMPTOM2, SYMPTOM3)

TREATMENT(TNO, DNO, DISEASE_NAME, MNO, DOSAGE, AVG_CURE_TIME)

1. Create the above given tables with all necessary constraints.


2. Insert proper data (at least 5 appropriate records) in all the tables.
3. Display records of each table in ascending order.
4. Count total number of doctors which has not given any treatment.
5. Display total number of disease treated by every doctor.
6. Remove disease “polio” from disease table as well as treatment table.
7. Delete all those treatment related to liver of Dr. kiran.
8. Create index on dno, Disease name in the treatment table.
9. Display details of doctors who treat migraines.
10. What is the maximum dosage of “penicillin” prescribe by the doctor for the treatment
of any disease?
11. Display all Chennai doctors who treat cancer.
12. Which doctor have no treatment for “depression” ?
13. Create a view which contains the treatment and doctors details. Make sure that no
body is allowed to modify any detail in the view.
Question 10:

CREATE BELOW MENTIONED TABLES WITH GIVEN CONSTRAINTS.

TRAIN _MASTER:

FIELD NAME DATA TYPE CONSTRAINTS

TRAIN NUMBER VARCHAR2(6) PRIMARY KEY AND LAST TWO


CHARS

SHOULD BE 'DN' OR 'UP'

TRAIN NAME VARCHAR2(25) NOT NULL

ARRIVAL TIME DATE NOT NULL

DEPARTURE TIME DATE NOT NULL

NO OF HOURS NUMBER(5,2) NOT NULL

SOURCE STATION VARCHAR2(25) NOT NULL

END STATION VHARCHAR2(25) NOT NULL

PASSENGER_DETAILS:

FIELD NAME DATA TYPE CONSTRAINTS

TICKET NUMBER NUMBER(5)

TRAIN NUMBER VARCHAR2(6) FOREIGN KEY REFERENCE TO


TRAIN_MASTER

THIS RELATED RECORD


SHOULD BE DELETED

IF MASTER RECORD IS
DELETED.
SEAT NUMBER NUMBER(2) NOT NULL

PASSENGER NAME VARCHAR2(35) NOT NULL

AGE NUMBER(2) NOT NULL

GENDER CHAR(1) SHOULD BE 'M' FOR MALE OR 'F'


FOR FEMALE

TRAVEL DATE DATE

CLASS VARCHAR2(4) SHOULD BE IN (IA, IIA, IIIA, IC,


II)

TRAIN_SEAT_MASTER:

FIELD NAME DATA TYPE CONSTRAINTS

TRAIN NUMBER VARCHAR2(6) FOREIGN KEY REFERENCE TO


TRAIN_MASTER

THIS RELATED RECORD SHOULD


BE DELETED

IF MASTER RECORD IS DELETED.

CLASS VARCHAR2(4) SHOULD BE IN (IA, IIA, IIIA, IC, II)

TOTAL SEATS NUMBER(2) SHOULD BE >= 25 AND <= 90

TRAIN_DAY_MASTER:

FIELD NAME DATA TYPE CONSTRAINTS

TRAIN NUMBER VARCHAR2(6) FOREIGN KEY REFERENCE TO TRAIN_MASTER

THIS RELATED RECORD SHOULD BE DELETED

IF MASTER RECORD IS DELETED.


DAY VARCHAR2(3) VALUE SHOULD BE IN 'MON' … TO … 'SUN'

1. Create the above given tables with all necessary constraints.


2. Insert proper data (at least 5 appropriate records) in all the tables.
3. Display records of each table in ascending order.
4. Alter table ‘Passenger details’ and drop not null constraints on passenger name
5. Create a copy of train master table with data.
6. Give all train names starting from “Ahmedabad” and going to “Bombay” on Tuesday or
Wednesday. The train names should be sorted ascending order.
7. Get the classwise seat availability on 10-8-2016 for train 9012DN bound gujarat express.

Reference Books:

a. SQL By Ivan Byross, BPB Publications.


b. Kevin Loney, Oracle Database 11g :The Complete Reference, Oracle Press,
McGrawHill
c. Ms. Anjali Jivani and Ms. Amisha Shingala , “ Practice book on SQL and
PL/SQL with examples”, Nirav and Roopal Publications, Third Edition

Você também pode gostar