Sleep Health and Lifestyle
This synthetic dataset contains sleep and cardiovascular metrics as well as lifestyle factors of close to 400 fictive persons.
The workspace is set up with one CSV file, data.csv, with the following columns:
Person IDGenderAgeOccupationSleep Duration: Average number of hours of sleep per dayQuality of Sleep: A subjective rating on a 1-10 scalePhysical Activity Level: Average number of minutes the person engages in physical activity dailyStress Level: A subjective rating on a 1-10 scaleBMI CategoryBlood Pressure: Indicated as systolic pressure over diastolic pressureHeart Rate: In beats per minuteDaily StepsSleep Disorder: One ofNone,InsomniaorSleep Apnea
1. Which factors could contribute to a sleep disorder?
The data indicates that individuals with sleep disorders are more likely to have a BMI that falls into the overweight or obese category.
SELECT occupation, gender,
"Sleep Disorder",
"Sleep Duration",
"Daily Steps",
"Physical Activity Level",
"Stress Level",
"BMI Category",
FROM 'data.csv'
WHERE "Sleep disorder" IS NOT NULL;2. Does an increased physical activity level result in a better quality of sleep? The data shows that the majority of people with lower physical activity levels tend to experience poor quality of sleep.
SELECT gender,
"Quality of Sleep",
"Daily Steps",
"Physical Activity Level",
FROM 'data.csv'
ORDER BY gender, "Daily Steps", "Physical Activity Level" DESC;
3. Does stress level impact the quality of sleep?
Yes. The data shows that when stress level increased, the quality of sleep then decreased.
SELECT Gender, "Quality of Sleep", "Stress Level", "Sleep Disorder"
FROM 'data.csv'
WHERE "Sleep Disorder" ='None'
GROUP BY Gender, "Quality of Sleep", "Stress Level", "Sleep Disorder"
ORDER BY "Stress Level" DESC;4. Does increase of body weight result in the quality of sleep?
As body weight increases, the average quality of sleep tends to decrease slightly. While the drop isn’t huge, there’s a small downward trend: people with higher body weight generally report lower sleep quality, especially when they have a sleep disorder like insomnia or sleep apnea.
SELECT
"BMI Category",
"Sleep Disorder",
ROUND(AVG("Quality of Sleep"), 0) AS "Average Quality of Sleep"
FROM 'data.csv'
WHERE "Sleep Disorder" IS NOT NULL
GROUP BY "BMI Category", "Sleep Disorder"
ORDER BY "Average Quality of Sleep" DESC;