Project 14: Analyzing Student’s Mental Health using SQL

Brain , concept idea art of thinking, surreal portrait painting, conceptual artwork, 3d illustration

Does going to university in a different country affect your mental health? A Japanese international university surveyed its students in 2018 and published a study the following year that was approved by several ethical and regulatory boards.

The study found that international students have a higher risk of mental health difficulties than the general population. Explore the students data using PostgreSQL to determine if this is true and see if the length of stay is a contributing factor.

Here is a data description of the fields you may find helpful. The full dataset is in one table with 50 fields and, according to the survey, 268 records. Each row is a student.

Field NameDescription
inter_domTypes of students
japanese_cateJapanese language proficiency
english_cateEnglish language proficiency
academicCurrent academic level
ageCurrent age of student
stayCurrent length of stay in years
todepTotal score of depression (PHQ-9 test)
toscTotal score of social connectedness (SCS test)
toasTotal score of Acculturative Stress (ASISS test)

In [13]:

-- Exploring Students Data 
SELECT *
FROM students;

Out[13]:

inter_domregiongenderacademicageage_catestaystay_catejapanesejapanese_cateenglishenglish_cateintimatereligionsuicidedepdeptypetodepdepsevtoscapdahomeaphafearacsaguiltamiscelltoaspartnerfriendsparentsrelativeprofessphonedoctorrelialoneothersinternetpartner_bifriends_biparents_birelative_biprofessional_biphone_bidoctor_bireligion_bialone_biothers_biinternet_bi
0InterSEAMaleGrad24.04.05.0Long3.0Average5.0HighYesNoNoNo0.0Min34.023.09.011.08.011.02.027.091.05.05.06.03.02.01.04.01.03.04.0NaNYesYesYesNoNoNoNoNoNoNoNo
1InterSEAMaleGrad28.05.01.0Short4.0High4.0HighNoNoNoNo2.0Min48.08.07.05.04.03.02.010.039.07.07.07.04.04.04.04.01.01.01.0NaNYesYesYesNoNoNoNoNoNoNoNo
2InterSEAMaleGrad25.04.06.0Long4.0High4.0HighYesYesNoNoNo2.0Min41.013.04.07.06.04.03.014.051.03.03.03.01.01.02.01.01.01.01.0NaNNoNoNoNoNoNoNoNoNoNoNo
3InterEAFemaleGrad29.05.01.0Short2.0Low3.0AverageNoNoNoNoNo3.0Min37.016.010.010.08.06.04.021.075.05.05.05.05.05.02.02.02.04.04.0NaNYesYesYesYesYesNoNoNoNoNoNo
4InterEAFemaleGrad28.05.01.0Short1.0Low3.0AverageYesNoNoNoNo3.0Min37.015.012.05.08.07.04.031.082.05.05.05.02.05.02.05.05.04.04.0NaNYesYesYesNoYesNoYesYesNoNoNo
281NaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaN128140
282NaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaN137131
283NaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaN66202
284NaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaN61207
285NaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaN30238

286 rows × 50 columns

In [30]:

-- All records count by student type
SELECT inter_dom, COUNT(*) FROM students
WHERE stay IS NOT NULL
GROUP BY inter_dom;

Out[30]:

inter_domcount
0Inter201
1Dom67

In [28]:

-- Filter the data to see how it differs between the student types
SELECT stay, ROUND(AVG(todep),2) AS average_phq, ROUND(AVG(tosc),2) AS average_scs, ROUND(AVG(toas),2) AS average_AS FROM students
WHERE stay IS NOT NULL AND inter_dom = 'Inter'
GROUP BY stay
ORDER BY stay DESC;

Out[28]:

stayaverage_phqaverage_scsaverage_as
01013.0032.0050.00
1810.0044.0065.00
274.0048.0045.00
366.0038.0058.67
450.0034.0091.00
548.5733.9387.71
639.0937.1378.00
728.2837.0877.67
817.4838.1172.80

2 responses to “Project 14: Analyzing Student’s Mental Health using SQL”

  1. BluntPathway Avatar

    I just found your blog, I am looking forward to you next posts, I came across it because I have been learning python and data anlysis tools in general. Keep blogging.

    Like

    1. Ram Rallabandi Avatar

      Glad to know that you are enjoying the posts. Will do my best to post content regularly

      Liked by 1 person

Leave a reply to Ram Rallabandi Cancel reply

Hello !!! I’m Ram Rallabandi

an AI consultant and data scientist with a proven track record of delivering high-impact AI solutions. My mission is simple: transform complex AI strategies into measurable business outcomes.

→ What I Do:
I specialize in leading the end-to-end lifecycle of AI products, from ideation to technical development to successful market launch. My expertise lies in bridging the gap between technical innovation and business value to ensure that every AI initiative aligns with organizational goals.

→ How I Add Value:
☑ Drive the adoption of responsible AI practices to future-proof businesses
☑ Build scalable, high-quality AI solutions that directly address customer needs
☑ Streamline processes to connect AI demand with delivery teams efficiently
☑ Analyze market trends to position data-driven solutions for maximum impact

Why It Works:
With a strong foundation in AI, machine learning, and data science, I provide strategic insights that empower organizations to leverage cutting-edge technologies for growth. I collaborate with technical and business teams to:
↳ Define product roadmaps
↳ Manage budgets, timelines, and scopes
↳ Foster cross-functional alignment for AI-driven innovation

My Passion:
I thrive on leading AI storytelling for executive leadership and fostering collaboration across diverse teams. With deep experience in Fintech and Payments, I’m dedicated to unlocking AI’s potential to deliver business transformation and create widely adopted solutions.

Let’s connect to explore how AI can transform your business.