Cycle Sheet 1
Cycle Sheet 1
The primary keys are underlined and foreign keys are self-explanatory. The Dept_id column in professor
table stands for the department the professor belongs to and Prof_id column in the school table stands
for the professor who chairs the school, the same column in the department table stands for the professor
who heads the department, the domain of Term column in semester table is {Winter, Fall}.
1. Create the above tables with the following integrity constraints assigning name to integrity constraint.
i) Prof_id must have exactly five characters and their email and mobile number are unique. The email
address must have @ as one of the characters and mobile number must have exactly ten characters.
ii) Use timestamp data type without fractional parts of seconds for start time and end time column of
class table.
iii) The Sem_code should start with either ‘Win’ or ‘Fall’ and Term column can assume only one of two
values {Winter, Fall}.
iv) Email and mobile column in student table should have same characteristics as those in professor table.
v) The enroll_time in the enroll table should be of timestamp data type without fractional parts of seconds.
The grade may assume one of the values in {‘S’, ‘A’, ‘B’, ‘C’, ‘D’}
vi) Use ‘on delete cascade’ or ‘on delete set null’ clause as requirements. Use deferrable constraint, if
required.
1
vii) Additional (innovative) integrity constraints, if any, may be specified by you.
2. Enter data into the above tables. (Learn how to enter data interactively also.). Display the content of
each table. Use column formatting while displaying.
3. (i) Display name, email address and address for those students who live in Katpadi area and whose
name has an l as the third character.
(ii) Display name, email address and address for those students who are not from Tamil Nadu.
(iii) Display name, email address and address of foreign students only.
(iv) List the name of professors along with their specialty who belong to School of Medicine.
(v) Display name of the school and name of professor who chairs the school.
(vi) List course code, course name and course description in alphabetic order of course code.
(vii) Change the mobile number of a student interactively.
(viii) Remove enrollment information of a student from a particular course interactively. How would you
recover the data?
(ix) Create a duplicate of course table.
(x) Create a view for list of students (Reg_no, Sname) and the courses they have registered along with
name of professors teaching the course.
(xi) List the room number, slot, start time, end time and duration of every class held on Wednesdays in
descending order of room number.
(xii) Display the name and grade of a student in different courses underwent in fall semester 2017 – 18.
(xiii) Find out name of students who have taken Database Systems course as well as Operating Systems
course in fall semester 2016 – 17.
(xiv) Find out name of students who have taken Database Systems course but have not taken Operating
Systems course in winter semester 2017 – 18.
(xv) List the registration number and name of the students who have registered for maximum number of
credits in Winter 17-18 semester.
(xvi) List the name of the course and the number of students registered in each slot for course under
different faculty members.
(xvii) Find out the name of the students who have registered in all the courses being taught by Prof.
O’Brien in Winter 17-18.
(xviii) List the registration number of the students who registered in Database Systems course on
November 17, 2017
2
(xix) Write a query to display the grade of a student given his/her registration number and the course
name for Fall semester 17–18.
(xx) List the name of departments and the name professors who is in charge of the department.
(xxi) List the name of schools with students strength higher than 7000.
(xxii) List the name of the department(s) under school of medicine with student strength higher than the
average students of all the departments in the school.
(xxiii) Given the registration number of a student, display the total credits registered by him/her in Winter
17–18.
(xxiv) Given the registration number of a student, display her/his grade in the course she/he registered in
Fall 17–18.
(xxv) Display the name of the courses that are not being offered in Winter 17–18.
(xxvi) Write necessary SQL statement to advance the start time and end time of every class by ten minutes
in Fall 18–19.
(xxvii) Write necessary SQL statement to advance the start date and end date of Fall 18–19 semester by
one week with respect to Fall semester of 17 – 18.
(xxviii) Find out the name list of students who had secured ‘S’ grade in at least 50% of the courses cleared
by her/him.
(xxix) Given the registration number of a student, find out his/her free slots.
(xxx) Find out the name list of students who have classes in the afternoon session only a specific day of
the week.
(xxxi) Add a column named ‘Duration’ (to indicate duration of a class) with appropriate data type to the
CLASS table and populate the column from values of start time and end time columns.
(xxxii) Add a column named ‘SemesterDuration’ (indicating duration of a semester) with appropriate data
type to the SEMESTER table and populate the column from values of start date and end date columns.
(xxxiii) Find out the list of students who are undergoing MCA program.
(xxxiv) Display the name of programs and the name of school offering the program.
(xxxv) Display the name of the departments and the name of the program controlled by the department.
4. (i) Test the string manipulation functions – UPPER, LOWER, INITCAP, LENGTH, LPAD, RPAD, LTRIM,
RTRIM and TRIM, using select queries on data present in the tables. Use one query each for demonstration
of one function.
(ii) Write query to illustrate usage of NVL function and NULLIF function.
3
(iii) Display the name of the students who were born on a specified month.
(iv) Display the name of the students with a specified date of birth.
(v) Display the date of birth of a specified student in the format ‘Day of week, Month dd, yyyy’.
(vi) Display the hour and minutes of the start time and end time of a specified slot.
(vii) Display the day of week of the start date and end date of Winter semester 17–18.
(viii) Display the duration of Winter semester 17–18 in terms of number of weeks.
5. Create a sequence that starts with 1000 and is incremented by 1. Use this sequence in the following
table for entering information about at least three customers.
CUSTOMER(Cus_code, Cus_name, Cus_address, Cus_mobile)