0% found this document useful (0 votes)
8 views

DBMS-QP MySQL

The document describes a college database with tables for students, professors, departments, and subjects. It provides sample data and asks to write SQL queries to retrieve specific data based on conditions from the tables.

Uploaded by

Vikas
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

DBMS-QP MySQL

The document describes a college database with tables for students, professors, departments, and subjects. It provides sample data and asks to write SQL queries to retrieve specific data based on conditions from the tables.

Uploaded by

Vikas
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Problem Statement

Instructions to Students:

Read the problem statement, functionality and the other details provided carefully and
implement the solution.

The coding standards and comments are mandatory wherever applicable.

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

Sample data for student table


rollNo firstName lastName city dateOfBirth
CSE14001 SUNIL VENKAT CHENNAI 1990-01-15
CSE14002 VANDANA MISHRA NEW DELHI 1989-06-21
ECE13002 PRASANNA KUMAR BENGALURU 1989-02-12
ECE14001 MEERA NATARAJ BENGALURU 1989-05-04
MEC14007 MEERA PAUL PORT BLAIR 1989-09-14

Sample data for department table


deptCode deptName address
CSE Computer Science & Engineering 180, Main Building
ECE Electronics & Communication Engineering NULL
MATH Mathematics Ramanujam Complex
PHYSICS Physics Satyendranath Bose Building
EEE Electronics & Electrical Engineering 25, VII Block, JP Nagar
MEC Mechatronics NULL

Sample data for professor table


facultyId firstName lastName city subject deptCode
ECE01 SANJAY MALPANI JAIPUR SSP ECE
CSE12 RAJEEV KRISHNAN CHENNAI TCS CSE
GEN03 VANITA MANI MUMBAI PL CSE
CSE07 SUBROTO MITRA KOLKATA AI CSE
GEN08 RAMA RAO HYDERABAD MATH01 ECE
MEC99 MANOJ SHARMA DELHI ENGPH MEC
Sample data for subject table
subjectCode Subject dept
SSP Statistical Signal Processing ECE
TCS Applications of Theoretical Computer Science CSE
PL Programming Languages & Compilers CSE
AI Artificial Intelligence CSE
MATH01 Engineering Mathematics MATH
ENGPH Engineering Physics PHYSICS

Write SQL queries for the following:


Note: Type the solution in dbms_sol.sql file

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.

You might also like