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

Assignment of Database

The document describes an online examination system schema including tables for students, departments, courses, faculty, and results. It then lists 13 queries to retrieve information from the schema such as student names by department, department name by username, student names by faculty, and aggregate course statistics. It also includes queries to update, delete, and alter records in the tables.

Uploaded by

Muqadas Pervez
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views

Assignment of Database

The document describes an online examination system schema including tables for students, departments, courses, faculty, and results. It then lists 13 queries to retrieve information from the schema such as student names by department, department name by username, student names by faculty, and aggregate course statistics. It also includes queries to update, delete, and alter records in the tables.

Uploaded by

Muqadas Pervez
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

MUQADDAS (Fa17-Bse-103)

UROOJ TAHIR (Fa17-bse-160)

Assignment: 4
Schema
1. Student (student id, std_name, contact no, CNIC, address, E-mail, username, password, gender
, department_no).
2. Department (department no, department name, location_id).
3. Courses (course name, course code, credit hour, and theory/lab).
4. Faculty (name, id, contact no, E-mail, address, status).
5. Result (student name, student id, course code, course title, marks, status).

Problem Statement Queries of Online Examination System:


1. Print the names of those students who study in same department as Mr. Ali is studying.
SELECT std_name FROM Students WHERE dept_no IN (SELECT dept_no FROM Students where
std_name = “Mr.Ali”).
2. Print the department name of student whose username is uroojt.
SELECT dept_name from Departments WHERE dept_no = (SELECT dept_no FROM Students
WHERE username = “uroojt”).
3. Print the names of those students who study from Mr. X.
SELECT s.std_name FROM students s, Faculty f where f.name = “Mr.X”.
4. Print the name and department name of all students.
SELECT s.std_name , d.dept_name FROM Students s, Departments d where s.dept_no =
d.dept_no.
5. Print count, maximum, minimum, and average marks for all courses.
SELECT course_code, COUNT (*), SUM (marks), MIN (marks), AVG (marks) FROM Courses
GROUP BY course_code
6. Retrieve the names of students in alphabetical order.
SELECT std_name FROM Students ORDER BY std_name.
7. Print the name of those students who have passed the course having course number CS102.
SELECT std_name, status FROM result where status =”pass” and course_code =”CS102”.
8. Delete record of those students who have not passed the course having course code EE103.
DELETE FROM Result where status =”fail” and course_code= “EE103”.
9. Change the name of departments whose location_id = 2000.
UPDATE departments SET dept_name =”BBA” where location_id = 2000.
10. Print id, name and email of faculty as FACULTY_ID, FACULTY_NAME, GMAIL
respectively whose status is HOURLY EMPLOYEES.
SELECT id AS FACULTY_ID, name AS FACULTY_NAME, email AS GMAIL from Faculty
where status = “Hourly Employees”.
11. Print the number of boys studying in department 10.
SELECT count (gender) FROM Students where gender = ‘male’ and dept_no = 10.
12. Print name and id of those students whose marks are between 21 and 49.
SELECT std_name, std_id, marks FROM Result WHERE marks > 20 and marks <50;
13. Change column type of the student_id from Integer to Varchar.
ALTER TABLE Students UPDATE COLUMN Student_id VARCHAR(20).

You might also like