DBMS-QP MySQL
DBMS-QP MySQL
Instructions to Students:
Read the problem statement, functionality and the other details provided carefully and
implement the solution.
The solutions provided by you must be generic and independent of the given sample data not to
be hard coded.
Note:
Run the CreateDB.sql file to create tables and table data automatically.
Provide all the solution queries in a file dbms_sol.sql file and upload it.
A Business Scenario:
A well-known college “ABC XYZ TS College” has the following tables to keep track of its
operations:
1. student
2. professor
3. subject
4. department
The student table provides the details of all the students studying in the college.
Table: student
Column Data type and Constraints Description
name size
rollNo VARCHAR(8) PRIMARY KEY Primary key of student table
firstName VARCHAR(32) NOT NULL First name of the student
lastName VARCHAR(32) NOT NULL Last name of the student
city VARCHAR(16) DEFAULT 'BENGALURU' City where the student resides
dateOfBirth DATETIME Date of birth of the student
The department table provides the details of all departments in the college.
Table: department
Column Data type and Constraints Description
name size
deptCode VARCHAR(8) PRIMARY KEY Primary key of department table
deptName VARCHAR(32) NOT NULL Name of the department
address TEXT Address of the department
The professor table provides the details of all the professors in the college. Each professor
belongs to exactly one department and teaches only one subject.
Table: professor
Column Data type and Constraints Description
name size
facultyId VARCHAR(8) PRIMARY KEY Primary key of professor table
firstName VARCHAR(32) First name of the professor
lastName VARCHAR(32) Last name of the professor
city VARCHAR(16) City where the professor resides
subject VARCHAR(8) FOREIGN KEY Subject code referring to subject table,
subject taught by professor
dept VARCHAR(8) FOREIGN KEY Department code, reference to department
to which the professor belongs
The subject table lists all the subjects supposed to be taught in the college.
Table: subject
Column name Data type and Constraints Description
size
subjectCode VARCHAR(8) PRIMARY KEY Primary key of subject table
subject VARCHAR(32) Descriptive name of the subject
dept VARCHAR(8) FOREIGN KEY Department offering this subject
A. Display the roll number, full name and date of birth of those student(s) whose first name 3rd
character is ‘n’ (e.g. Sunil Kumar) display date of birth in DD-MM-YY format in a column named
DOB.
B. Display department name and the total number of professors that are under every
department. If no professors are there in a department, then do not display anything for that
department in the output.
C. Display the department code and name of those departments whose length of name is
between 25 and 35 characters.
D. Display the department name, address and number of subjects associated with that
department for which the number of subjects offered is maximum. If the address is not
available, i.e., NULL, display it as 'N/A'.
E. Display the subject code and name of the subjects along with the count of professors for
which teachers are available.
F. Display the subject details for all the subjects which are taught by professors from
departments different from the departments which offer the course.
G. Display the subject names in the ascending order of the department name which offers it.
H. Display roll no, full name and city of those students whose city has more than one word. (e.g.
New Delhi)
I. Display the name of the student who is the oldest in the college among those whose date of
birth is available.
J. Display the name of the department and number of professors for the department that has
the third maximum number of professors available across departments.