Skip to content

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, and that social connectedness (belonging to a social group) and acculturative stress (stress associated with joining a new culture) are predictive of depression.

Explore the students data using PostgreSQL to find out if you would come to a similar conclusion for international students and see if the length of stay is a contributing factor.

Here is a data description of the columns you may find helpful.

Field NameDescription
inter_domTypes of students (international or domestic)
japanese_cateJapanese language proficiency
english_cateEnglish language proficiency
academicCurrent academic level (undergraduate or graduate)
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)
Spinner
DataFrameas
df
variable
---Explore how the length of stay impacts the mental health of international students
SELECT stay, 
COUNT(inter_dom) AS count_int, 
ROUND(AVG(todep),2) AS average_phq, 
ROUND(AVG(tosc),2) AS average_scs, 
ROUND(AVG(toas),2) AS average_as
FROM students
WHERE inter_dom = 'Inter'
GROUP BY stay
ORDER BY stay DESC;
Spinner
DataFrameas
df1
variable
SELECT stay, 
COUNT(inter_dom) AS count_int, 
ROUND(AVG(todep),2) AS average_phq, 
ROUND(AVG(tosc),2) AS average_scs, 
ROUND(AVG(toas),2) AS average_as
FROM students
WHERE inter_dom = 'Inter'
GROUP BY stay
HAVING COUNT(inter_dom) > 6
ORDER BY stay DESC;
Spinner
DataFrameas
df2
variable
SELECT *
FROM students
WHERE inter_dom='Dom';

SELECT stay,
COUNT(inter_dom) AS count_int,
ROUND(AVG(todep),2) AS average_phq, 
ROUND(AVG(tosc),2) AS average_scs, 
ROUND(AVG(toas),2) AS average_as
FROM students
WHERE gender = 'Male'
GROUP BY stay
ORDER BY stay DESC;

SELECT stay,
COUNT(inter_dom) AS count_int,
ROUND(AVG(todep),2) AS average_phq, 
ROUND(AVG(tosc),2) AS average_scs, 
ROUND(AVG(toas),2) AS average_as
FROM students
WHERE gender = 'Female'
GROUP BY stay
ORDER BY stay DESC;

with gen_F AS (SELECT stay,
COUNT(inter_dom) AS count_int,
ROUND(AVG(todep),2) AS average_phq, 
ROUND(AVG(tosc),2) AS average_scs, 
ROUND(AVG(toas),2) AS average_as
FROM students
WHERE gender = 'Female'),
	gen_M AS (SELECT stay,
COUNT(inter_dom) AS count_int,
ROUND(AVG(todep),2) AS average_phq, 
ROUND(AVG(tosc),2) AS average_scs, 
ROUND(AVG(toas),2) AS average_as
FROM students
WHERE gender = 'Male')
SELECT stay, gen_F.count_in, gen_M.count_in
FROM students
WHERE academic = 'grad' 
GROUP BY students.stay
ORDER BY students.stay DESC;

1 hidden cell
Spinner
DataFrameas
df3
variable
SELECT
corr(todep, tosc) AS correlation_depression_social_connectedness,
corr(todep, toas)AS correlation_depression_acculturative_stress
FROM students;
Spinner
DataFrameas
df4
variable
-- Regression
SELECT regr_slope(todep, stay) AS slope,
       regr_intercept(todep, stay) AS intercept,
       regr_r2(todep, stay) AS r_squared
FROM students;
Spinner
DataFrameas
df5
variable
SELECT avg(todep) AS mean_depression,
       stddev(todep) AS stddev_depression,
       min(todep) AS min_depression,
       max(todep) AS max_depression,
       avg(tosc) AS mean_social_connectedness,
       stddev(tosc) AS stddev_social_connectedness,
       min(tosc) AS min_social_connectedness,
       max(tosc) AS max_social_connectedness,
       avg(toas) AS mean_acculturative_stress,
       stddev(toas) AS stddev_acculturative_stress,
       min(toas) AS min_acculturative_stress,
       max(toas) AS max_acculturative_stress
FROM students;
# The % operator in Python is the modulus operator.
# It returns the remainder of the division of the left-hand operand by the right-hand operand.
# In this case, 3 divided by 7 is 0 with a remainder of 3.
# Therefore, 3 % 7 will return 3.

result = 3 % 7
result