0% found this document useful (0 votes)
18 views16 pages

DB Lab Assignment 3

Uploaded by

mominaqureshi101
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)
18 views16 pages

DB Lab Assignment 3

Uploaded by

mominaqureshi101
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

SUBMITTED BY :

EMAN FATIMA

SUBMITTED TO :

SIR HUSSAIN

REGISTRATION NO :

242201060

SUBJECT :

DATABASE (LAB)
Scenario:
You are given a database with three related
tables:
• Students (student_id, name, email)
• Courses (course_id, course_name, credit_hour)
• Enrollments (enrollment_id, student_id, course_id,
enrollment_date)
Where:
• student_id is the Primary Key in Students
• course_id is the Primary Key in Courses
• enrollment_id is the Primary Key in Enrollments
• student_id and course_id in Enrollments are Foreign Keys

Tasks:
1. Create the above three tables with proper Primary Key and
Foreign Key constraints.
Student table:
Course table:
Enrollement table:

2. Insert at least 5 sample records in each table.


Student table:
Course table:
Enrollment table:

3. Write an SQL query to display the names of students along


with the course names they are enrolled in.
4. Write an SQL query to list all courses and the students
enrolled in each course.
5. Write an SQL query to find the names of students who have
not enrolled in any course.
6. Write an SQL query to display all courses and the number of
students enrolled in each course.
7. Write an SQL query to display the student name, course
name, and enrollment date.
8. Write an SQL query to find courses that have no
enrollments.
9. Write an SQL query to display each student's name along
with the total number of courses they have enrolled in.
10. Write an SQL query using a RIGHT JOIN to list all students
and any course data where applicable.

You might also like