0% found this document useful (0 votes)
22 views15 pages

ITCS285 Project

The document outlines the creation of a Training Center Management System database, detailing the requirements, ER design, relational schema, implementation using Python and SQLite3, and SQL queries. It includes specifications for entities such as Trainees, Instructors, Courses, and Sections, along with their attributes and relationships. The implementation section provides Python code for creating the database tables and examples of SQL queries for data retrieval.

Uploaded by

abdullah jasem
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views15 pages

ITCS285 Project

The document outlines the creation of a Training Center Management System database, detailing the requirements, ER design, relational schema, implementation using Python and SQLite3, and SQL queries. It includes specifications for entities such as Trainees, Instructors, Courses, and Sections, along with their attributes and relationships. The implementation section provides Python code for creating the database tables and examples of SQL queries for data retrieval.

Uploaded by

abdullah jasem
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

University of Bahrain

Training Center Management


System

ITCS 285

Name: Abdullah Al-Jassim


ID: 202310963

Submitted on: 17 April 2025


Submitted to: Dr.

ITCS 285 1
Table of Content
Introduction 3
1. Findings 3
1.1. Requirements 3
1.2. ER Design 4
1.3. Relational Scheme 5
1.4. Implementation 7
1.5. SQL Queries 12

ITCS 285 2
Introduction
Creating a well designed Database is essential for a Training Center. This
Document outlines the steps taken to create said Database. Starting from Training
Center Management System’s Requirements. Afterwards, an ER diagram is created
and the relational schema is de ned. Following that, the database will be
implemented using python and sqlite3. Finally, some SQL Query questions will be
imposed and answered; Ensuring that any Information that the management needs
can found. Resulting in a streamlined operations, e cient data storage, and
enhanced Training Experience.

1. Findings
1.1. Requirements
When creating a database, the most crucial step is collecting requirements.
The requirements of one Training centre is:

A. A training center o ers Courses/Programs having: Course ID as a unique


identi er, Course Name, Description, Cost, Room, and zero or more
Prerequisite; and can be a prerequisite to zero or more Courses. A room can be
a physical place or online.
B. Trainees have Trainee ID as a unique identi er, Name, Email, Phone, Address,
Credit Card, and Date of birth.
C. Instructors have Instructor ID as a unique identi er, Name, Email, Phone,
Address, Salary, and Date of birth.
D. A section have SecNo, year, and Starting Week as a unique identi er for the
same course. In addition, a section have the ending week and the room in
which a lecture is presented, the room can be online.
E. Each Trainee is registered to zero or more section and a section has more than
one trainee
F. If a trainee passes a course, a certi cate is made with the date of certi cation
and expiry date for the certi cate.
G. A section is taught by one instructor only and an instructor can teach one or
more sections.

ITCS 285 3
fi
ff
fi
fi
fi
fi
fi
ffi
fi
fi
1.2. ER Design
This Design of ER is Done on draw.io online.

Date of
Name Email Address Phone
Birth

Course ID
M Prerequisite Person

Course
Name Course N
Credit
Card
M Is A
1
Description
Certificate Trainee ID
Instructor
ID
Cost
has N Trainee Instructor
Date of
Expiry Date
Salary
Certification
M 1

Sec No. M

Section N Regestired Teaches


Year

Starting
Week
M

Ending
Room
Week

Since Trainee and Instructor entity share many attributes, a super type was created.
A person can only be Trainee or an Instructor. Section was made a weak entity since it is
only de nable using the Course entity. The partial keys for section are Sec No, Year, and
Starting Week.

ITCS 285 4
fi
1.3. Relational Scheme
This relational schema was done on draw.io

Trainee Instructor Course

Trainee_ID Instructor_ID Course_ID


Name Name Name
Email Email Description
Phone Phone Cost
Address Address
Date_of_Birth Date_of_Birth
Credit Cart Salary

Section Prerequisites Certificate

Course_ID Lower _Level_ID Course_ID


Sec_No Higher_Level_ID Trainee_ID
Year Date_of_Certification
Starting_Week Expiry_Date
Ending_Week
Room
Instructor_ID

Registered

Course_ID
Sec_No
Year
Starting_Week
Trainee_ID

Trainee (Trainee_ID, Name, Email, Phone, Address, Date_of_Birth, Credit_Card)


