SQL SERVER – CASE STUDY
SCHOOL
DATABASE DESIGN:
1. Create a DATABASE: SCHOOL
TABLES
CREATE THE FOLLOWING THREE TABLES WITH SAME NAMES AND
DATA TYPES AS PROVIDED BELOW:
CourseMaster
Column Name Data Type Remarks
CID Integer Primary Key
CourseName Varchar (40) NOT NULL
Category Char(1) NULL,
Basic/Medium/Advanc
ed
Fee Smallmoney NOT NULL; Fee can’t
be negative
www.GoOnlineTrainings.com Pg: 1
SQL SERVER – CASE STUDY
SCHOOL
StudentMaster
Column Name Data Type Remarks
SID TinyInt Primary Key
Name Varchar (40) NOT NULL
Origin Char(1) NOT NULL,
Local/Foreign
Type Char(1) NOT NULL,
UnderGraduate/Gradua
te
EnrollmentMaster
Column Name Data Type Remarks
CID Integer Foreign Key
SID Tinyint Foreign Key
DOE DateTime NOT NULL
FWF Bit NOT NULL
Grade Char(1) O/A/B/C
www.GoOnlineTrainings.com Pg: 2
SQL SERVER – CASE STUDY
SCHOOL
USING THE ABOVE TABLE LAYOUTS AS SCHEMA, WRITE T-SQL
STATEMENTS FOR THE FOLLOWING REQUIREMENTS:
1. List the course wise total no. of Students enrolled. Provide the
information only for students of foreign origin and only if the
total exceeds 10.
2. List the names of the Students who have not enrolled for Java
course.
3. List the name of the advanced course where the enrollment by
foreign students is the highest.
4. List the names of the students who have enrolled for at least one
basic course in the current month.
5. List the names of the Undergraduate, local students who have got
a “C” grade in any basic course.
6. List the names of the courses for which no student has enrolled
in the month of May 2016.
7. List name, Number of Enrollments and Popularity for all Courses.
Popularity has to be displayed as “High” if number of enrollments
is higher than 50, “Medium” if greater than or equal to 20 and
less than 50, and “Low” if the no. Is less than 20.
8. List the most recent enrollment details with information on
Student Name, Course name and age of enrollment in days.
9. List the names of the Local students who have enrolled for
exactly 3 basic courses.
10. List the names of the Courses enrolled by all (every) students.
www.GoOnlineTrainings.com Pg: 3
SQL SERVER – CASE STUDY
SCHOOL
11. For those enrollments for which fee have been waived, provide
the names of students who have got ‘O’ grade.
12. List the names of the foreign, undergraduate students who have
got grade ‘C’ in any basic course.
13. List the course name, total no. of enrollments in the current
month.
www.GoOnlineTrainings.com Pg: 4
SQL SERVER – CASE STUDY
SCHOOL
STORED PROCEDURE
USING THE ABOVE TABLE LAYOUTS AS SCHEMA, WRITE A STORED
PROCEDURE FOR THE FOLLOWING SPECIFICATIONS:
Input Parameters:
Date From (Mandatory), Date To (optional, if not specified, take the
current date), & Student ID (Mandatory)
Requirements:
Course-wise, enrollment-wise in ascending order of course name to be
printed. If no enrollment exists for a given course for the period
specified, print course name and the remarks ‘No enrollment for this
period’
------------------------------------------------------------------------------------------
Enrollment Details of <Student Name > from <FromDate> To
<ToDate>
Origin : Type:
SL. No Course Name Date of Enrollment Fee Waiver?
Grade
(Yes/No)
… … …… …… ……
… … …… …… ……
Total No. of Courses Enrolled:
www.GoOnlineTrainings.com Pg: 5
SQL SERVER – CASE STUDY
SCHOOL
*** End of Document ***
www.GoOnlineTrainings.com Pg: 6