Group1 Report
Group1 Report
Group1 Report
INTERNATIONAL UNIVERSITY
SCHOOL OF COMPUTER SCIENCE AND ENGINEERING
PRINCIPLES OF
DATABASE MANAGEMENT
IT079IU
FINAL REPORT
Course by Assoc. Prof. Nguyen Thi Thuy Loan
TABLE OF CONTENT
I. INTRODUCTION ..............................................................................................................................................................................4
1. Abstract ..................................................................................................................................................................................4
2. System Overview ...............................................................................................................................................................4
3. Goal ...........................................................................................................................................................................................5
4. The techniques & tools used. ......................................................................................................................................6
II. TASK TIMELINE & DIVISION ..................................................................................................................................................6
1. Contribution.........................................................................................................................................................................6
2. Project Timeline & Task Division..............................................................................................................................6
III. PROJECT ANALYSIS ...................................................................................................................................................................8
1. Requirements Analysis ..................................................................................................................................................8
2. Approach Analysis ............................................................................................................................................................9
2.1 Reviewed Materials .................................................................................................................................................9
2.2 Research Approach..................................................................................................................................................9
3. System Analysis ..............................................................................................................................................................10
3.1 Database Design .....................................................................................................................................................10
3.2 Database and Tables Creation ........................................................................................................................11
3.3 Database Data Insertion.....................................................................................................................................18
3.4 Database Queries ...................................................................................................................................................26
4. Application Java structure .........................................................................................................................................35
4.1 Project structure ....................................................................................................................................................36
4.2 Class structure ........................................................................................................................................................37
4.3 Connection implementation ............................................................................................................................39
4.4 G.U.I. Design – Frames implementation.....................................................................................................46
4.5 Buttons implementation ....................................................................................................................................51
4.6 Application Demo – Screenshots ...................................................................................................................56
IV. CONCLUSION..............................................................................................................................................................................61
1. Achieved goals .................................................................................................................................................................61
2. Future work ......................................................................................................................................................................62
3. Concluding thoughts.....................................................................................................................................................62
V. REFERENCES ...............................................................................................................................................................................63
LIST OF FIGURES
Figure 1. Primary Crow's Foot Format E.R.D. Diagram ................................................................... 10
Figure 2. Schema design created by using SQL Server.................................................................... 11
Figure 3. The project structures in IDE ................................................................................................... 36
Figure 4. UML Diagram of the project ...................................................................................................... 37
Figure 5. Free database hosting website for the project ................................................................. 39
Figure 6. Testing connection with the database ................................................................................. 40
Figure 7. Create a new G.U.I. Form in IDE .............................................................................................. 47
Figure 8. G.U.I. Designer Form for making a reservation................................................................ 48
Figure 9. Login interface for the first time running ........................................................................... 56
Figure 10. Specialist account registration successfully ...................................................................... 57
Figure 11. Patient dashboard with searched result ............................................................................. 58
Figure 12. Change user password successfully ...................................................................................... 58
Figure 13. Making a reservation successfully ......................................................................................... 59
Figure 14. Test-taking in progress................................................................................................................ 59
Figure 15. Score announcement .................................................................................................................... 60
Figure 16. Specialist posting reservation successfully ....................................................................... 61
Figure 17. Delist reservation successfully ................................................................................................ 61
Figure 18. Administrator mode for debugging purposes .................................................................. 61
LIST OF TABLES
Table 1. Individual responsibility and contribution ...............................................................................6
Table 2. Sprint planning and task division for individuals and teams ...........................................6
Table 3. Normal form achievement .............................................................................................................. 11
Table 4. An overview of all database entities and their attributes ............................................... 12
I. INTRODUCTION
1. Abstract
The Principles of Database Management course project involved developing a
mental healthcare services system with several features. These features included account
creation, searching for disease symptoms and solutions, finding reservations with
psychological specialists, and conducting mental health tests. The project also emphasized
creating a perfect database that adhered to the B.C. normal form. The database design
process logically defined data entities, relationships, attributes, and constraints. Achieving
the B.C. normal form ensured data integrity, eliminated anomalies, and optimized data
retrieval and storage ("1NF, 2NF, 3NF, and BCNF in Database Normalization | Studytonight,"
n.d.). The logical design was meticulously crafted to ensure system efficiency, reliability, and
scalability. The database contained data uploaded by reputable organizations from around
the world. This ensured that the information stored in the database was credible and
dependable. The system's user interface was designed to be user-friendly, enabling easy
access to various features. The search function allowed users to find information about
disease symptoms and solutions quickly. The reservation system provided a straightforward
way to schedule appointments with psychological specialists.
The mental health test feature also allowed users to assess their mental health status.
Overall, the project provided a valuable opportunity to apply database management
principles to a real-world problem in the field of mental health. It underscored the
significance of efficient and reliable data management in this domain. The thoughtful
approach to system features and design demonstrated a commitment to developing a robust
mental healthcare system. The project showcased the practical application of database
management principles in addressing challenges in mental health.
2. System Overview
The global pandemic has profoundly impacted mental health, resulting in increased
recognition of the importance of psychological therapy ("Depression," n.d.). In recent years,
there has been a significant shift in attitudes towards therapy, with more individuals
acknowledging its benefits and seeking professional help for their mental health concerns.
However, accessing traditional therapy can still be challenging for many people due to
factors such as long waitlists, high costs, and the enduring stigma associated with mental
health ("Suicide mortality rate (per 100,000 population) | Data," n.d.).
To address these barriers and meet the growing demand for mental health services,
online therapy platforms have emerged as a popular and accessible option. These platforms
offer a wide range of mental health services, including individual and group therapy sessions,
online resources, and support from licensed therapists. One of the critical advantages of
online therapy is its flexibility, allowing individuals to schedule sessions at their convenience
and receive therapy from the comfort of their homes. Moreover, these platforms often offer
more affordable pricing than traditional in-person therapy, making therapy accessible to a
broader audience.
Among the well-known online therapy platforms are BetterHelp, Talkspace, and
Amwell. BetterHelp provides various therapy options, including live sessions, messaging,
and chat support. Talkspace specializes in unlimited messaging therapy with licensed
therapists. On the other hand, Amwell offers mental health services as part of its broader
telehealth platform, including access to medical doctors and specialists.
The COVID-19 pandemic has further highlighted the significance of online therapy
platforms. With social distancing measures in place, many individuals have turned to these
platforms to continue receiving mental health support. Online therapy offers the added
benefits of anonymity and privacy, which can be particularly appealing to those who may
feel hesitant about seeking therapy in person due to stigma or other concerns.
It is important to note that while online therapy platforms offer numerous
advantages, they are not a substitute for traditional therapy, especially for individuals with
severe mental health conditions. These platforms, however, provide a valuable resource for
individuals seeking mental health support, offering a convenient and accessible alternative
to in-person therapy. While they are not a replacement for all types of therapy, online
platforms have become a valuable tool in supporting individuals' mental well-being and
addressing the increased demand for psychological support in today's challenging times.
3. Goal
- Design the database to suit the requirements of Normalization BC Normal Form.
- Connect the front-end interface (application) to the back-end database using a Java
connection driver.
- Develop the functions such as login, account creation, and booking; take a test using
complex queries.
- Evaluate the data and give more precise predictions in the future for the users.
- Take security measures in the database to ensure robust privacy for the users' data
and prevent any hacking into the system (known as SQL Injection).
specialists. Users can access and extract data based on their role and request additions to the
system's database. Patients can take tests to identify psychological disorders and receive
recommended solutions. The system will provide information on common mental illnesses,
symptoms, and potential solutions.
2. Approach Analysis
2.1 Reviewed Materials
- Advanced SQL Server language structure ("SQL Tutorial," n.d.).
- Java, JDBC, Swing Worker official usage documents ("Lesson: JDBC Basics (The
JavaTM Tutorials > JDBC Database Access)," n.d.), ("SwingWorker (Java Platform S.E.
8 )," n.d.).
2.2 Research Approach
a) Methodology
The Scrum framework, a part of the Agile approach, has been adopted for the project.
Teams can deliver products using Scrum, which emphasizes adaptability and responsiveness
to change in iterative and incremental stages. It is frequently called an "agile project
management framework" and concentrates on controlling circumstances to manage time
and expense. Traditional project management techniques, on the other hand, focus on set
requirements to manage time and costs. To support efficient project management, Scrum
uses several strategies, including time boxes, group rituals, a prioritized product backlog,
and regular feedback loops.
b) Process
The product backlog, which serves as a to-do list for the project, contains the features.
The team sets a sprint backlog with features and activities at the sprint planning meeting by
choosing the product backlog items they think can be completed during the sprint period.
When the team decides on the sprint backlog, they begin working on the assigned tasks with
a single, undivided concentration on reaching the sprint goal. The product backlog can be
altered before the start of the subsequent sprint, while the sprint backlog is left alone during
the sprint.
The team meets for a 15-minute scrum during the sprint to discuss remaining tasks,
offer updates on their progress, and resolve any issues they encounter. Each team member
presents their work to the other members of the team, who provide insightful feedback that
helps them plan the subsequent sprint and make required modifications. The three Scrum
pillars of transparency, inspection, and adaptability, which stress the value of open
communication, ongoing review, and the capacity to adjust to changing conditions, serve as
the framework for these meetings.
3. System Analysis
3.1 Database Design
a. Database Creation
CREATE DATABASE [congbang0711_]
USE [congbang0711_]
Table Attributes
User_ID bigint IDENTITY(1, 1) PRIMARY KEY
User_name varchar(50) NOT NULL
Account
Password varbinary(20) NOT NULL
Salt varchar(100) NOT NULL
Specialist_ID int IDENTITY(1, 1) PRIMARY KEY
UserID bigint NOT NULL
FullName varchar(50) NOT NULL
DoB date NOT NULL
Sex varchar(10) NOT NULL
Specialist
Email varchar(50) NOT NULL
Phone varchar(15) NOT NULL
IndentifyNumber varchar(50) NOT NULL
GraduationUniversity varchar(50) NOT NULL
Patient Table:
CREATE TABLE [Account].[Patient] ([Patient_ID] [int] IDENTITY(1, 1) PRIMARY
KEY,
[UserID] [bigint] NOT NULL,
[FullName] [varchar](50) NOT NULL,
[DoB] [date] NOT NULL,
[Sex] [varchar](10) NOT NULL,
[Email] [varchar](50) NOT NULL,
FOREIGN KEY(UserID)REFERENCES [Account].[Account](User_ID))
PatientRecord Table:
Specialist Table:
CREATE TABLE [Account].[Specialist] ([Specialist_ID] [int] IDENTITY(1, 1)
PRIMARY KEY,
[UserID] [bigint] NOT NULL,
[FullName] [varchar](50) NOT NULL,
[DoB] [date] NOT NULL,
[Sex] [varchar](10) NOT NULL,
[Email] [varchar](50) NOT NULL,
[Phone] [varchar](15) NOT NULL,
[IdentifyNumber] [varchar](50) NOT NULL,
[GraduationUniversity] [varchar](50) NOT NULL,
FOREIGN KEY(UserID)REFERENCES [Account].[Account](User_ID))
d. Booking Schema
HealingInformation Table:
CREATE TABLE [Booking].[HealingInformation] ([HealingInformation_ID] [int]
IDENTITY(1, 1) PRIMARY KEY,
[SpecialistID] [int] NOT NULL,
[Place] [varchar](50) NOT NULL,
[Date] [date] NOT NULL CHECK(Date>CAST(GetDate() as Date)),
[Fee] [money] NOT NULL,
[Description] [varchar](200) NOT NULL,
[Extra_Information] [varchar](100),
FOREIGN KEY(SpecialistID)REFERENCES [Account].[Specialist](Specialist_ID))
Booking Table:
CREATE TABLE [Booking].[Booking] ([Book_ID] [int] IDENTITY(1, 1) PRIMARY
KEY,
[PatientID] [int] NOT NULL,
e. Disease Schema
Disease Table:
CREATE TABLE [Disease].[Disease] ([Disease_ID] [int] PRIMARY KEY,
[Name] [varchar](50) NOT NULL,
[Description] [varchar](200) NOT NULL)
Symptom Table:
CREATE TABLE [Disease].[Symptom] ([Symptom_ID] [int] PRIMARY KEY,
[Name] [varchar](50) NOT NULL,
[Description] [varchar](100) NOT NULL)
DiseaseSymptom Table:
CREATE TABLE [Disease].[DiseaseSymptom] ([ID] [int] PRIMARY KEY,
[DiseaseID] [int] NOT NULL,
[SymptomID] [int] NOT NULL,
FOREIGN KEY(DiseaseID)REFERENCES [Disease].[Disease](Disease_ID),
FOREIGN KEY(SymptomID)REFERENCES [Disease].[Symptom](Symptom_ID))
f. Test Schema
Test Table:
CREATE TABLE [Test].[Test] ([Test_ID] [int] PRIMARY KEY,
[Total] [int],
[No_Question] [int],
[DiseaseID] [int] NOT NULL,
FOREIGN KEY(DiseaseID)REFERENCES [Disease].[Disease](Disease_ID))
Result Table:
CREATE TABLE [Test].[Result] ([Result_ID] [int] PRIMARY KEY,
Question Table:
CREATE TABLE [Test].[Question] ([Question_ID] [int] PRIMARY KEY,
[TestID] [int] NOT NULL,
[Title] [varchar](500) NOT NULL,
[AnswerSetID] [int] NOT NULL,
FOREIGN KEY(TestID)REFERENCES [Test].[Test](Test_ID),
FOREIGN KEY(AnswerSetID)REFERENCES [Test].[AnswerSet](AnswerSet_ID))
AnswerSet Table:
CREATE TABLE [Test].[AnswerSet] ([AnswerSet_ID] [int] PRIMARY KEY,
[No_Answer] [int] NOT NULL)
AnswerSetContent Table:
CREATE TABLE [Test].[AnswerSetContent] ([ID] [int] PRIMARY KEY,
[AnswerSetID] [int] NOT NULL,
[AnswerID] [int] NOT NULL,
FOREIGN KEY(AnswerID)REFERENCES [Test].[Answer](Answer_ID),
FOREIGN KEY(AnswerSetID)REFERENCES [Test].[AnswerSet](AnswerSet_ID))
Answer Table:
CREATE TABLE [Test].[Answer] ([Answer_ID] [int] PRIMARY KEY,
[Title] [varchar](100) NOT NULL,
[Weight] [int] NOT NULL)
g. Solution Schema
Solution Table:
CREATE TABLE [Solution].[Solution] ([Solution_ID] [int] PRIMARY KEY,
[Name] [varchar](50) NOT NULL,
[Type] [varchar](50) NOT NULL,
Recommendation Table:
CREATE TABLE [Solution].[Recommendation] ([ID] [int] PRIMARY KEY,
[SolutionID] [int] NOT NULL,
[ResultID] [int] NOT NULL,
FOREIGN KEY(SolutionID)REFERENCES [Solution].[Solution](Solution_ID),
FOREIGN KEY(ResultID)REFERENCES [Test].[Result](Result_ID))
CureOneByOne Table:
CREATE TABLE [Solution].[CureOneByOne] ([ID] [int] PRIMARY KEY,
[SolutionID] [int],
[SymptomID] [int] NOT NULL,
FOREIGN KEY(SolutionID)REFERENCES [Solution].[Solution](Solution_ID),
FOREIGN KEY(SymptomID)REFERENCES [Disease].[Symptom](Symptom_ID))
In this report, the first five rows of each table are demonstrated to preview the data insert
only, and the complete data can be found using the backup file attached to this report.
b. Account Schema
Account Table:
INSERT [Account].[Account]([User_ID], [User_name], [Salt], [Password])
VALUES(1, N'tucute123', N'9Pn(2',
0xDD4689A6BF12DFA64DDD713199BA53B51F65AD53)
INSERT [Account].[Account]([User_ID], [User_name], [Salt], [Password])
VALUES(2, N'lamthanhluan2907', N'6Eb(2',
0x698BF12AA5B33A21903D296B5784158A6DFB1378)
INSERT [Account].[Account]([User_ID], [User_name], [Salt], [Password])
VALUES(3, N'vanbui.work', N'0Lw%2',
0x01D1D332798FD5D6EE495294886ABD5886418F1A)
INSERT [Account].[Account]([User_ID], [User_name], [Salt], [Password])
VALUES(4, N'guangyaoaoao', N'0Rk$8',
0xAC9B7169C63453090BDAA6E857338528B77BC43F)
INSERT [Account].[Account]([User_ID], [User_name], [Salt], [Password])
VALUES(5, N'congbang', N'5Sj%3', 0xC17EDC261652EC7CD357BC6850B8962B9EE9216A)
Patient Table:
INSERT [Account].[Patient]([Patient_ID], [UserID], [FullName], [DoB], [Sex],
[Email])
VALUES(1, 1, N'Nguyen Hoang Anh Tu', CAST(N'2002-06-13' AS Date), N'Male',
N'nghganhtu@gmail.com')
INSERT [Account].[Patient]([Patient_ID], [UserID], [FullName], [DoB], [Sex],
[Email])
VALUES(2, 3, N'Bui Thi Cam Van', CAST(N'2002-12-08' AS Date), N'Female',
N'buicamvan.work@gmail.com')
INSERT [Account].[Patient]([Patient_ID], [UserID], [FullName], [DoB], [Sex],
[Email])
VALUES(3, 4, N'Nguyen Quang Dieu', CAST(N'2002-05-29' AS Date), N'Male',
N'guangyao@gmail.com')
INSERT [Account].[Patient]([Patient_ID], [UserID], [FullName], [DoB], [Sex],
[Email])
PatientRecord Table:
INSERT [Account].[PatientRecord]([ID], [PatientID], [ResultID])
VALUES(1, 1, 2)
INSERT [Account].[PatientRecord]([ID], [PatientID], [ResultID])
VALUES(2, 5, 19)
INSERT [Account].[PatientRecord]([ID], [PatientID], [ResultID])
VALUES(3, 1, 4)
INSERT [Account].[PatientRecord]([ID], [PatientID], [ResultID])
VALUES(4, 3, 15)
INSERT [Account].[PatientRecord]([ID], [PatientID], [ResultID])
VALUES(5, 4, 1)
Specialist Table:
INSERT [Account].[Specialist]([Specialist_ID], [UserID], [FullName], [DoB],
[Sex], [Email], [Phone], [GraduationUniversity], [IdentifyNumber])
VALUES(1, 2, N'Lam Thanh Luan', CAST(N'1990-06-13' AS Date), N'Male',
N'lamthanhluan@gmail.com', N'0913517039', N'Sai Gon University',
N'403697021687539')
INSERT [Account].[Specialist]([Specialist_ID], [UserID], [FullName], [DoB],
[Sex], [Email], [Phone], [GraduationUniversity], [IdentifyNumber])
VALUES(2, 6, N'Pham Minh Vu', CAST(N'1985-06-13' AS Date), N'Male',
N'laimaybay@gmail.com', N'0947513068', N'International University',
N'5103697140687439')
INSERT [Account].[Specialist]([Specialist_ID], [UserID], [FullName], [DoB],
[Sex], [Email], [Phone], [GraduationUniversity], [IdentifyNumber])
VALUES(5, 28, N'Trinh Duc Bao', CAST(N'2002-09-06' AS Date), N'Male',
N'trducbo@gmail.com', N'0944738291', N'International University',
N'032428934334')
c. Booking Schema
HealingInformation Table:
INSERT [Booking].[Booking]([Book_ID], [PatientID], [HealingInformationID])
VALUES(1, 5, 1)
INSERT [Booking].[Booking]([Book_ID], [PatientID], [HealingInformationID])
VALUES(3, 2, 2)
INSERT [Booking].[Booking]([Book_ID], [PatientID], [HealingInformationID])
VALUES(5, 1, 4)
INSERT [Booking].[Booking]([Book_ID], [PatientID], [HealingInformationID])
VALUES(6, 1, 8)
Booking Table:
INSERT [Booking].[HealingInformation]([HealingInformation_ID],
[SpecialistID], [Place], [Date], [Fee], [Description], [Extra_Information])
VALUES(1, 1, N'Quan 3', CAST(N'2023-05-01' AS Date), 300000.0000, N'I will
help you to get out of your mental problem within 1 hour', N'Please come in
the morning')
INSERT [Booking].[HealingInformation]([HealingInformation_ID],
[SpecialistID], [Place], [Date], [Fee], [Description], [Extra_Information])
VALUES(2, 2, N'Quan 1', CAST(N'2023-05-01' AS Date), 400000.0000, N'If you
need help, come to me', NULL)
INSERT [Booking].[HealingInformation]([HealingInformation_ID],
[SpecialistID], [Place], [Date], [Fee], [Description], [Extra_Information])
VALUES(4, 2, N'Quan 1', CAST(N'2023-05-05' AS Date), 400000.0000, N'If you
need help, come to me', N'I am free in the afternoon')
INSERT [Booking].[HealingInformation]([HealingInformation_ID],
[SpecialistID], [Place], [Date], [Fee], [Description], [Extra_Information])
VALUES(5, 2, N'Quan 1', CAST(N'2023-05-06' AS Date), 400000.0000, N'If you
need help, come to me', NULL)
INSERT [Booking].[HealingInformation]([HealingInformation_ID],
[SpecialistID], [Place], [Date], [Fee], [Description], [Extra_Information])
VALUES(6, 2, N'Quan 1', CAST(N'2023-05-13' AS Date), 400000.0000, N'If you
need help, come to me', NULL)
d. Disease Schema
Disease Table:
INSERT [Disease].[Disease]([Disease_ID], [Name], [Description])
VALUES(1, N'Depression', N'Depression is a mood disorder that causes a
persistent feeling of sadness and loss of interest.')
INSERT [Disease].[Disease]([Disease_ID], [Name], [Description])
VALUES(2, N'Stress', N'Stress is a consequence of experiencing pressure or
tension.')
INSERT [Disease].[Disease]([Disease_ID], [Name], [Description])
VALUES(3, N'Anxiety', N'Anxiety is an emotion caused by a perceived or
experienced threat, which often leads to an avoidance or evasion thereof.')
INSERT [Disease].[Disease]([Disease_ID], [Name], [Description])
VALUES(4, N'Borderline', N'Borderline is a personality disorder. People with
borderline have fast-changing feelings toward friendship, love, and so on.')
INSERT [Disease].[Disease]([Disease_ID], [Name], [Description])
VALUES(5, N'Migraine', N'Migraine is an illness, where regular intense
attacks of headache occur. In the case of migraine, this headache often only
takes place at one side of the head, and causes a pounding type of pain')
Symptom Table:
INSERT [Disease].[Symptom]([Symptom_ID], [Name], [Description])
VALUES(1, N'Eating disorder', N'Physical')
INSERT [Disease].[Symptom]([Symptom_ID], [Name], [Description])
VALUES(2, N'Sleeping disorder', N'Physical')
INSERT [Disease].[Symptom]([Symptom_ID], [Name], [Description])
VALUES(3, N'Having fewer feelings', N'Mental')
INSERT [Disease].[Symptom]([Symptom_ID], [Name], [Description])
VALUES(4, N'Decrease libido', N'Physical')
INSERT [Disease].[Symptom]([Symptom_ID], [Name], [Description])
VALUES(5, N'Tension', N'Mental')
DiseaseSymptom Table:
INSERT [Disease].[DiseaseSymptom]([I.D.], [DiseaseID], [SymptomID])
VALUES(1, 1, 15)
INSERT [Disease].[DiseaseSymptom]([I.D.], [DiseaseID], [SymptomID])
VALUES(2, 1, 30)
INSERT [Disease].[DiseaseSymptom]([I.D.], [DiseaseID], [SymptomID])
VALUES(3, 1, 19)
INSERT [Disease].[DiseaseSymptom]([I.D.], [DiseaseID], [SymptomID])
VALUES(4, 1, 31)
INSERT [Disease].[DiseaseSymptom]([I.D.], [DiseaseID], [SymptomID])
VALUES(5, 1, 2)
e. Test Schema
Test Table:
INSERT [Test].[Test]([Test_ID], [Total], [No_Question], [DiseaseID])
VALUES(1, 27, 9, 1)
INSERT [Test].[Test]([Test_ID], [Total], [No_Question], [DiseaseID])
VALUES(2, 40, 10, 2)
INSERT [Test].[Test]([Test_ID], [Total], [No_Question], [DiseaseID])
VALUES(3, 40, 10, 3)
INSERT [Test].[Test]([Test_ID], [Total], [No_Question], [DiseaseID])
VALUES(4, 17, 9, 4)
INSERT [Test].[Test]([Test_ID], [Total], [No_Question], [DiseaseID])
VALUES(5, NULL, NULL, 5)
Result Table:
INSERT [Test].[Result]([Result_ID], [TestID], [Weight], [Description])
VALUES(1, 1, 80, N'Little Severe')
INSERT [Test].[Result]([Result_ID], [TestID], [Weight], [Description])
VALUES(2, 1, 100, N'Severe')
INSERT [Test].[Result]([Result_ID], [TestID], [Weight], [Description])
VALUES(3, 2, 80, N'Little Severe')
INSERT [Test].[Result]([Result_ID], [TestID], [Weight], [Description])
VALUES(4, 2, 100, N'Severe')
INSERT [Test].[Result]([Result_ID], [TestID], [Weight], [Description])
VALUES(5, 3, 80, N'Little Severe')
Question Table:
INSERT [Test].[Question]([Question_ID], [TestID], [Title], [AnswerSetID])
VALUES(1, 1, N'Little interest or pleasure in doing things?', 1)
INSERT [Test].[Question]([Question_ID], [TestID], [Title], [AnswerSetID])
AnswerSet Table:
INSERT [Test].[AnswerSet]([AnswerSet_ID], [No_Answer])VALUES(1, 4)
INSERT [Test].[AnswerSet]([AnswerSet_ID], [No_Answer])VALUES(2, 5)
INSERT [Test].[AnswerSet]([AnswerSet_ID], [No_Answer])VALUES(3, 2)
INSERT [Test].[AnswerSet]([AnswerSet_ID], [No_Answer])VALUES(4, 3)
INSERT [Test].[AnswerSet]([AnswerSet_ID], [No_Answer])VALUES(5, 2)
AnswerSetContent Table:
INSERT [Test].[AnswerSetContent]([I.D.], [AnswerSetID], [AnswerID])
VALUES(1, 1, 1)
INSERT [Test].[AnswerSetContent]([I.D.], [AnswerSetID], [AnswerID])
VALUES(2, 1, 2)
INSERT [Test].[AnswerSetContent]([I.D.], [AnswerSetID], [AnswerID])
VALUES(3, 1, 3)
INSERT [Test].[AnswerSetContent]([I.D.], [AnswerSetID], [AnswerID])
VALUES(4, 1, 4)
INSERT [Test].[AnswerSetContent]([I.D.], [AnswerSetID], [AnswerID])
VALUES(5, 2, 5)
Answer Table:
INSERT [Test].[Answer]([Answer_ID], [Title], [Weight])
VALUES(1, N'Not at all', 0)
INSERT [Test].[Answer]([Answer_ID], [Title], [Weight])
VALUES(2, N'Several days', 1)
INSERT [Test].[Answer]([Answer_ID], [Title], [Weight])
VALUES(3, N'More than half the days', 2)
INSERT [Test].[Answer]([Answer_ID], [Title], [Weight])
f. Solution Schema
Solution Table:
INSERT [Solution].[Solution]([Solution_ID], [Name], [Type], [Benefit],
[Platform], [Description])
VALUES(1, N'Sheep in Dream', N'Game', N'Sleep', N'Mobile App', N'Sheep in
Dream is a game about getting a boy to sleep by making sheep jump over a
log. The sheep are in the top left corner of the screen on a dream hill and
the boy is in his bed at the bottom. ')
INSERT [Solution].[Solution]([Solution_ID], [Name], [Type], [Benefit],
[Platform], [Description])
VALUES(2, N'Love is in small things', N'Game', N'Relationship', N',Mobile
App', N'Love is…in small things is one of the romantic games made
by Lunosoft. The game showcases the lively artwork of a South Korean artist
who goes by the name Puuung and is a romantic title')
INSERT [Solution].[Solution]([Solution_ID], [Name], [Type], [Benefit],
[Platform], [Description])
VALUES(3, N'My Oasis: Relaxing, Satisfying', N'Game', N'Communicate-Calm',
N'Mobile App', N'My Oasis: Anxiety Relief Game is a relaxing game that helps
in calming your mind, relieve your stress. This anti anxiety game helps in
relaxation and calm sleeping.')
INSERT [Solution].[Solution]([Solution_ID], [Name], [Type], [Benefit],
[Platform], [Description])
VALUES(4, N'Focus Plant: Pomodoro timer', N'App', N'Focus', N'Mobile App',
N'Focus is a gamified focus study timer app to help people better manage
their time and focus on the important things in their life. Some times self-
discipline is just not enough to keep us away from the phones. This is when
gamification comes in, the in-game achievements encourage users to stick
with the app, better manage their time and get things done.')
INSERT [Solution].[Solution]([Solution_ID], [Name], [Type], [Benefit],
[Platform], [Description])
VALUES(5, N'Wokamon - Walking app game', N'Game', N'Exercise', N'Mobile
App', N'Wokamons are running out of resources and they need your help! Every
step you take is turned into energy. Use it to feed, grow and collect
Wokamons. The more you walk, the more Wokamons you can collect and the
further you get to explore the magical Woka-worlds like candy desert, icy
realm, mystical forest and more! Lend a helping hand and soon you will find,
the more you help, the fitter you get!')
Recommendation Table:
INSERT [Solution].[Recommendation]([ID], [SolutionID], [ResultID])
VALUES(1, 30, 1)
INSERT [Solution].[Recommendation]([ID], [SolutionID], [ResultID])
VALUES(2, 18, 1)
INSERT [Solution].[Recommendation]([ID], [SolutionID], [ResultID])
VALUES(3, 13, 1)
INSERT [Solution].[Recommendation]([ID], [SolutionID], [ResultID])
VALUES(4, 53, 2)
INSERT [Solution].[Recommendation]([ID], [SolutionID], [ResultID])
VALUES(5, 11, 2)
CureOneByOne Table:
INSERT [Solution].[CureOneByOne]([I.D.], [SolutionID], [SymptomID])
VALUES(1, 58, 1)
INSERT [Solution].[CureOneByOne]([I.D.], [SolutionID], [SymptomID])
VALUES(2, 1, 2)
INSERT [Solution].[CureOneByOne]([I.D.], [SolutionID], [SymptomID])
VALUES(3, 3, 3)
INSERT [Solution].[CureOneByOne]([I.D.], [SolutionID], [SymptomID])
VALUES(4, 59, 4)
INSERT [Solution].[CureOneByOne]([I.D.], [SolutionID], [SymptomID])
VALUES(5, 56, 5)
Most queries shown below are in the same form of this structure to ensure the user
input is sanitized, where each question mark shows it is parameterized to suit the content
user data:
o INNER JOIN: to join the table for more linked data query
b. Register account
Our system users can create accounts with two roles: Patient and Specialist. In
addition, we provide several features, such as password change and display of the user's
name in the welcome message.
User login authentication
The following query is used to check if user login credentials are correct and exist in
the database; this query returns the role also for later use in other queries.
DECLARE @UserName AS VARCHAR(50) = ?
DECLARE @Pwd AS VARCHAR(30) = ?
SELECT CASE WHEN A.User_ID=P.UserID AND P.UserID IS NOT NULL THEN 'Patient'
WHEN A.User_ID=S.UserID AND S.UserID IS NOT NULL THEN 'Specialist' ELSE NULL END
AS Role, CASE WHEN A.User_ID=P.UserID AND P.UserID IS NOT NULL THEN P.Patient_ID
WHEN A.User_ID=S.UserID AND S.UserID IS NOT NULL THEN S.Specialist_ID ELSE NULL END AS
ID
FROM [Account].[Account] A
FULL JOIN [Account].[Patient] P ON A.User_ID=P.UserID
FULL JOIN [Account].[Specialist] S ON A.User_ID=S.UserID
WHERE A.User_name=@UserName AND A.Password=HASHBYTES('SHA1', CONCAT(@Pwd, (SELECT A.Salt
FROM [Account].[Account] A WHERE A.User_name=@UserName)))
Patient registration
The following query is used to create an account for a user with the patient role,
containing basic information such as account name, password, and personal information.
The password is secured by adding a salt value after each password input to create a hash,
which cannot be retrieved back to string one.
DECLARE @Username VARCHAR(50) = ?
DECLARE @Pwd AS VARCHAR(30) = ?
DECLARE @Salt AS VARCHAR(5)
SET @Salt=CONCAT(CHAR(FLOOR(RAND()* 10)+48), CHAR(FLOOR(RAND()* 26)+65),
CHAR(FLOOR(RAND()* 26)+97), CHAR(FLOOR(RAND()* 15)+33), CHAR(FLOOR(RAND()* 10)+48))
INSERT INTO [Account].[Account]([User_name], [Password], [Salt])
VALUES(@Username, HASHBYTES('SHA1', CONCAT(@Pwd, @Salt)), @Salt)
INSERT INTO [Account].[Patient]([UserID], [FullName], [DoB], [Sex], [Email])
VALUES((SELECT User_ID FROM [Account].[Account] A WHERE A.User_name = ?), ?, ?, ?, ?)
Specialist registration
The following query is used to create an account for a user with the specialist role,
containing basic information such as account name, password, personal information, and
identity information. The password is secured by adding a salt value after each password to
create a hash that cannot be retrieved back to the string value.
DECLARE @Username AS VARCHAR(50) = ?
DECLARE @Pwd AS VARCHAR(30) = ?
DECLARE @Salt AS VARCHAR(5)
SET @Salt=CONCAT(CHAR(FLOOR(RAND()* 10)+48), CHAR(FLOOR(RAND()* 26)+65), CHAR(FLOOR(RAND()*
26)+97), CHAR(FLOOR(RAND()* 15)+33), CHAR(FLOOR(RAND()* 10)+48))
INSERT INTO [Account].[Account]([User_name], [Password], [Salt])
VALUES(@Username, HASHBYTES('SHA1', CONCAT(@Pwd, @Salt)), @Salt)
INSERT INTO [Account].[Specialist]([UserID], [FullName], [DoB], [Sex], [Email], [Phone],
[IdentifyNumber], [GraduationUniversity])
VALUES((SELECT User_ID FROM [Account].[Account] A WHERE A.User_name=?), ?, ?, ?, ?, ?, ?, ?)
Username display
This query displays the username on the system welcoming message based on the
user's I.D.
DECLARE @UserID AS INT = ?
WHERE D.Name= ?
The query below is used to show the weight of each answer to calculate the result of
the patient for the test.
SELECT A.Weight
FROM [Test].[Question] Q
INNER JOIN [Test].[AnswerSet] ASET ON Q.AnswerSetID=ASET.AnswerSet_ID
INNER JOIN [Test].[AnswerSetContent] ASCon ON
ASCon.AnswerSetID=ASET.AnswerSet_ID
INNER JOIN [Test].[Answer] A ON ASCon.AnswerID=A.Answer_ID
WHERE Q.Question_ID= ?
The system will run the query below to check the patients at the severe disease
level.
SELECT TOP 1 Pa.FullName, Pa.Sex, Pa.DoB, COUNT(Description) NumberOfSevereDisease
FROM [Account].[Patient] Pa
INNER JOIN [Account].[PatientRecord] Pr ON Pa.Patient_ID=Pr.PatientID
INNER JOIN [Test].[Result] R ON PR.ResultID=R.Result_ID
WHERE R.Description LIKE 'Severe'
GROUP BY Pa.FullName, Pa.Sex, Pa.DoB
ORDER BY NumberOfSevereDisease DESC
FROM [Account].[Specialist] S
INNER JOIN [Booking].[HealingInformation] H ON S.Specialist_ID=H.SpecialistID
INNER JOIN [Booking].[Booking] B ON
H.HealingInformation_ID=B.HealingInformationID
GROUP BY S.Specialist_ID, S.FullName
ORDER BY NumberOfBookedReservation DESC
Find the disease for which the patients have the most
The system will run the query below to display the disease the patients have the
most.
SELECT TOP 1 D.Name, D.Description, COUNT(PR.ResultID) NumberOfDoneTest
FROM [Disease].[Disease] D
INNER JOIN [Test].[Test] T ON D.Disease_ID=T.Test_ID
INNER JOIN [Test].[Result] R ON T.Test_ID=R.TestID
INNER JOIN [Account].[PatientRecord] PR ON R.Result_ID=PR.ResultID
GROUP BY D.Name, D.Description
ORDER BY NumberOfDoneTest DESC
o src: the project's source code mainly contains the class and frm files used
by G.U.I. Designer.
o .gitgnore, mindfulness.iml, README.md: used for project setup
on GitHub Version Control System and provide based configuration per
developers.
4.2 Class structure
Taking a closer look at each class used, we have the following UML Diagram to show the
dependence of each class on others and provide a quicker view of the methods
implementations
o frmTest.java: manages the TEST frame and logic for buttons inside it
for patients to take tests in the system.
4.3 Connection implementation
First, we go to the www.freeasphosting.net website to create a remote database like
the figure below:
Then we connect to the database (for use in the IDE) using the information provided
and run the CREATE DATABASE, CREATE TABLE, and INSERT INTO queries
above to begin initializing our database.
After doing all the creation, it is time to implement our ConnectSQL.java class to manage
all the queries used in the project. First is to import the JDBC Driver using and setting the
connection URL of:
import java.sql.*;
import net.proteanit.sql.DbUtils;
static final String connectionUrl =
"jdbc:sqlserver://sql.bsite.net\\MSSQL2016;databaseName=congbang0711_;user=con
gbang0711_;password=mindfulness;encrypt=true;trustServerCertificate=true;";
Then, there are some methods to help with closing connections and displaying the
result in tabular form:
public static void closeConnect(Connection con) {
if (con != null) {
try {
con.close();
} catch (SQLException e) {
System.out.println("Error closing connection");
}
}
}
};
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
Finally, we can make the methods that use the queries above by following the
structure grouped by and call these methods when the button is clicked when checking the
return have any value ("How to check if ResultSet is empty in JDBC Java - Example
Tutorial," n.d.):
o Standard queries (can return any data based on the results)
public static ArrayList<Integer> showTestQuery() {
Connection con = null;
PreparedStatement stmt;
ResultSet rs;
ArrayList<Integer> results = new ArrayList<>();
try {
con = DriverManager.getConnection(connectionUrl);
String preparedQuery =
"""
SELECT Test_ID AS ID
FROM [Test].[Test]""";
stmt = con.prepareStatement(preparedQuery);
rs = stmt.executeQuery();
while (rs.next()) {
results.add(rs.getInt("id"));
}
} catch (SQLException e) {
throw new RuntimeException(e);
} finally {
closeConnect(con);
}
return results;
}
o Parameterized queries (can also return any data based on the result)
public static String showSearchQuery(String queryTxt) {
Connection con = null;
PreparedStatement stmt;
ResultSet rs;
StringBuilder result = new StringBuilder();
try {
con = DriverManager.getConnection(connectionUrl);
String preparedQuery =
"""
SELECT S.Name AS symptom, So.Name AS solution, So.Platform,
So.Description FROM [Disease].[Disease] D INNER JOIN
[Disease].[DiseaseSymptom] DS ON D.Disease_ID = DS.DiseaseID
INNER JOIN [Disease].[Symptom] S ON DS.SymptomID =
S.Symptom_ID
INNER JOIN [Solution].[CureOneByOne] C ON S.Symptom_ID =
C.SymptomID
INNER JOIN [Solution].[Solution] So ON C.SolutionID =
So.Solution_ID WHERE D.Name = ?""";
stmt = con.prepareStatement(preparedQuery);
stmt.setString(1, queryTxt);
rs = stmt.executeQuery();
while (rs.next()) {
result
.append("Possible symptom: ")
.append(rs.getString("symptom"))
.append(" has the solution of: ")
.append(rs.getString("solution"))
.append(". Please see at: ")
.append(rs.getString("platform"))
.append(", more details: ")
.append(rs.getString("description"))
.append("\n\n");
}
} catch (SQLException e) {
throw new RuntimeException(e);
} finally {
closeConnect(con);
}
return result.toString();
}
o Update queries (return true/false Boolean value for system to notify user)
public static boolean submitPasswordUpdate(String userTxt, String oldPwdTxt,
String newPwdTxt) {
Connection con = null;
PreparedStatement stmt;
int rs;
boolean isUpdated = false;
try {
con = DriverManager.getConnection(connectionUrl);
con.setAutoCommit(false);
String updateString =
"""
DECLARE @UserName AS VARCHAR(50) = ?
DECLARE @oldPwd AS VARCHAR(30) = ?
DECLARE @newPwd AS VARCHAR(30) = ?
DECLARE @Salt AS VARCHAR(5)
S.E.T. @Salt
= CONCAT(
CHAR(FLOOR(RAND() * 10) + 48),
CHAR(FLOOR(RAND() * 26) + 65),
CHAR(FLOOR(RAND() * 26) + 97),
CHAR(FLOOR(RAND() * 15) + 33),
CHAR(FLOOR(RAND() * 10) + 48))
UPDATE [Account].[Account]
SET Password = HASHBYTES('SHA1', CONCAT(@newPwd, @Salt)),
Salt = @Salt
WHERE User_name = @UserName
o Removal queries (return true/false Boolean value for system to notify user)
public static boolean delistHealingUpdate(String specialistTxt, String
healingTxt) {
Connection con = null;
PreparedStatement stmt;
int rs;
boolean isUpdated = false;
try {
con = DriverManager.getConnection(connectionUrl);
con.setAutoCommit(false);
String updateString =
"""
DELETE FROM [Booking].[HealingInformation]
WHERE SpecialistID = ? AND HealingInformation_ID = ?
""";
stmt = con.prepareStatement(updateString);
stmt.setString(1, specialistTxt);
stmt.setString(2, healingTxt);
rs = stmt.executeUpdate();
if (rs > 0) {
isUpdated = true;
}
con.commit();
} catch (SQLException e) {
return isUpdated;
} finally {
closeConnect(con);
}
return isUpdated;
From then, we can drag-and-drop the elements to the JFrame created; some of the
frequent usages are:
o JTextArea: to display the message after the query has been done.
txtArea.selectAll();
txtArea.replaceSelection("");
txtArea.setText("");
txtArea.setEditable(false);
JOptionPane.showMessageDialog(
null,
"Account: "
+ frmIndex.getInstance().getCredentials()[0]
+ " registered successfully. Thank you!",
"Success",
JOptionPane.INFORMATION_MESSAGE);
int option =
JOptionPane.showConfirmDialog(
null,
"Please check the information carefully!",
"Confirmation",
JOptionPane.YES_NO_OPTION,
JOptionPane.QUESTION_MESSAGE);
message,
"Password Required",
JOptionPane.YES_NO_OPTION,
JOptionPane.QUESTION_MESSAGE);
To initialize the frames, we will use the constructor provided; with the use of the
Singleton Design Pattern, we can save time by not reloading all the elements again as:
o Default constructor
public frmTest() {
setContentPane(panel);
setTitle("mindfulNESS - Self-diagnosis test");
setSize(1200, 800);
setLocationRelativeTo(null);
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
}
o Singleton constructor
private static frmIndex instance;
private frmIndex() {
setContentPane(panel);
setTitle("mindfulNESS - Homepage");
setSize(800, 800);
setLocationRelativeTo(null);
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
}
public static synchronized frmIndex getInstance() {
if (instance == null) {
instance = new frmIndex();
}
return instance;
}
frmIndex.getInstance().setVisible(true);
setVisible(false);
o The frame that needs to be loaded with content uses these methods:
@Override
public void setVisible(boolean visible) {
super.setVisible(visible);
if (isVisible()) {
pwdField.setText("");
}
}
All together, they are put inside a class that runs like this with all the variables and
methods for working:
public class frmPatientDashboard extends JFrame {}
return;
}
SwingWorker<Void, Void> worker =
new SwingWorker<>() {
@Override
protected Void doInBackground() {
ConnectSQL.showQuery(queryField.getText(), resultTable);
return null;
}
@Override
protected void done() {
runQueryButton.setEnabled(true);
}
};
worker.execute();
});
@Override
protected void done() {
healButton.setEnabled(true);
}
};
worker.execute();
});
o Cancel healing, and delist healing buttons: for users to cancel any
reservations they made.
o Answer A, B, C, and D buttons: to show answer content and accompany the
user when doing tests.
o Clear all button: to clear all the fields after confirming dialog.
clearAllButton.addActionListener(
e -> {
int option =
JOptionPane.showConfirmDialog(
null,
"Are you sure you want to clear all field(s)?",
"Confirmation",
JOptionPane.YES_NO_OPTION,
JOptionPane.WARNING_MESSAGE);
if (option == JOptionPane.YES_OPTION) {
clearAllButton.setEnabled(false);
SwingWorker<Void, Void> worker =
new SwingWorker<>() {
@Override
protected Void doInBackground() {
fullNameField.setText("");
emailField.setText("");
dobField.setText("");
genderField.setSelectedItem("<please choose>");
return null;
}
@Override
protected void done() {
clearAllButton.setEnabled(true);
}
};
worker.execute();
}
});
Thread.sleep(1000);
System.exit(0);
} catch (InterruptedException ex) {
throw new RuntimeException(ex);
}
return null;
}
@Override
protected void done() {
logOutButton.setEnabled(true);
}
};
worker.execute();
}
@Override
protected void done() {
goBackButton.setEnabled(true);
}
};
worker.execute();
}
});
IV. CONCLUSION
1. Achieved goals
During the project, our team successfully achieved the goal of developing the mental
healthcare system. Firstly, we designed the database to adhere to the requirements of B.C.
Normal Form, ensuring efficient data storage and retrieval while eliminating data anomalies.
Secondly, we connected the front-end interface of the application to the back-end database
using a Java connection driver, establishing a seamless and secure connection between the
user interface and the database. Thirdly, we developed essential functions such as login,
account creation, and booking, implementing complex queries to manage various scenarios
effectively.
Additionally, we incorporated data evaluation techniques to give users more precise
predictions and recommendations for their mental health. Finally, we implemented robust
security measures in the database to safeguard users' data and prevent unauthorized access,
including protection against SQL injection attacks. Through completing these goals, our
project has delivered a reliable and user-friendly mental healthcare system that meets the
requirements of modern database management, security, and user experience.
2. Future work
The achievement of these goals opens exciting possibilities for the future evolution of this
project into a fully-fledged real-world application. Our team is committed to enhancing the
user experience by implementing more advanced features. We will introduce functionalities
that allow users to update their information according to their preferences, expand the role
of specialists to provide additional support and resources and improve the overall interface
of the application. Additionally, we aim to optimize the connection process, reducing user
waiting times. Furthermore, we plan to integrate a scheduling system into the app, enabling
users to conveniently manage their therapy appointments and receive guidance throughout
their treatment journey. We will focus on continuous improvement and delivering a
comprehensive and user-centric mental healthcare solution as we move forward.
3. Concluding thoughts
In conclusion, we are optimistic about the future development and improvement of our
mental healthcare service system. We aspire to make the system even more user-friendly
and practical, focusing on enhancing our users' overall experience. Throughout the project,
our team members have learned valuable lessons in collaboration, communication, and
V. REFERENCES
1NF, 2NF, 3NF and BCNF in Database Normalization | Studytonight [WWW Document], n.d.
URL https://www.studytonight.com/dbms/database-normalization.php (accessed
5.3.23).
Add a Salt with the SQL Server HASHBYTES Function [W.W.W. Document], n.d. URL
https://www.mssqltips.com/sqlservertip/3293/add-a-salt-with-the-sql-server-
hashbytes-function/ (accessed 5.3.23).
Depression [W.W.W. Document], n.d. URL https://www.who.int/news-room/fact-
sheets/detail/depression (accessed 2.27.23).
FREE Mental Health Tests, Quizzes, Self-Assessments, & Screening Tools [W.W.W. Document],
2022. URL https://www.psycom.net/quizzes (accessed 2.26.23).
How to check if ResultSet is empty in JDBC Java - Example Tutorial [W.W.W. Document], n.d.
URL https://javarevisited.blogspot.com/2016/10/how-to-check-if-resultset-is-empty-
in-Java-JDBC.html#axzz80XaDldWk (accessed 5.3.23).
Lesson: JDBC Basics (The JavaTM Tutorials > JDBC Database Access) [W.W.W. Document], n.d.
URL https://docs.oracle.com/javase/tutorial/jdbc/basics/index.html (accessed
5.3.23).
Ltd, R.G.S., n.d. Free Online SQL Formatter [W.W.W. Document]. URL https://www.red-
gate.com/website/sql-formatter (accessed 5.3.23).
SQL Tutorial [W.W.W. Document], n.d. URL https://www.w3schools.com/sql/ (accessed
5.3.23).
Suicide mortality rate (per 100,000 population) | Data [W.W.W. Document], n.d. URL
https://data.worldbank.org/indicator/SH.STA.SUIC.P5 (accessed 5.3.23).
THE END