Instructor (Instructor_ID, Name, Email, Phone, Address, Date_of_Birth, Salary)
Course (Course_ID, Course_Name, Description, Cost)
Section (Course_ID, Sec_No, Year, Starting_Week, Ending_Week, Room,
Instructor_ID)
FK (Course_ID) References Course
Prerequisite (Lower_Level_ID, Higher_Level_ID)
FK (Lower_Level_ID) References Course
FK (Higher_Level_ID) References Course
Certi cate (Course_ID, Trainee_ID, Date_of_Certi cation, Expiry_Date)
FK (Course_ID) References Course
FK (Trainee_ID) References Trainee
Registered (Course_ID, Sec_No, Year, Starting_Week, Trainee_ID)
FK ( Course_ID, Sec_No, Year, Starting_Week) References Section
FK (Trainee_ID) References Trainee

ITCS 285 5
fi
fi
Constraints:
Trainee:
Trainee_ID is an eight digit number
Phone is a unique sixteen digit number
Credit_Card is a sixteen digit number

Instructor:
Instructor_ID is a six digit number
Phone is a unique eight digit number

Course:
Course_ID is a three digit number

Section:
Starting week is a number between 1 and 52
Ending week is a number between 1 and 52

There can be (sometimes) multiple Relational schema for the same ER


diagram, here are some reasons why the current relational schema was chosen:

- Since a person is either a Trainee or an instructor, choice 8B is the most logical


choice.
- Because section is a weak entity and Course is the owner entity, Course_ID is
part of the primary key and a foreign key in the section Relation referencing
the Course Relation.
- For each many to many relationship, a new Relation was created having as the
primary key of the two primary keys of the entities it is in relation with.
- Since the cardinality of the Teaches relationship is one to many, the key of the
one side is a foreign key in the many side.

ITCS 285 6
1.4. Implementation
Python code to generate Tables:

import sqlite3

# Connect to or create an SQLite3 database


def create_connection(db_file):
try:
conn = sqlite3.connect(db_file)
print("Database created and successfully connected to SQLite3.")
return conn
except sqlite3.Error as e:
print(e)
return None

# Create tables
def create_tables(conn):
try:
cursor = conn.cursor()

# Trainee table
cursor.execute("""
CREATE TABLE IF NOT EXISTS Trainee (
Trainee_ID INTEGER PRIMARY KEY,
Name TEXT NOT NULL,
Email TEXT NOT NULL,
Phone TEXT,
Address TEXT,
Date_of_Birth TEXT,
Credit_Card TEXT
);
""")

# Instructor table
cursor.execute("""
CREATE TABLE IF NOT EXISTS Instructor (
Instructor_ID INTEGER PRIMARY KEY,
Name TEXT NOT NULL,
Email TEXT NOT NULL,
Phone TEXT,
Address TEXT,
Date_of_Birth TEXT,
Salary REAL
);
""")

# Course table
cursor.execute("""
CREATE TABLE IF NOT EXISTS Course (
Course_ID INTEGER PRIMARY KEY,
Name TEXT NOT NULL,
Description TEXT,
Cost REAL
);
""")

# Section table
cursor.execute("""
CREATE TABLE IF NOT EXISTS Section (
Course_ID INTEGER,
Sec_NO INTEGER,
Year INTEGER,
Starting_Week INTEGER,
Ending_Week INTEGER,
Room TEXT,
Instructor_ID INTEGER,
PRIMARY KEY (Course_ID, Sec_NO, Year, Starting_Week),

ITCS 285 7
FOREIGN KEY (Course_ID) REFERENCES Course(Course_ID),
FOREIGN KEY (Instructor_ID) REFERENCES Instructor(Instructor_ID)
);
""")

# Prerequisites table
cursor.execute("""
CREATE TABLE IF NOT EXISTS Prerequisites (
Lower_Level_Course_ID INTEGER,
Higher_Level_Course_ID INTEGER,
PRIMARY KEY (Lower_Level_Course_ID, Higher_Level_Course_ID),
FOREIGN KEY (Lower_Level_Course_ID) REFERENCES Course(Course_ID),
FOREIGN KEY (Higher_Level_Course_ID) REFERENCES Course(Course_ID)
);
""")

# Certificate table
cursor.execute("""
CREATE TABLE IF NOT EXISTS Certificate (
Course_ID INTEGER,
Trainee_ID INTEGER,
Date_of_Certification DATE,
Expiry_Date DATE,
PRIMARY KEY (Course_ID, Trainee_ID),
FOREIGN KEY (Course_ID) REFERENCES Course(Course_ID),
FOREIGN KEY (Trainee_ID) REFERENCES Trainee(Trainee_ID)
);
""")

