Analyzing Students' Mental Health in SQL
In this live code-along, you'll perform exploratory data analysis on a dataset around mental health of domestic and international students. You'll perform SQL querying to look at how social connectedness and cultural issues affect mental health. Finally, you'll visualize the results of your analysis using the Python Plotly package.
The Data
This survey was conducted in 2018 at an international Japanese university and the associated study was published in 2019. It was approved by several ethical and regulatory boards.
The study found that international students have a higher risk of mental health difficulties compared to the general population, and that social connectedness and acculturative stress are predictive of depression.
Social connectedness: measure of belonging to a social group or network.
Acculturative stress: stress associated with learning about and intergrating into a new culture.
See paper for more info, including data description.
Create database connection
- Databases > Connect Database > PostgreSQL
- Database connection name: Live Training Student MH
- Port:
5432
- Hostname:
workspacedemodb.datacamp.com
- Database:
students
- Username:
students_codealong
- Password:
students_codealong
Inspect the Data
Our data is in one table that includes all of the survey data. There are 50 fields and, according to the paper, 268 records. Each row is a student.
You can check the schema on the left.
- Check if the data has 268 records.
-- Count the number of records in the data
- Inspect the dataset to see what the fields look like.
-- Inspect the data and limit the output to 5 records
- How many international and domestic students are in the data set?
-- Count the number of international and domestic students
- Look into the 18 unassigned rows to understand what they could be.
-- Query the data to see all records where inter_dom is neither 'Dom' nor 'Inter'
- Where are the international students from?
-- See what Region international students are from
Understanding the scores
- Find the minimum, maximum, and average of each of the diagnostic tests (PHQ-9, SCS, ASISS). This information is in the paper, but it's good practice to look this up yourself during analysis.