0% found this document useful (0 votes)
14 views5 pages

DBMS Solutions

The document contains SQL statements that create tables, insert, update, delete and select data from the tables. The tables created are Student, Faculty, Course, Qualified, Section and Registration. Relationships are defined between the tables using foreign keys. Various queries are written to select, count, group and filter data from the tables.

Uploaded by

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

DBMS Solutions

The document contains SQL statements that create tables, insert, update, delete and select data from the tables. The tables created are Student, Faculty, Course, Qualified, Section and Registration. Relationships are defined between the tables using foreign keys. Various queries are written to select, count, group and filter data from the tables.

Uploaded by

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

1.

CREATE TABLE Student_TBL


(
StudentID INT NOT NULL
,StudentName VARCHAR(25)
,CONSTRAINT Student_PK PRIMARY KEY (StudentID));
CREATE TABLE Faculty_TBL
(
FacultyID INT NOT NULL
,FacultyName VARCHAR(25)
,CONSTRAINT Faculty_PK PRIMARY KEY (FacultyID));
CREATE TABLE Course_TBL(
CourseID CHAR(8)NOT NULL
,CourseName VARCHAR(15)
,CONSTRAINT Course_PK PRIMARY KEY (CourseID));
CREATE TABLE Qualified_TBL(
FacultyID INT NOT NULL
,CourseID CHAR(8)NOT NULL
,DateQualified DATE
,CONSTRAINT Qualified_PK PRIMARY KEY (FacultyID, CourseID)
,CONSTRAINT Qualified_FK1 FOREIGN KEY (FacultyID) REFERENCES
Faculty_TBL(FacultyID)
,CONSTRAINT Qualified_FK2 FOREIGN KEY (CourseID) REFERENCES Course_TBL(CourseID))
;
CREATE TABLE Section_TBL(
SectionNo INT NOT NULL
,Semester CHAR(7)NOT NULL
,CourseID CHAR(8)NOT NULL
,CONSTRAINT Section_PK PRIMARY KEY (SectionNo, Semester, CourseID)
,CONSTRAINT Section_FK FOREIGN KEY (CourseID) REFERENCES Course_TBL(CourseID));

2.
It is not fully normalized

3.
4.
a.
Alter Table STUDENT add (Class varchar(10));
b.
Drop table REGISTERATION;
c.
Before removing COURSE table, I will take into account the fact that the attribute
COURSE ID of the COURSE table is associated with the QUALIFIED and
SECTION table as a Foreign Key. By removing it, it will cause a problem in the
database.

d.
ALTER TABLE MODIFY (FacultyName varchar(40));

5.
a.
INSERT INTO Student VALUES (65798, ‘Lopez’);
INSERT INTO Student (StudendID, StudentName)VALUES (65789, ‘Lopez’);

b.
DELETE FROM Student WHERE StudentID = 65798;

c.
DELETE FROM Student WHERE StudentName = ‘Lopez’;

d.
UPDATE Course
SET CourseName = ‘Introduction to Relational Databases’
WHERE CourseID = ‘ISM 4212’;

6.
a.
Select REGISTERATION.Student.ID from SECTION, REGISTERATION where
SECTION.CourseID in (select CourseID from COURSE Where CourseName =
‘Database’ or ‘Networking’);

b.
Select FacultyID from QUALIFIED where QUALIFIED.CourseID in (select
CourseID from COURSE where CourseName not in (‘Syst Analysis’, Syst
Design’));
c.
Select CourseID from SECTION where Semester = ‘1-2018’;

7.
a.
SELECT DISTINCT COURSE.CourseName
FROM SECTION, COURSE
WHERE section.CourseID = course.CourseID;

b.
SELECT StudentName
FROM STUDENT
ORDER BY StudentName;

c.
SELECT STUDENT.StudentName, SECTION.Semester, COURSE.CourseName
FROM STUDENT, REGISTERATION, SECTION, COURSE where
SECTION.SectionNo = REGISTERATION.SectionNo AND
STUDENT.StudentID = REGISTERATION.StudentID AND
COURSE.CourseID = SECTION.CourseID group by SECTION.SectionNo,
StudentName having Semester = ‘I-2018’;

d.
Select CourseID, CourseName from COURSE
where CourseID like ‘ISM%’;

8.
a.
Select SectionNo from SECTION where CourseID = ‘ISM 3113 AND
Semester = ‘I-2018’;

b.
SELECT CourseID, CourseName
FROM COURSE
WHERE CourseID LIKE ‘DATA%’;
c.
SELECT FacultyID, FacultyName
FROM Faculty
WHERE Faculty.FacultyID = Qualified.FacultyID AND
Qualified.Course ID = 'ISM 3112 AND ISM 3113';

d.
Select FacultyID from QUALIFIED where CourseID in (‘ISM 3112’, ‘ISM 3113’)
AND DateQualifed > 2011;

e.
Select FacultyID from QUALIFIED where CourseID = ISM 4212
AND SECTION.Semester = II-2018;

9.

a.
select CourseID, count (FacultyID) from QUALIFIED group by CourseID;

b.
select SectionID, count(StudentID) from REGISTERATION group by SectionID having
Count (StudentID) > 1;
c.
select CourseID, count (SectionID) from SECTION where Semester = ‘II-2018
group by CourseID;

10.
SELECT FACULTY.FacultyName
FROM FACULTY, QUALIFIED
WHERE QUALIFIED.FacultyID = FACULTY.FacultyID
AND CourseID = ‘ISM 3113’
AND QUALIFIED.FacultyID NOT IN
(SELECT FacultyID FROM QUALIFIED
WHERE CourseID = ‘ISM 4930’);

11.
a.
SELECT COUNT (StudentID)
FROM REGISTERATION
WHERE SectionID = 2714
AND Semester = ‘I-2008’;
b.
SELECT COUNT (StudentID)
FROM SECTION, REGISTERATION
WHERE SECTION.SectionNo = REGISTERATION.SectionNo
AND CourseID = ‘ISM 3113’ AND Semester = ‘I-2008’;

12.

a.
SELECT DISTINCT CourseName FROM STUDENT
NATURAL JOIN REGISTRATION
NATURAL JOIN SECTION
NATURAL JOIN COURSE
WHERE StudentName = 'Altvater'
AND Semester = 'I-2008';

b.
SELECT StudentName FROM FACULTY
NATURAL JOIN QUALIFIED
NATURAL JOIN SECTION
NATURAL JOIN REGISTERATION
NATURAL JOIN STUDENT
WHERE FacultyName = ‘Collins’;
c.
SELECT StudentName FROM COURSE
NATURAL JOIN REGISTRATION
NATURAL JOIN SECTION
NATURAL JOIN STUDENT
WHERE CourseName = 'syst'
AND Semester = 'I-2008';

d.
SELECT count (StudentID) FROM FACULTY
NATURAL JOIN QUALIFIED
NATURAL JOIN SECTION
NATURAL JOIN REGISTERATION
WHERE FacultyName = ‘Collins’ AND Semester = ‘I-2018’;
e.
SELECT CourseName FROM QUALIFIED
NATURAL JOIN COURSE
GROUP BY CourseName
HAVING COUNT (DISTINCT CourseID) > 1;

You might also like