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

Assignment 3

Uploaded by

api-576578251
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)
71 views2 pages

Assignment 3

Uploaded by

api-576578251
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

ASSIGNMENT 3

MIS331 Database Management Systems· SEM1·AY2021/2022


SQL 1
13. SQL commands to create relations

SQL Command to create STUDENT relation:

CREATE TABLE Student_T


(StudentID INT NOT NULL,
StudentName VARCHAR(25),
CONSTRAINT Student_PK PRIMARY KEY (StudentID));

SQL Command to create FACULTY relation:

CREATE TABLE Faculty_T


(FacultyID INT NOT NULL,
FacultyName VARCHAR(25),
CONSTRAINT Faculty_PK PRIMARY KEY (FacultyID));

SQL Command to create COURSE relation:

CREATE TABLE Course_T


(CourseID VARCHAR(8) NOT NULL,
CourseName VARCHAR(15),
CONSTRAINT Course_PK PRIMARY KEY (CourseID));

SQL Command to create QUALIFIED relation:

CREATE TABLE Qualified_T


(FacultyID INT NOT NULL,
CourseID VARCHAR(8) NOT NULL,
DateQualified DATE,
CONSTRAINT Qualified_PK PRIMARY KEY (FacultyID, CourseID),
CONSTRAINT Qualified_FK1 FOREIGN KEY (FacultyID) REFERENCES
Faculty_T(FacultyID),
CONSTRAINT Qualified_FK2 FOREIGN KEY (CourseID) REFERENCES
Course_T(CourseID));

SQL Command to create SECTION relation:

CREATE TABLE Section_T


(SectionNo INT NOT NULL,
Semester VARCHAR(7),
CourseID VARCHAR(8),
CONSTRAINT Section_PK PRIMARY KEY (SectionNo));
CONSTRAINT Section_FK FORGEIN KEY (CourseID) REFERENCES
Course_T(CourseID));

1
SQL Command to create REGISTRATION relation:

CREATE TABLE Registration_T


(StudentID INT NOT NULL,
SectionNo INT NOT NULL,
CONSTRAINT Registration_PK PRIMARY KEY (StudentID, SectionNo),
CONSTRAINT Registration_FK1 FOREIGN KEY (StudentID) REFERENCES
Student_T(StudentID),
CONSTRAINT Registration_FK2 FOREIGN KEY (SectionNo) REFERENCES
Section_T(SectionNo));

14. SQL commands to insert data into relation

SQL commands to insert the four records into the Course relation
(Hint: write four INSERT INTO statements to insert the four records):

INSERT INTO Course_T,


VALUES (“ISM 3113”, “Syst Analysis”);

INSERT INTO Course_T,


VALUES (“ISM 3112”, “Syst Design”);

INSERT INTO Course_T,


VALUES (“ISM 4212”, “Database”);

INSERT INTO Course_T,


VALUES (“ISM 4930”, “Network”);

15. SQL commands to retrieve data from relation

i. Retrieve all records in the COURSE relation

SELECT * FROM Course_T;

ii. Retrieve all values from the CourseID attribute in the COURSE relation

SELECT CourseID
FROM Course_T;

iii. Retrieve the record where CourseID is ISM4930

SELECT CourseID
FROM Course_T
WHERE CourseID = “ISM4930”;

You might also like