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

Internal Lab - Assessment

The document outlines an internal practical SQL test for students in the Department of Computer Science & Engineering, focusing on table creation, data insertion, and querying. It includes tasks for creating tables for Students, Departments, Courses, and Enrollments, inserting sample data, and performing various queries, including basic, aggregate, and advanced queries with joins. Additionally, it emphasizes testing constraints such as primary and foreign keys through specific operations.

Uploaded by

amirbxr2003
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views2 pages

Internal Lab - Assessment

The document outlines an internal practical SQL test for students in the Department of Computer Science & Engineering, focusing on table creation, data insertion, and querying. It includes tasks for creating tables for Students, Departments, Courses, and Enrollments, inserting sample data, and performing various queries, including basic, aggregate, and advanced queries with joins. Additionally, it emphasizes testing constraints such as primary and foreign keys through specific operations.

Uploaded by

amirbxr2003
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Department of Computer Science & Engineering

(Artificial Intelligence / Artificial Intelligence & Machine Learning)

Internal Practical SQL Test:


Part 1: Creation of Table

1. Create Tables:
o Create the following tables with the specified columns and constraints:
▪ Students:

(StudentID (Primary Key), Name (Not Null),


Age, DepartmentID (Foreign Key referencing Departments)

▪ Departments:

DepartmentID (Primary Key),


DepartmentName (Unique, Not Null)

▪ Courses:

CourseID (Primary Key),


CourseName (Not Null),
Credits,
DepartmentID (Foreign Key referencing Departments)

▪ Enrollments:

EnrollmentID (Primary Key)


StudentID (Foreign Key referencing Students)
CourseID (Foreign Key referencing Courses)
EnrollmentDate

Part 2: Insert Data

Insert Sample Data:

o Insert at least 5 records into each table.

Part 3: Querying the Data

Basic Queries:

o Retrieve all students from the Students table.


o Find all courses with credits greater than 3.
o Get the names of students enrolled in the course "Database Systems."

Aggregate Functions:
Department of Computer Science & Engineering
(Artificial Intelligence / Artificial Intelligence & Machine Learning)

o Find the total number of students in each department.


o Calculate the average age of students in the Computer Science department.

Subqueries:

o Retrieve the names of students who are not enrolled in any courses.
o Find the department name of the student with the highest age.

Part 4: Advanced Queries

Joins:

o List all students along with the courses they are enrolled in.
o Find all students and their departments, including those who are not assigned to any
department.

Constraints Testing:

o Try to insert a student with a duplicate StudentID and verify the constraint works.
o Attempt to delete a department that has students associated with it and verify the
foreign key constraint.

You might also like