Assignment 1-4
Assignment 1-4
Query 1 :
CREATE TABLE tblBranch(branchID varchar(5) NOT NULL PRIMARY KEY,branchName varchar(50) NOT
NULL,building char(10),other char(10));
Output :
Query 2 :
CREATE TABLE tblSubject(subjectID varchar(5) NOT NULL PRIMARY KEY,subName varchar(0) NOT
NULL,thHours int(4),tuHours int(4),prHours int(4),credit int(4));
Output :
Query 3 :
CREATE TABLE tblStudent(studentID int(4) NOT NULL PRIMARY KEY,fName varchar(20) NOT
NULL,mName varchar(20),lName varchar(20),address varchar(30),area varchar(20),city
varchar(20),state varchar(20),country varchar(20),pincode int(6),phoneNo int(10), birthDate
date,gender varchar(20) NOT NULL,regNo int(5), branchID char(20) NOT NULL, FOREIGN KEY
(branchID) REFERENCES tblBranch(branchID),admyear int(10),emailID varchar(20));
Output :
Query 4 :
CREATE TABLE tblFaculty(facID varchar(5) NOT NULL PRIMARY KEY,fName varchar(20) NOT
NULL,mName varchar(20),lName varchar(20),address varchar(20),area char(10),city char(10),state
char(10),country char(10),pincode int(10),phoneNo int(15),emailID varchar(20),joinDate date,gender
char(10) NOT NULL,qualification varchar(20),designation varchar(20),deptID char(10) NOT
NULL,addDuties char(20), FOREIGN KEY (deptID) REFERENCES tblBranch(branchID));
Output :
Query 5 :
CREATE TABLE tblCourse(courseID varchar(5) NOT NULL PRIMARY KEY,subID varchar(5) NOT
NULL,facID varchar(5) NOT NULL,semester int(2) NOT NULL,branchID char(5),FOREIGN KEY(subID)
REFERENCES tblSubject(subjectID),FOREIGN KEY (facID) REFERENCES tblFaculty(facID),FOREIGN KEY
(branchID) REFERENCES tblBranch(branchID));
Output :
Query 6 :
CREATE TABLE tblStudentCourse(stuCouID varchar(5) NOT NULL PRIMARY KEY,stuID int(5) NOT
NULL,courseID varchar(5) NOT NULL,month char(10),year int(5),FOREIGN KEY(stuID) REFERENCES
tblStudent(studentID),FOREIGN KEY(courseID) REFERENCES tblCourse(courseID));
Output :
Query 7 :
CREATE TABLE tblStudentResult(ID varchar(5) NOT NULL PRIMARY KEY,stuCouID varchar(5) NOT
NULL,creditObtained int(5) NOT NULL,isCleared char(5),yearApp int(5),FOREIGN KEY (stuCouID)
REFERENCES tblStudentCourse(StuCouID));
Output :
Query 8 :
CREATE TABLE tblOneTimeFees(ID varchar(10) NOT NULL PRIMARY KEY,stuID int(5) NOT
NULL,particular varchar(20),amount int(10),dateSub date,isRefundable varchar(5),FOREIGN KEY
(stuID) REFERENCES tblStudent(studentID));
Output :
Query 9 :
CREATE TABLE tblTuitionFees(ID varchar(5) NOT NULL PRIMARY KEY,stuID int(5) NOT NULL,semester
int(5),amount int(10),dateSub date,FOREIGN KEY (stuID) REFERENCES tblStudent(studentID));
Output :
Query 10 :
CREATE TABLE tblExamFees(ID varchar(5) NOT NULL PRIMARY KEY,stuID int(5) NOT NULL,couID
varchar(5) NOT NULL,amount int(10),dateSub date,FOREIGN KEY(stuID) REFERENCES
tblStudent(studentID), FOREIGN KEY (couID) REFERENCES tblCourse(courseID));
Output :
Assignment – 2
Query 1 :
Output :
Aim 2 : Display the city names of all the students.
Output :
Aim 3 : Display the names and birth dates of all the students whose names start with either ‘M’ or
with ‘P’.
Syntax : SELECT fName "Name",birthDate FROM tblStudent WHERE fName LIKE 'M%' OR fName LIKE
'P%';
Output :
Aim 4 : Display the entire student IDs who are from ‘Maharashtra’.
Output :
Aim 5 : Display the entire student first and last names having age equal to or greater than 20.
Output :
Aim 6 : Display all the male student first names, last names and year of admission that are from
‘Surat’.
Syntax : SELECT fName, lName, admYear FROM tblStudent WHERE gender='Male' AND city='Surat';
Output :
Aim 7 : Display the student IDs and branch names of all the students.
Output :
Aim 8 : Display the first and last names of all the students who belong to D1 building.
Output :
Aim 9 : Display all the student IDs and registration numbers that are registered for more than 4
years.
Syntax : SELECT fName , lName FROM tblFaculty f,tblBranch b WHERE f.deptID=b.branchID AND
b.Building='D1';
Output :
Aim 11 : Display all the student IDs and cities in the descending order of their year of admission.
Output :
Assignment – 4
Aim 1 : Display the total number of students and the department name for every department.
Output :
Aim 2 : Find and display the branch name with the maximum students enrolled to it.
Output :
Aim 3 : Display the entire student first and last names for which the faculty is ‘Chetan
Solanki’.
Syntax : SELECT s.fname , s.lname FROM tblStudent s, tblFaculty f WHERE s.branchID=f.deptID and
f.fname='Chetan' and f.lname='Solanki';
Output :
Aim 4 : Display the subject name and faculty name of branch ‘EC’.
Output :
Aim 5 : Display all the student IDs and faculty IDs who live in the same city.
Syntax : SELECT studentID , facID FROM tblStudent s , tblFaculty f WHERE s.branchID=f.deptId and
s.city =f.city;
Output :
Aim 6 : Display the faculty ID and name for the faculty who has joined most recently.
Output :
Aim 7 : Display the Subject Name and Semester No. for all the subjects up to 2nd year.
Output :
Aim 8 : Display One Time Fees’ ID, Tuition fees’ ID and Exam fees’ ID for all the students who are in
1st year(1st and 2nd sem).
Syntax : SELECT otf.ID, tf.ID,ef.ID FROM tblOneTimeFees otf ,tblTuitionFees tf, tblExamFee ef WHERE
otf.stuID=tf.stuID and otf.stuID=ef.stuID and tf.Semester <=2;
Output :
Aim 9 : Display total fees for all the ‘Computer’ branch students.
Output :
Aim 11 : Count the average years of experience for all the faculties.
Output :