Dbms practical-1
Dbms practical-1
ON
DBMS Lab
BCA 2th Sem
Course code: BCA 102T
Session: 2024-28
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.
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
Table 1: Dept_master
Table 2: Employee_master
Table 3: Vendor_master
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
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.
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.)
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.