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

Dbms practical-1

This document is a practical file for a DBMS lab course, detailing various SQL queries and tasks related to database management. It includes instructions for modifying table structures, writing queries to retrieve and manipulate data, creating triggers, indexes, sequences, and views, as well as stored procedures. The document serves as a guide for students to complete their assignments in the BCA 2nd semester, session 2024-28.

Uploaded by

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

Dbms practical-1

This document is a practical file for a DBMS lab course, detailing various SQL queries and tasks related to database management. It includes instructions for modifying table structures, writing queries to retrieve and manipulate data, creating triggers, indexes, sequences, and views, as well as stored procedures. The document serves as a guide for students to complete their assignments in the BCA 2nd semester, session 2024-28.

Uploaded by

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

PRACTICAL FILE

ON
DBMS Lab
BCA 2th Sem
Course code: BCA 102T
Session: 2024-28

SUBMITTED TO: SUBMITTED BY:


Dr Sumit Chauhan Name: Hunar Goel
Roll No.: 00515102024
Shift:1
INDEX
SNO. Query List
1 Modify the structure of the employee _master table to have primary key constraint
on the field employee_ no.

2 Modify the structure of order _master table to have foreign key constraint on the
field employee _no.

3 Write a query to select the vendor id, name and phone of vendor who lives in the
state of NY
4 Write a query to select the name and address of vendor whose name contain the
letter ‘a’.
5 Write a query to count the no. of vendors who fall in the state of “New York” If the
no. of vendors in the state of are 3, the result should be as. Result.

No. of vendors in the state of New York is 3


6 Write a query to select the vendor id, name and state of the vendor whose address2
field has a ‘.’ Contained in it.
7 Write a query to list the details of vendors who does not belong to the state of “NY”
and “IL
8 Write a query to list the material id, its description and stock available for those
whose unit price falls above 600 but less than 900
9 Write a query to display the information about the material value in the stock is less
than 650.
10 Write a query to change the address1 of vendor to “186, circular no. 2” whose
vendor id is V005.

11 Modify the date of birth to 1982-08-23 where employee id is 2.


Write a query to inform you about the vendor(s) in the following form: (e.g.)
12 Vendor with id as well as lives in the state of Delhi

13 Write a query to display the names of all employees whose commission is more than
10% of their basic salary and falls in the category of salesman.

14 . Write a query to select the employee no. and name of those employees who earn
salary more than the average salary of all the employees working in the organization
15 Write a query to select the minimum, maximum and average salary of the
employees working in the organization. The headings should be smi, smx and sav
respectively

16 Write a query to display the employee id, name and department no. of all employees
who are either working as salesman or miscellaneous staff. The grouping should be
department wise. Within the department, it should have all salesman together and all
miscellaneous staff together

17 .Write a query to inform you about the no. of employees working for each
department
18 Write a query to select the name, department name and location of employee who
are designated as manager
19 Write a query to display the name, designation, department name and location who
does not work in the New York
20 Write a query to list the name and id of all employees in alphabetical order of their
name.
21 Write a query to select the name and date of birth of those employees who are born
before 1985-12-31.
22 Write a query to select the name and department of those employees who have age
between 30 and 40 years.

23 Write a query to select the name and basic salary of employees who have a letter ‘e’
or‘s’ in their names. Further, modify the query list for those who does not contain
‘m’ in their names
24 Write a query to list the id, name and department no. of employees who are born in
the month of February
Part-2

SNO. Query List


1 Write a trigger on the Enrollments table to ensure that the Marks column
cannot be updated to a value greater than 100.
2 Create a trigger that logs any deletion from the Students table into an audit
table DeletedStudents(StudentID, Name, DeletedAt).
3 Create an index on the Email column of the Students table to improve the
performance of search queries.
4 Create a composite index on DepartmentID and CourseName in the Courses
table. Write a query that benefits from this index.
5 Create a sequence student_seq to generate new StudentID values starting
from 1001, incremented by 1. Use it to insert a new student record.
6 Create a sequence for generating unique EnrollmentID values and use it in a
procedure to add a new enrollment.
7 Create a view View_StudentDetails to display student name, department
name, and number of courses enrolled.
8 Create a view to list all students along with their marks in each course, but
only show those with marks greater than 75.
9 Write a stored procedure to insert a new student into the Students table using
parameters and return a success message.
10 Write a stored procedure that takes a DepartmentID as input and returns the
list of all courses under that department.
Data Base Management System Lab

Write the queries to create following tables

Table 1: Dept_master

Field Name Data type Size Constraint


Dept_no Varchar2 5 Primary key
Department_Name Varchar2 25
Department_Location Varchar2 30

Table 2: Employee_master

Field Name Data Type Size Constraint


Employee_no Varchar2 6 Primary key
Employee_name Varchar2 30
Address1 Varchar2 30
Address2 Varchar2 30
DateofBirth Date
Basic Number/Int 6,2
Commission Number/Int 6,2
Dept_no Varchar2 5 Dependent on dept_no of dept_master
Designation Varchar2 6 Default ‘mstaff’ values if any can be any of
‘cman’, ’vp’, ’mgr’, ‘slman’ and ‘mstaff’

