0% found this document useful (0 votes)
15 views2 pages

University Database SQL Assignment

The document outlines a university database assignment focused on SQL solutions. It includes SQL commands for inserting records into Students, Courses, and Enrollments tables, as well as queries to retrieve specific data based on given criteria. The queries cover student birth dates, course departments, credit hours, enrollment counts, and enrollment dates.

Uploaded by

muhammadusman0m0
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)
15 views2 pages

University Database SQL Assignment

The document outlines a university database assignment focused on SQL solutions. It includes SQL commands for inserting records into Students, Courses, and Enrollments tables, as well as queries to retrieve specific data based on given criteria. The queries cover student birth dates, course departments, credit hours, enrollment counts, and enrollment dates.

Uploaded by

muhammadusman0m0
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

University Database Assignment – SQL Solution

Student Name: __________________________

Roll Number: ____________________________

Course: _________________________________

Date: _________________________________

Question 1: Insert One Record into Each Table


 🔹 Students Table:

INSERT INTO Students (student_id, first_name, last_name,


date_of_birth, gender, email, phone, admission_date)
VALUES (1, 'Ali', 'Khan', '2002-06-15', 'Male',
'[Link]@[Link]', '03123456789', '2021-09-01');

 🔹 Courses Table:

INSERT INTO Courses (course_id, course_name, department, credits,


instructor_name)
VALUES (101, 'Database Systems', 'Computer Science', 4, 'Dr. Ayesha
Siddiqui');

 🔹 Enrollments Table:

INSERT INTO Enrollments (enrollment_id, student_id, course_id,


enrollment_date, grade)
VALUES (1001, 1, 101, '2023-02-15', 'A');

Question 2: SQL Queries for Given Statements


 🔹 List all students born between 2000 and 2005 (format YYYY-MM-DD):

SELECT * FROM Students


WHERE date_of_birth BETWEEN '2000-01-01' AND '2005-12-31';
 🔹 Find all courses in the 'Computer Science' or 'Mathematics' departments:

SELECT * FROM Courses


WHERE department IN ('Computer Science', 'Mathematics');

 🔹 List courses with more than 3 credits, ordered by credits in descending order:

SELECT * FROM Courses


WHERE credits > 3
ORDER BY credits DESC;

 🔹 List students enrolled in more than 3 courses:

SELECT student_id
FROM Enrollments
GROUP BY student_id
HAVING COUNT(course_id) > 3;

 🔹 Find students who are enrolled after January 31, 2023:

SELECT * FROM Enrollments


WHERE enrollment_date > '2023-01-31';

You might also like