# Registered table
cursor.execute("""
CREATE TABLE IF NOT EXISTS Registered (
Course_ID INTEGER,
Sec_NO INTEGER,
Year INTEGER,
Starting_Week INTEGER,
Trainee_ID INTEGER,
PRIMARY KEY (Course_ID, Sec_NO, Year, Starting_Week, Trainee_ID),
FOREIGN KEY (Course_ID, Sec_NO, Year, Starting_Week)
REFERENCES Section(Course_ID, Sec_NO, Year, Starting_Week),
FOREIGN KEY (Trainee_ID) REFERENCES Trainee(Trainee_ID)
);
""")

conn.commit()
cursor.close()
print("Tables created successfully.")
except sqlite3.Error as e:
print(e)

if __name__ == "__main__":
db_file = "Database.db"
conn = create_connection(db_file)
if conn:
create_tables(conn)
conn.close()

ITCS 285 8
Trainee Table

Trainee_ID Name Email Phone Address Date_of_Birth Credit_Card

20199889 Hamad hamad889@T 5981232 Muharraq 15/10/2004 3912567894


rainingCenter 659811
.com

20210012 Ali ali012@Traini 65596565 Muharraq 31/1/2005 8739546489


ngCenter.co 726323
m

20222532 Noora noora532@Tr 5782345 Isa Town 22/3/2002 9653878653


ainingCenter. 421750
com

20230998 Abdullah abdullah998 66654545 Saar 06/12/2003 8436598273


@TrainingCe 064584
nter.com

20252338 Ahmed ahmed338@T 9886768 Manama 21/8/2001 4897347658


rainingCenter 973584
.com

Instructor Table

Instructor_ID Name Email Phone Address Date_of_Birth Salary

213454 Jamal jamal21@Inst 87233445 Manama 23/7/1996 845.21


ructor.Trainin
gCenter.com

754936 Ali ali75@Instruc 48795623 Muharraq 04/11/1997 845.21


tor.TrainingC
enter.com

893456 Khalid khaild89@Ins 87454523 Manama 19/5/1993 712.35


tructor.Traini
ngCenter.co
m

912332 Mohammad mohammad9 9941212 Ri a 11/3/1995 831.23


1@Instructor.
TrainingCent
er.com

932386 Sara sara93@Instr 76842974 Budaiya 17/10/1999 678.53


uctor.Training
Center.com

ITCS 285 9
ff
Course Table

Course_ID Name Description Cost

113 Java Programming Teaches how to program 15.0


using java

122 Python Programming Teaches how to program 15.0


using python

123 AI and ML Teaches AI and Machine 20.0


Learning concepts

234 LLM Teaches Large language 25.0


Models concepts

259 Game Development Teaches how to create 30.0


and optimize games

Section Table

Course_ID Sec_No Year Starting_We Ending_wee Room Instructor_I


ek k D

122 1 2025 29 39 Online 213454

123 1 2024 29 44 1135 754936

259 1 2025 19 39 2050 213454

122 1 2023 1 11 2032 893456

234 1 2025 34 49 1050 932386

113 1 2025 29 39 Online 912332

Prerequisites Table

Lower_Level_Course_ID Higher_Level_Course_ID

122 123

123 234

122 259

ITCS 285 10
Certi cate Table

Course_ID Trainee_ID Date_of_certi cation Expiry_Date

113 20210012 14042025 NULL

113 20230998 14042025 NULL

122 20222532 14042023 NULL

123 20222532 17052024 17052027

234 20222532 13032025 13032028

122 20199889 19012023 NULL

259 20199889 15082025 NULL

Registered Table

Course_ID SEC_NO Year Starting_Week Trainee_ID

122 1 2025 29 20210012

113 1 2025 29 20210012

122 1 2023 1 20222532

123 1 2024 29 20222532

234 1 2025 34 20222532

122 1 2023 1 20199889

259 1 2025 19 20222532

113 1 2025 29 20230998

ITCS 285 11
fi
fi
1.5. SQL Queries
1. Find courses’s name that are taught by Instructor named Jamal.

SELECT C.Name
FROM Instructor AS I, Section AS S, Course AS C
WHERE I.Instructor_ID = S.Instructor_ID AND S.Course_ID = C.Course_ID
AND I.Name = ‘Jamal’
Name

Python
Programming

Game Development