Table 3: Vendor_master

Field Name Data type Size Constraint


Vendor_id Varchar2 6 Primary key
Vendor_name Varchar2 25
Address1 Varchar2 25
Address2 Varchar2 25
City Varchar2 20
State Varchar2 15
Pincode Number/Int 6
Phone Number/Int 10

Table 4: Material_master
Field Name Data type Size Constraint
Material_id Varchar2 6 Primary key
Material_desc Varchar2 25
Unit_price Number/Int 6,2
Unit_measure Varchar2 6
Stock Number/Int 3
Table 4: Order_master

Field Name Data type Size Constraint


Vendor_id Varchar2 6 Dependent on vendor_id of vendor_master
Material_id Varchar2 6 Dependent on material_id of material_master
Quantity_ordered Number/Int 4 Greater than zero
Date_ordered Date Default system date
Order_id Varchar2 6
Sell_price Number/Int 6,2 Greater than zero
Employee_no Varchar2 6
Delivery_status Char 1 Default ‘p’ can have value ‘f’ or ‘p’
Qty_delivered Number/Int 4 Less than quantity_ordered and greater than zero

 Students(StudentID, Name, DOB, DepartmentID, Email)

 Departments(DepartmentID, DepartmentName, HOD)

 Courses(CourseID, CourseName, DepartmentID)

 Enrollments(EnrollmentID, StudentID, CourseID, Semester, Marks)

 Faculty(FacultyID, Name, DepartmentID, Email)


Create Table
Part-1
Part-2
Insertion In Table
Part-1
Part-2
Queries

Q1. Modify the structure of the employee _master table to have primary key constraint on the
field employee_ no.

Q2. Modify the structure of order _master table to have foreign key constraint on the field
employee _no.
Q3. Write a query to select the vendor id, name and phone of vendor who lives in the state of
NY.

Q4. Write a query to select the name and address of vendor whose name contain the letter ‘a’.
Q5. Write a query to count the no. of vendors who fall in the state of “New York” If the no.
of vendors in the state of are 3, the result should be as. Result.

No. of vendors in the state of New York is 3

Q6. Write a query to select the vendor id, name and state of the vendor whose address2 field
has a ‘.’ Contained in it.
Q7. Write a query to list the details of vendors who does not belong to the state of “NY” and
“IL”.

Q8. Write a query to list the material id, its description and stock available for those whose
unit price falls above 600 but less than 900.
Q9. Write a query to display the information about the material value in the stock is less than
650.

Q10. Write a query to change the address1 of vendor to “186, circular no. 2” whose vendor id
is V005.
Q11. Modify the date of birth to 1982-08-23 where employee id is 2.

Q12. Write a query to inform you about the vendor(s) in the following form: (e.g.)

Vendor with id as well as lives in the state of Delhi


Q13. Write a query to display the names of all employees whose commission is more than
10% of their basic salary and falls in the category of salesman.

Q14. Write a query to select the employee no. and name of those employees who earn salary
more than the average salary of all the employees working in the organization.
Q15. Write a query to select the minimum, maximum and average salary of the employees
working in the organization. The headings should be smi, smx and sav respectively.

Q16. Write a query to display the employee id, name and department no. of all employees
who are either working as salesman or miscellaneous staff. The grouping should be
department wise. Within the department, it should have all salesman together and all
miscellaneous staff together.
Q17. Write a query to inform you about the no. of employees working for each department.

Q18. Write a query to select the name, department name and location of employee who are
designated as manager.
Q19. Write a query to display the name, designation, department name and location who does
not work in the New York.

Q20. Write a query to list the name and id of all employees in alphabetical order of their
name.
Q21. Write a query to select the name and date of birth of those employees who are born
before 1985-12-31.

Q22. Write a query to select the name and department of those employees who have age
between 30 and 40 years.
Q23. Write a query to select the name and basic salary of employees who have a letter ‘e’
or‘s’ in their names. Further, modify the query list for those who does not contain ‘m’ in their
names.

Q24. Write a query to list the id, name and department no. of employees who are born in the
month of February.
Part-2

Q1. Write a trigger on the Enrollments table to ensure that the Marks column cannot be
updated to a value greater than 100.

Q2. Create a trigger that logs any deletion from the Students table into an audit table
DeletedStudents(StudentID, Name, DeletedAt).
Q3. Create an index on the Email column of the Students table to improve the performance
of search queries.

Q4. Create a composite index on DepartmentID and CourseName in the Courses table.
Write a query that benefits from this index.
Q5. Create a sequence student_seq to generate new StudentID values starting from 1001,
incremented by 1. Use it to insert a new student record.

Q6. Create a sequence for generating unique EnrollmentID values and use it in a procedure
to add a new enrollment.
Q7. Create a view View_StudentDetails to display student name, department name, and
number of courses enrolled.

Q8. Create a view to list all students along with their marks in each course, but only show
those with marks greater than 75.
Q9. Write a stored procedure to insert a new student into the Students table using
parameters and return a success message.

Q10. Write a stored procedure that takes a DepartmentID as input and returns the list of all
courses under that department.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy