0% found this document useful (0 votes)
10 views13 pages

Database Tutorial

The document outlines a tutorial for a Database Management Systems II course, focusing on designing an EER diagram and creating SQL queries. It includes tasks for creating, altering, and deleting database tables related to a university system, as well as inserting, updating, and retrieving data. Specific requirements for entities such as students, programs, and mentorship relationships are detailed throughout the tutorial.
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)
10 views13 pages

Database Tutorial

The document outlines a tutorial for a Database Management Systems II course, focusing on designing an EER diagram and creating SQL queries. It includes tasks for creating, altering, and deleting database tables related to a university system, as well as inserting, updating, and retrieving data. Specific requirements for entities such as students, programs, and mentorship relationships are detailed throughout the tutorial.
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/ 13

BSc Degree in Information Technology

IT 236 Database Management Systems II


DBMS 2 Tutorial 1:
Question Paper
D.D.C.Madushani
BSC/WD/24/45/11
Q1.
University System EER Diagram and Relational Model Design
Design an EER Diagram for ABC University based on the following specifications:
1. Include a composite attribute.
2. Include a derived attribute.
3. Include multi-valued contact numbers.
4. Programs should be categorized into sub classes: Undergraduate, Postgraduate, and
Diploma.
5. Students can mentor other students as part of a mentorship program (recursive
relationship):-
 A student can mentor multiple other students.-
 A student can only have one mentor.-
 Mentors must be in the same or a higher academic year than their mentees.

Ensure the design includes entities such as:- Students- Programs- Courses- Enrolment
Q2.
DDL Questions Section 1:
CREATE Command
 Write an SQL query to create a table named `Student` with there levant fields and key constraints.

 Write an SQL query to create a `Contact` table to store multiple phone numbers for students. The
table should have the relevant fields and key constraints.

 Write an SQL query to create a `Program` table with there levant fields and key constraints.
Ensure the table supports subclasses for Undergraduate, Postgraduate, and Diploma programs.
 Write an SQL query to create an `Enrolment` table with there levant fields and key constraints.

 Write an SQL query to create a `Mentorship` table to store information about the mentoring
relationships between students. Ensure it captures the recursive relationship constraints.
 Write an SQL query to create a backup table named `Student_bkp` with the same structure as the
`Student` table.
Section 2:
ALTER Command
 Write an SQL query to add a column named `Email` VARCHAR(100)to the `Student` table.

 Write an SQL query to modify the `ProgramName` column in the `Program` table to have a maximum
length of 150 characters.

 Write an SQL query to rename the `ContactNumber` column in the `Contact` table to
`PhoneNumber`(VARCHAR(15)).

Write an SQL query to add both a primary key constraint and a foreign key constraint to the `Enrolment`
table:-

 Set the `EnrolmentID` column as the primary key.-


 Set the `StudentID` column as a foreign key referencing the `StudentID` column in the `Student`
table.
Section 3:
DROP Command
 Write an SQL query to drop the `Student_bkp` table from the database.

Q3.
DML Questions Section 1:
INSERT Command
 Write an SQL query to insert a single record into the `Student` table with your Personal Details (your
self).

 Write SQL queries to insert 9 more rows of data into the `Student` table.
Ensure:- Students have Sri Lankan names and addresses.-
Include various dates of birth and mentor relationships where applicable.
 Write SQL queries to insert 10 rows of data into the `Contact` table for the students.
Ensure:-
Each student has multiple phone numbers, including mobile and landline numbers.

 Write SQL queries to insert 7 rows of data into the `Program` table.
Ensure:-
Programs are categorized as Undergraduate, Postgraduate, or Diploma.-
Include realistic program names and durations.
 Write SQL queries to insert 10 rows of data into the `Enrolment` table.
Ensure:-
Each enrolment is associated with a specific student and program.-
Include enrolment dates and statuses.

 Write SQL queries to insert all rows from the `Student` table into a backup table `Student_bkp` using
`INSERT INTO SELECT`.

Section 2:
UPDATE Command
 Write an SQL query to update the `Address` of a specific student by appending "Sri Lanka" to their
existing address.
 Write an SQL query to change the `ProgramName` of a specific program to "Advanced Diploma in IT".

 Write an SQL query to assign a new mentor to a specific student (update etheir `MentorID`).

 Write an SQL query to update the `ContactNumber` of a specific student in the `Contact` table to a new
mobile number(e.g., `+94771234567`).

Section 3:
DELETE Command
 Create a backup tables of enrolments (enrolments_bkp)

 Write an SQL query to delete all enrolments for a specific program.

 Write an SQL query to delete all students who are not enrolled in any program.

 Write an SQL query to delete a specific program based on its `ProgramID`.


Section 4:
TRUNCATE Command
 Write an SQL query to delete all records from the `enrolments_bkp` table while keeping the table
structure intact.

Section 4:
SELECT Command
 Write an SQL query to retrieve all students who are minors(age below18)along with their mentor
details.

 Write an SQL query to fetch all programs along with the total number of students enrolled in each
program.

 Write an SQL query to retrieve all enrolments fora specific student, sorted by enrolment date in
descending order
.  Write an SQL query to fetch the total number of students enrolled in each program, grouped by
`ProgramID`.

 Write an SQL query to retrieve the maximum, minimum, and average age of students enrolled in the
university.

 Write an SQL query to fetch all students whose names start with the letter "K".

 Write an SQL query to count the total number of phone numbers for eachstudent.

 Write an SQL query to fetch the details of programs that have students enrolled in the Undergraduate
category only.
 Write an SQL query to retrieve the to p3 students with the highest number of enrolments.

 Write an SQL query to retrieve all students who are enrolled in programs lasting more than 2 years.

You might also like