2. Count the number of Trainees in each section and order them from highest to
lowest number of Trainees.

SELECT Course_ID, Sec_No, Year, Starting_Week, Count(Trainee_ID) AS


Trainee_Count
FROM Registered
GROUP BY Course_ID, Sec_No, Year, Starting_Week
ORDER BY Trainee_count

Course_ID Sec_No Year Starting_Wee Trainee_Coun


k t

113 1 2025 29 2

122 1 2023 1 2

122 1 2025 29 1

123 1 2024 29 1

234 1 2025 34 1

259 1 2025 19 1

3. List all prerequisites for a course named LLM.

SELECT C1.Name
FROM Course AS C1, Course AS C2, Prerequisites AS P
WHERE C1.Course_ID = P.Lower_Level_Course_ID AND C2.Course_ID =
P.Higher_Level_Course_ID AND C2.Name = ‘LLM’

Name

Python
Programming

ITCS 285 12
4. List Trainee name who have earned certi cate along with Course name and
Date of certi cation.

SELECT T.Name AS Trainee_name, C.Name AS Course_name,


R.Date_of_Certi cation
FROM Trainee AS T, Course AS C, Certi cate AS R
WHERE R.Trainee_ID = T.Trainee_ID AND R.Course_ID = C.Course_ID

Trainee_name Course_name Date_of _Certi cation

Ali Java Programming 14042025

Abdullah Java Programming 14042025

Noora Python Programming 24042023

Noora AI and ML 17052024

Noora LLM 13032025

Hamad Game Development 15082025

Hamad Python programming 19012023

5. For each course count the number of Trainees.

SELECT C.Name, COUNT(R.Trainee_ID) AS Trainee_Count


FROM Course AS C, Registered AS R
WHERE C.Course_ID = R.Course_ID
GROUP BY C.Name

Name Trainee_Count

Java Programming 2

Python 3
Programming

AI and ML 1

LLM 1

Game Development 1

6.

ITCS 285 13
fi
fi
fi
fi
fi
7. Retrieve the name of the Instructor with the highest salary.

SELECT Name
FROM Instructor
WHERE Salary = (SELECT MAX(Salary)
FROM Instructor)

Name

Jamal

Ali

8. Retrieve the most expensive Courses.

SELECT Name
FROM Course
WHERE Cost = (SELECT MAX(Cost) FROM Course)

Name

Game Development

9. retrieve the Trainee with the highest number of Certi cate.

SELECT Trainee_ID, COUNT(*) AS Num


FROM Certi cate
GROUP BY Trainee_ID

SELECT T.Trainee_ID, T.Name, C.Num


FROM Trainee T, (SELECT Trainee_ID, COUNT(*) AS Num
FROM Certi cate
GROUP BY Trainee_ID) AS C
WHERE T.Trainee_ID = C.Trainee_ID AND C.Num =
(SELECT MAX(C.NUM) FROM C)

Trainee_ID Name Num

20222532 Noora 3

10.

ITCS 285 14
fi
fi
fi
11. Display all section information along with course name and Instructor name.

SELECT C.Name AS Course_name, Sec_No, Year, Starting_Week,


Ending_Week, Room, I.Name AS Instructor_name
FROM Section AS S, Course AS C, Instructor AS I
WHERE S.Course_ID = C.Course_ID AND S.Instructor_ID = I.Instructor_ID

Course_name Sec_No Year Starting_We Ending_wee Room Instructor_n


ek k ame

Python 1 2025 29 39 Online Jamal


Programming

AI and ML 1 2024 29 44 1135 Ali

Game 1 2025 19 39 2050 Jamal


Development

Python 1 2023 1 11 2032 Khalid


Programming

LLM 1 2025 34 49 1050 Sara

Java 1 2025 29 39 Online Mohammad


Programming

12. Find courses with the highest number of prerequisites.

SELECT C.Course_ID, C.Name, COUNT(P.Higher_Level_Course_ID) AS


Num
FROM Course AS C, Prerequisites AS P
WHERE C.Course_ID = P.Higher_Level_Course_ID
GROUP BY C.Course_ID, C.Name
HAVING Num = ( SELECT MAX(Num_of_Prerequisite)
FROM ( SELECT COUNT(Higher_Level_Course_ID) AS
Num_of_Prerequisite
FROM Prerequisite)
)

Course_ID Name Num

123 AI and ML 1

234 LLM 1

259 Game 1
Development

ITCS 285 15

You might also like