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

DBMS Lab 5 Tasks

The document outlines Lab #5 for a DBMS course, focusing on SQL aggregate functions and sub-queries using PostgreSQL. It details the design and implementation of a relational database with three tables: Student, Courses, and Enrollment, including their attributes and sample data. Additionally, it provides tasks for writing SQL queries to manipulate and retrieve data based on specified criteria.
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)
4 views2 pages

DBMS Lab 5 Tasks

The document outlines Lab #5 for a DBMS course, focusing on SQL aggregate functions and sub-queries using PostgreSQL. It details the design and implementation of a relational database with three tables: Student, Courses, and Enrollment, including their attributes and sample data. Additionally, it provides tasks for writing SQL queries to manipulate and retrieve data based on specified criteria.
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/ 2

-CS-232 DBMS Lab #5 Spring 2025

LAB 05
SQL AGGREGATE FUNCTIONS,
SUB-QUERIES
The objective of this lab is to design and implement a relational database using PostgreSQL, and to practice
writing SQL queries to retrieve and manipulate data. You will work with three tables: Student, Courses, and
Enrollment. The goal is to understand relationships between tables, enforce data integrity, and generate
meaningful queries.

Tables Description:
1. Student Table:
o SID (Primary Key): Unique identifier for each student.
o SNAME: Name of the student.
o Faculty: Faculty or department the student belongs to.
2. Courses Table:
o CID (Primary Key): Unique identifier for each course.
o CNAME: Name of the course.
o CreditHour: Number of credit hours for the course.
3. Enrollment Table:
o CID (Foreign Key): References the Courses table.
o SID (Foreign Key): References the Student table.
o Semester: Semester in which the student is enrolled (e.g., Fall, Spring).

Sample Data:

INSERT INTO Student (SID, SNAME, Faculty) VALUES


(1, 'John Doe', 'Computer Science'),
(2, 'Jane Smith', 'Mathematics'),
(3, 'Alice Brown', 'Physics'),
(4, 'Bob Johnson', 'Chemistry'),
(5,'Alice Smith','Electronics');

INSERT INTO Courses (CID, CNAME, CreditHour) VALUES


(101, 'Database Systems', 3),
(102, 'Calculus I', 4),
(103, 'Quantum Mechanics', 3),
(104, 'Organic Chemistry', 4);

INSERT INTO Enrollment (CID, SID, Semester) VALUES


(101, 1, 'Fall'),
(102, 2, 'Spring'),
(101, 3, 'Fall'),
(101, 4, 'Spring'),
(103, 1, 'Spring');
Write SQL queries to perform the following tasks:
 Retrieve all students who are not enrolled in any course.
 Retrieve all courses that have no students enrolled.
 List all students enrolled in Database System as well as Quantum Mechanics
 List all the students who are never enrolled in Calculus-I course.
 List all the courses that are offered in Fall as well as spring semester.

You might also like