Tut 6 Questions
Tut 6 Questions
1. Write a database description for each of the relations shown, using SQL DDL (shorten,
abbreviate, or change any data names, as needed for your SQL version). Assume the
following attribute data types:
StudentID (integer, primary key), StudentName (25 characters), FacultyID (integer,
primary key), FacultyName (25 characters), CourseID (8 characters, primary key),
CourseName (15 characters), DateQualified (date), SectionNo (integer, primary key),
Semester (7 characters)
FROM Question >=2, use table above to write SQL Query, Faculty has the same meaning as
Instructor.
2. Create an SQL VIEW for following table
3. Write SQL data definition commands for each of the following queries:
a. Create two different forms of the INSERT command to add a student with a student
ID of 65798 and last name Lopez to the Student table.
INSERT INTO `student` VALUES('65789','Lopez');
INSERT INTO `student` (`studentID`,`studentName`)VALUES ('65788'
,'Lopez’);
b. Now write a command that will remove Lopez from the Student table.
DELETE FROM student WHERE studentName='Lopez';
c. Create an SQL command that will modify the name of course ISM 4212 from
Database to Introduction to Relational Databases.
UPDATE course SET CourseName='Relational
Databases' WHERE CourseID='ISM 4212';
c. What is the smallest section number used in the first semester of 2008?
SELECT MIN(`SectionNo`) FROM `section` WHERE Semester = 'I-
2008';
a. How many students are enrolled in Section 2714 in the first semester of 2008?
SELECT COUNT(`studentID`) FROM `registration` WHERE `SectionNo`=
'2714'
b. Which faculty members have qualified to teach a course since 1993? List the
faculty ID, courseID, and date of qualification.
SELECT F.FacultyID, C.CourseID, Q.DateQualified FROM `faculty`
AS F, `course` AS C, `qualified` AS Q WHERE YEAR(Q.DateQualifie
d) >= '1993' AND C.CourseID=Q.CourseID;
a. What are the courses included in the Section table? List each course only once.
SELECT DISTINCT courseid FROM `section`;
c. List the students who are enrolled in each course in Semester I, 2008. Group the
students by the sections in which they are enroll