The Examination Management System Database is a comprehensive SQL Server database designed to manage educational institution operations including:
| Property | Value |
|---|---|
| Database Name | db |
| Compatibility Level | SQL Server 2019 (150) |
| Collation | DATABASE_DEFAULT |
| Recovery Model | FULL |
| File Growth | 64 MB |
| Auto Close | ON |
βββββββββββββββββββ
β department β
βββββββββββββββββββ
β PK departmentid β
β departmentnameβ
ββββββββββ¬βββββββββ
β
β 1:N
βΌ
βββββββββββββββββββ βββββββββββββββββββ
β track β β instructor β
βββββββββββββββββββ βββββββββββββββββββ
β PK trackid β β PK instructorid β
β trackname β β instructornameβ
β FK deptid βββββββΌβββββββββββ email β
ββββββββββ¬βββββββββ β password β
β β FK deptid βββββββ€
β 1:N ββββββββββ¬βββββββββ
βΌ β
βββββββββββββββββββ β 1:N
β student β βΌ
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β PK studentid β β course β β topic β
β studentname β βββββββββββββββββββ βββββββββββββββββββ
β email (UQ) β β PK courseid ββββββββββββ PK topicid β
β password β β coursename β β topicname β
β FK trackid ββββββ€ β FK instructorid β βββββββββββββββββββ
ββββββββββ¬βββββββββ β FK topicid β
β ββββββββββ¬βββββββββ
β β
β β 1:N
β βΌ
β βββββββββββββββββββ βββββββββββββββββββ
β β question ββββββββββββ choice β
β βββββββββββββββββββ 1:N βββββββββββββββββββ
β β PK questionid β β PK choiceid β
β β questiontext β β choicelabel β
β β questiontype β β choicetext β
β β correctanswerβ β FK questionid β
β β degree β βββββββββββββββββββ
β β FK courseid β
β ββββββββββ¬βββββββββ
β β
β ββββββββββββββββββββ΄βββββββββββββββββββ
β β β
β βΌ βΌ
β βββββββββββββββββββ βββββββββββββββββββββββββββ
β β exam β β examquestion β
β βββββββββββββββββββ βββββββββββββββββββββββββββ
βββΊβ PK examid βββββββββββββββββββ PK,FK examid β
β FK courseid β β PK,FK questionid β
β FK studentid β βββββββββββββββββββββββββββ
β grade β
β ExamStartedAtβ
ββββββββββ¬βββββββββ
β
β 1:N
βΌ
βββββββββββββββββββββββββββ
β studentquestionanswer β
βββββββββββββββββββββββββββ
β PK,FK examid β
β PK,FK studentid β
β PK,FK questionid β
β studentanswer β
β mark β
βββββββββββββββββββββββββββ
Stores academic department information.
| Column | Data Type | Nullable | Description |
|---|---|---|---|
departmentid |
INT | NO | Primary Key - Unique department identifier |
departmentname |
VARCHAR(100) | YES | Name of the department |
Example Data:
| departmentid | departmentname |
|--------------|---------------------|
| 1 | Computer Science |
| 2 | Information Systems |
| 3 | Software Engineering|
Represents learning tracks/specializations within departments.
| Column | Data Type | Nullable | Description |
|---|---|---|---|
trackid |
INT | NO | Primary Key - Unique track identifier |
trackname |
VARCHAR(100) | YES | Name of the track |
deptid |
INT | YES | Foreign Key β department.departmentid |
Relationships:
department (ON DELETE SET NULL)student recordsExample Data:
| trackid | trackname | deptid |
|---------|---------------------|--------|
| 1 | Web Development | 1 |
| 2 | Mobile Development | 1 |
| 3 | Data Science | 2 |
Stores student information and credentials.
| Column | Data Type | Nullable | Constraints | Description |
|---|---|---|---|---|
studentid |
INT IDENTITY(1,1) | NO | Primary Key | Auto-generated student ID |
studentname |
VARCHAR(100) | YES | Β | Full name of student |
email |
VARCHAR(100) | NO | Unique | Student email (login) |
trackid |
INT | YES | Foreign Key | Track assignment |
password |
VARCHAR(50) | NO | Β | Account password |
Relationships:
track (ON DELETE SET NULL)exam recordsstudentquestionanswer recordsConstraints:
PK_student - Primary key on studentidUQ_Student_Email - Unique constraint on emailfk_student_track - Foreign key to trackStores instructor/teacher information.
| Column | Data Type | Nullable | Description |
|---|---|---|---|
instructorid |
INT | NO | Primary Key - Instructor identifier |
instructorname |
VARCHAR(100) | YES | Full name |
email |
VARCHAR(100) | YES | Email address (login) |
deptid |
INT | YES | Foreign Key β department.departmentid |
password |
VARCHAR(50) | NO | Account password |
Relationships:
department (ON DELETE SET NULL)course recordsCategorizes courses by subject/topic.
| Column | Data Type | Nullable | Description |
|---|---|---|---|
topicid |
INT | NO | Primary Key - Topic identifier |
topicname |
VARCHAR(100) | YES | Topic/subject name |
Example Data:
| topicid | topicname |
|---------|--------------------|
| 1 | Programming |
| 2 | Database |
| 3 | Networking |
Stores course information with instructor and topic assignments.
| Column | Data Type | Nullable | Description |
|---|---|---|---|
courseid |
INT IDENTITY(1,1) | NO | Primary Key - Auto-generated |
coursename |
VARCHAR(100) | YES | Course title |
instructorid |
INT | YES | Foreign Key β instructor.instructorid |
topicid |
INT | YES | Foreign Key β topic.topicid |
Relationships:
instructor (ON DELETE SET NULL)topic (ON DELETE SET NULL)question recordsexam recordsStores the question bank with MCQ and True/False questions.
| Column | Data Type | Nullable | Description |
|---|---|---|---|
questionid |
INT | NO | Primary Key - Question identifier |
questiontext |
VARCHAR(MAX) | YES | The question text |
questiontype |
VARCHAR(50) | YES | Type: 'MCQ' or 'TF' |
correctanswer |
VARCHAR(100) | YES | Correct answer (e.g., βAβ, βBβ, βTrueβ, βFalseβ) |
degree |
INT | YES | Points/marks for the question |
courseid |
INT | YES | Foreign Key β course.courseid |
Relationships:
course (ON DELETE CASCADE)choice records (for MCQ)examquestion recordsstudentquestionanswer recordsQuestion Types:
MCQ - Multiple Choice Question (has choices A, B, C, D)TF - True/False Question (no choices needed)Stores answer choices for MCQ questions.
| Column | Data Type | Nullable | Description |
|---|---|---|---|
choiceid |
INT | NO | Primary Key - Choice identifier |
choicelabel |
VARCHAR(10) | YES | Choice label (A, B, C, D) |
choicetext |
VARCHAR(200) | YES | Choice text/content |
questionid |
INT | YES | Foreign Key β question.questionid |
Relationships:
question (ON DELETE CASCADE)Example Data:
| choiceid | choicelabel | choicetext | questionid |
|----------|-------------|-------------------------|------------|
| 1 | A | JavaScript | 1 |
| 2 | B | Python | 1 |
| 3 | C | Java | 1 |
| 4 | D | All of the above | 1 |
Stores exam instances for students.
| Column | Data Type | Nullable | Default | Description |
|---|---|---|---|---|
examid |
INT | NO | Β | Primary Key - Exam identifier |
courseid |
INT | YES | Β | Foreign Key β course.courseid |
studentid |
INT | YES | Β | Foreign Key β student.studentid |
grade |
INT | YES | NULL | Final grade (0-100) |
ExamStartedAt |
DATETIME2(7) | NO | SYSUTCDATETIME() |
Exam start timestamp (UTC) |
Relationships:
coursestudentexamquestion recordsstudentquestionanswer recordsNotes:
Junction table linking exams to their questions.
| Column | Data Type | Nullable | Description |
|---|---|---|---|
examid |
INT | NO | Primary Key (Composite), Foreign Key β exam.examid |
questionid |
INT | NO | Primary Key (Composite), Foreign Key β question.questionid |
Relationships:
exam and question (Many-to-Many)Stores student answers for each question in an exam.
| Column | Data Type | Nullable | Description |
|---|---|---|---|
examid |
INT | NO | Primary Key (Composite), FK β exam.examid |
studentid |
INT | NO | Primary Key (Composite) |
questionid |
INT | NO | Primary Key (Composite), FK β question.questionid |
studentanswer |
VARCHAR(100) | YES | Studentβs answer (e.g., βAβ, βTrueβ) |
mark |
INT | YES | 1 = Correct, 0 = Wrong, NULL = Not graded |
Relationships:
exam (ON DELETE CASCADE)question (ON DELETE CASCADE)| Child Table | Column | Parent Table | Parent Column | On Delete |
|---|---|---|---|---|
track |
deptid |
department |
departmentid |
SET NULL |
student |
trackid |
track |
trackid |
SET NULL |
instructor |
deptid |
department |
departmentid |
SET NULL |
course |
instructorid |
instructor |
instructorid |
SET NULL |
course |
topicid |
topic |
topicid |
SET NULL |
question |
courseid |
course |
courseid |
CASCADE |
choice |
questionid |
question |
questionid |
CASCADE |
exam |
studentid |
student |
studentid |
NO ACTION |
examquestion |
examid |
exam |
examid |
CASCADE |
examquestion |
questionid |
question |
questionid |
CASCADE |
studentquestionanswer |
examid |
exam |
examid |
CASCADE |
studentquestionanswer |
questionid |
question |
questionid |
CASCADE |
| Procedure | Parameters | Description |
|---|---|---|
insert_department |
@deptId, @deptname |
Insert new department |
select_department |
@deptId (optional) |
Get all or specific department |
update_department |
@deptId, @deptName |
Update department name |
delete_department |
@deptId |
Delete department |
| Procedure | Parameters | Description |
|---|---|---|
insert_track |
@trackId, @trackName, @deptid |
Insert new track |
select_track |
@trackId (optional) |
Get all or specific track |
update_track |
@trackId, @trackName, @deptId |
Update track |
delete_track |
@trackId |
Delete track |
| Procedure | Parameters | Description |
|---|---|---|
insert_student |
@studentname, @email, @trackid, @password |
Register new student |
select_student |
@studentid (optional) |
Get all or specific student |
update_student |
@studentid, @studentname, @email, @trackid |
Update student info |
delete_student |
@studentid |
Delete student |
| Procedure | Parameters | Description |
|---|---|---|
insert_instructor |
@instructorid, @instructorname, @email, @deptid |
Add instructor |
select_instructor |
@instructorid (optional) |
Get all or specific instructor |
delete_instructor |
@instructorid |
Delete instructor |
| Procedure | Parameters | Description |
|---|---|---|
insert_topic |
@topicId, @topicname |
Insert new topic |
select_topic |
@topicId (optional) |
Get all or specific topic |
update_topic |
@topicID, @topicName |
Update topic |
delete_topic |
@topicID |
Delete topic |
| Procedure | Parameters | Description |
|---|---|---|
insert_course |
@coursename, @instructorid, @topicid |
Create course |
select_course |
@courseid, @PageNumber, @PageSize |
Get courses (paginated) |
update_course |
@courseid, @coursename, @instructorid, @topicid |
Update course |
delete_course |
@courseid |
Delete course |
| Procedure | Parameters | Description |
|---|---|---|
insert_question |
@questionid, @questiontext, @questiontype, @correctanswer, @degree, @courseid |
Add question |
select_question |
@questionid (optional) |
Get questions |
update_question |
All fields | Update question |
delete_question |
@questionid |
Delete question |
| Procedure | Parameters | Description |
|---|---|---|
insert_choice |
@choiceid, @choicelabel, @choicetext, @questionid |
Add choice |
select_choice |
@choiceid (optional) |
Get choices |
update_choice |
All fields | Update choice |
delete_choice |
@choiceid |
Delete choice |
Authenticates a student and returns their profile with enrolled courses.
EXEC sp_StudentLogin @email = 'student@example.com', @password = 'password123'
Parameters:
| Parameter | Type | Description |
|---|---|---|
@email |
VARCHAR(100) | Student email |
@password |
VARCHAR(100) | Student password |
Returns (2 Result Sets):
studentid, studentname, email, departmentname, tracknameStatusMessage: βSuccessβ, βEmail not foundβ, or βWrong passwordβSuccess: 1 or 0courseid, coursename, departmentname, instructornameAuthenticates an instructor and returns their profile.
EXEC sp_InstructorLogin @email = 'instructor@example.com', @password = 'password123'
Parameters:
| Parameter | Type | Description |
|---|---|---|
@email |
VARCHAR(100) | Instructor email |
@password |
VARCHAR(50) | Instructor password |
Returns:
instructorid, instructorname, email, departmentnameStatusMessage, SuccessGenerates a new exam with random MCQ and True/False questions.
EXEC generate_exam
@courseID = 11,
@studentID = 1,
@mcqCount = 6,
@TFCount = 4
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
@courseID |
INT | Required | Course to generate exam for |
@studentID |
INT | Required | Student taking the exam |
@mcqCount |
INT | Required | Number of MCQ questions |
@TFCount |
INT | Required | Number of True/False questions |
@Count |
INT | 10 | Total questions (must equal mcqCount + TFCount) |
Business Logic:
studentquestionanswer records for each questionExamStartedAt to current UTC timeReturns:
| Status | StatusMessage | ExamID | StudentID |
|--------|----------------------------|--------|-----------|
| 1 | Exam generated successfully| 101 | 1 |
Retrieves all questions and choices for an exam.
EXEC getexamquestions @examid = 101
Returns:
| questionid | questiontext | questiontype | choicelabel | choicetext |
|------------|---------------------|--------------|-------------|------------|
| 1 | What is JavaScript? | MCQ | A | A language |
| 1 | What is JavaScript? | MCQ | B | A framework|
| 2 | SQL is a language | TF | NULL | NULL |
Submits student answers for an exam (10 answers).
EXEC exam_answers
@examID = 101,
@studentID = 1,
@ans1 = 'A',
@ans2 = 'B',
@ans3 = 'True',
@ans4 = 'C',
@ans5 = 'False',
@ans6 = 'A',
@ans7 = 'D',
@ans8 = 'True',
@ans9 = 'B',
@ans10 = 'A'
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
@examID |
INT | Required | Exam identifier |
@studentID |
INT | Required | Student identifier |
@ans1 - @ans10 |
VARCHAR(10) | ββ | Answers in order |
Grades the exam and calculates final score.
EXEC exam_correction @examID = 101, @studentID = 1
Business Logic:
mark = 1 for correct, 0 for wrongexam.gradeReturns:
| Status | StatusMessage | Grade | studentID | examID |
|--------|----------------------------------------|-------|-----------|--------|
| 1 | Exam corrected and Marks added... | 80 | 1 | 101 |
Returns detailed exam review with questions and choices.
EXEC GetExamReview_Split @examID = 101, @studentID = 1
Returns (2 Result Sets):
| questionid | questiontext | SelectedLabel | CorrectLabel | mark |
|------------|--------------|---------------|--------------|------|
| 1 | What is... | A | A | 1 |
| 2 | SQL is... | True | True | 1 |
| questionid | choicelabel | choicetext |
|------------|-------------|---------------------|
| 1 | A | A programming lang |
| 1 | B | A markup language |
Retrieves all exams taken by a student.
EXEC GetStudentExamsHistory @studentID = 1
Returns:
| examid | coursename | grade | ExamStartedAt |
|--------|------------|-------|--------------------------|
| 101 | JavaScript | 80 | 2026-01-23T10:30:00.000Z |
| 100 | SQL | 70 | 2026-01-22T09:00:00.000Z |
Returns when an exam was started (for timer calculation).
EXEC GetExamStartTime @examID = 101, @studentID = 1
Returns:
| examid | ExamStartedAt |
|--------|--------------------------|
| 101 | 2026-01-23T10:30:00.000Z |
| Table | Constraint Name | Column(s) |
|---|---|---|
department |
PK (Clustered) | departmentid |
track |
PK (Clustered) | trackid |
student |
PK_student |
studentid |
instructor |
PK (Clustered) | instructorid |
topic |
PK (Clustered) | topicid |
course |
PK__course__2AAB4BC9279D1F4D |
courseid |
question |
PK (Clustered) | questionid |
choice |
PK (Clustered) | choiceid |
exam |
PK (Clustered) | examid |
examquestion |
PK (Clustered) | examid, questionid |
studentquestionanswer |
PK (Clustered) | examid, studentid, questionid |
| Table | Constraint Name | Column |
|---|---|---|
student |
UQ_Student_Email |
email |
| Table | Constraint Name | Column | Default Value |
|---|---|---|---|
exam |
DF_ExamStartedAt |
ExamStartedAt |
SYSUTCDATETIME() |
NEWID()ExamStartedAt set automatically on generationExamStartedAtExamStartedAtmark = 1 (correct) or 0 (wrong)SUM(mark) Γ 10| Question Type | Valid Answers |
|---|---|
| MCQ | βAβ, βBβ, βCβ, βDβ |
| TF | βTrueβ, βFalseβ, βTβ, βFβ |
-- Connect using SSMS or sqlcmd
sqlcmd -S localhost -E
-- Run the db.script file
:r "path/to/db.script"
Or in SSMS:
db.scriptUSE db;
GO
-- Check tables
SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE';
-- Check procedures
SELECT name FROM sys.procedures;
-- Insert department
EXEC insert_department @deptId = 1, @deptname = 'Computer Science';
-- Insert track
EXEC insert_track @trackId = 1, @trackName = 'Web Development', @deptid = 1;
-- Insert student
EXEC insert_student
@studentname = 'John Doe',
@email = 'john@example.com',
@trackid = 1,
@password = 'password123';
The project includes backup files for quick restoration:
dbafterstored.bak - Database with stored proceduresdbveido.bak - Alternative backupRestore Command:
RESTORE DATABASE db
FROM DISK = 'path/to/dbafterstored.bak'
WITH REPLACE,
MOVE 'db' TO 'D:\SQL_Server\...\db.mdf',
MOVE 'db_log' TO 'D:\SQL_Server\...\db_log.ldf';
SELECT
s.studentid,
s.studentname,
s.email,
t.trackname,
d.departmentname
FROM student s
LEFT JOIN track t ON s.trackid = t.trackid
LEFT JOIN department d ON t.deptid = d.departmentid;
SELECT
c.courseid,
c.coursename,
i.instructorname,
t.topicname
FROM course c
LEFT JOIN instructor i ON c.instructorid = i.instructorid
LEFT JOIN topic t ON c.topicid = t.topicid;
SELECT
c.coursename,
COUNT(e.examid) AS TotalExams,
AVG(e.grade) AS AverageGrade,
MAX(e.grade) AS HighestGrade,
MIN(e.grade) AS LowestGrade
FROM exam e
JOIN course c ON e.courseid = c.courseid
GROUP BY c.coursename;
SELECT
s.studentname,
COUNT(e.examid) AS ExamsTaken,
AVG(e.grade) AS AverageGrade,
SUM(CASE WHEN e.grade >= 60 THEN 1 ELSE 0 END) AS PassedExams
FROM student s
LEFT JOIN exam e ON s.studentid = e.studentid
GROUP BY s.studentid, s.studentname;
CrossITI Team