Page 1 of 15
Page 1 of 15
ER DIAGRAM
College
College id (PK)
Name
Department
Department ID (PK)
Department Name
College ID (FK)
Course
Course ID (PK)
Title
Teacher ID (FK)
Department ID (FK)
Teachers
Teacher ID (PK)
Name
Email
Department ID (FK)
Students
Student ID (PK)
Name
Email
Department ID (FK)
Entities Relationship
College:
Department:
Page 2 of 15
Belongs to a college.
Offers multiple courses.
Has multiple teachers.
Has multiple students.
Course:
Belongs to a department.
Is taught by a teacher.
Has multiple students enrolled (via enrollments).
Teachers:
Belongs to a department.
Teaches multiple courses.
Students:
Belongs to a department.
Studies in a college.
Enrolls in multiple courses (via enrollments).
The underlined attribute for each entities represent their Primary Key.
Challenges Faced
The major challenge was to understand the use case model and to construct an er diagram
from it. Understanding the use case model and relating it to the real-life examples and then
draw an er diagram which truly depicts an er diagram. Then the next challenge was the
attributes of entities and how they would relate to each other and in the end refining or
normalizing them to 3nf was something that demanded a lot of concentration and focus.
Page 3 of 15
Page 4 of 15
NORMALIZATION
In Normalization the shaded box in each table represents primary key and all the tables are in
3nf as they only depend on the primary key. A new Table named Enrollments was formed in
the process of making normalized tables
STUDENT TABLE
COLLEGE TABLE
college_id name
DEPARTMENT TABLE
TEACHER TABLE
COURSE TABLE
ENROLLMENT TABLE
Page 5 of 15
DATABASE IMPLEMENTATION
Below is the photo given from a DB Browser for SQLite in which all the required code was
implemented. Necessary attributes were also added keeping in mind the use case model.
PHOTOS FROM DB BROWSER FOR SQLITE
Page 6 of 15
CODE
-- College Table
CREATE TABLE College (
college_id INTEGER PRIMARY KEY,
name TEXT NOT NULL
);
-- Department Table
CREATE TABLE Department (
department_id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
college_id INTEGER,
FOREIGN KEY (college_id) REFERENCES College(college_id)
);
-- Course Table
CREATE TABLE Course (
course_id INTEGER PRIMARY KEY,
title TEXT NOT NULL,
description TEXT,
teacher_id INTEGER,
department_id INTEGER,
FOREIGN KEY (teacher_id) REFERENCES Teacher(teacher_id),
FOREIGN KEY (department_id) REFERENCES Department(department_id)
);
Page 7 of 15
-- Teacher Table
CREATE TABLE Teacher (
teacher_id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
email TEXT UNIQUE NOT NULL,
department_id INTEGER,
FOREIGN KEY (department_id) REFERENCES Department(department_id)
);
-- Student Table
CREATE TABLE Student (
student_id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
email TEXT UNIQUE NOT NULL,
department_id INTEGER,
FOREIGN KEY (department_id) REFERENCES Department(department_id)
);
-- Enrollment Table
CREATE TABLE Enrollment (
enrollment_id INTEGER PRIMARY KEY,
student_id INTEGER,
course_id INTEGER,
grade TEXT,
FOREIGN KEY (student_id) REFERENCES Student(student_id),
FOREIGN KEY (course_id) REFERENCES Course(course_id)
);
Page 8 of 15
Code
-- Insert sample data into College Table
INSERT INTO College (name) VALUES ('Engineering College');
INSERT INTO College (name) VALUES ('Arts College');
Page 9 of 15
INSERT INTO Teacher (name, email, department_id) VALUES ('Dr. Bob',
'[email protected]', 2);
INSERT INTO Teacher (name, email, department_id) VALUES ('Dr. Carol',
'[email protected]', 3);
Below are the tables after being populated with the sample data. Note that these tables are
before any manipulation tasks were being performed on them which were given in the next
part of the question which include SELECTION, INSERTION and UPDATION.
STUDENT TABLE
Page 10 of 15
std_id Name Email dept_id (FK)
COLLEGE TABLE
1 Engineering College
2 Arts College
DEPARTMENT TABLE
1 Computer Science 1
2 Mathematics 1
3 History 2
TEACHER TABLE
COURSE TABLE
Page 11 of 15
3 World History History of the world 3 3
ENROLLMENT TABLE
1 1 1 A
2 2 2 B
3 3 3 C
INSERT QUERIES:
1. A new student has joined so we need to add that student data into students table
INSERT INTO Students (name, email, dept_id) VALUES ('Alice Johnson',
'[email protected]', 1);
2. A new teacher has been hired so there is a need of additional row in the teachers
table.
INSERT INTO Teachers (name, email, dept_id) VALUES (Mitchel Johnson',
'[email protected]', 1);
UPDATE QUERIES:
1. A Student changes his department:
A very often or normal activity in schools when students change their departments so
to perform this action below query will be implemented on our database.
SELECT QUERIES:
1. To see which courses have been assigned to a teacher
Page 12 of 15
SELECT course_id, title AS CourseTitle,
(SELECT name FROM Teacher WHERE teacher_id = Course.teacher_id) AS TeacherName
FROM Course;
2. To count the number of departments in college with college_id = 1
This select query selects the number of departments ina college using his id with the help
of COUNT.
Views
1. View that shows the names of students along with the courses they are enrolled in
and their grades.
Views in SQLite is a virtual table based on the result set of an SQL query. They
dynamically retrieve the data using the stored query. In our example view
“StudentCourses” shows a detailed info about students like a Report Card of a student
showing his name, courses enrolled and the grades he got in those enrolled courses. It
retrieves data from two tables i.e. Student and Course and using join it combines the
data.
Page 13 of 15
2. To view teachers their respective departments along with the courses assigned to
them.
This view gives a detailed info about a teacher showcasing his/her name, department
and the courses assigned to him/her. It retrieves data from three tables aas shown in
the query and then uses join to combine them together.
Any user with access to the SQLite database file has full access to all the data within
it, which is very alarming that anyone having database access can access the whole
database.
Encryption
SQLite does not support encryption natively. Without encryption, sensitive data stored
in SQLite databases is vulnerable to unauthorized access if the database file is
compromised. Third-party encryption solutions does the work but they add
complexity to the project.
SQLite uses a file-level locking mechanism to manage concurrent access, which can
limit the number of simultaneous writes. SQLite allows multiple readers but only one
Page 14 of 15
writer at a time. Applications requiring high write throughput may experience
performance degradation.
No Built-in Replication:
SQLite does not support built-in replication or clustering, which are features
commonly found in other database systems to enhance availability and scalability.
Page 15 of 15