What does this sample show?
The project examined diagnosis patterns, patient demographics, environmental variables and lesion characteristics in a supplied course dataset. The first task was to establish a dependable joined dataset before comparing groups.
This was an analytical capstone using PostgreSQL 18 and pgAdmin. It did not diagnose patients or train a prediction model. The source database is not distributed in the public repository.
Validate. Join. Summarise.
- Check the source tables. Compare patient, lesion and joined row counts; identify unmatched records and repeated identifiers.
- Create a temporary analytical view. Join the tables on
patient_idwhile preserving the original source tables. - Handle unavailable measurements. Treat zero-coded skin type and diameters as unavailable, pending confirmation of their original meaning.
- Describe the sample. Use aggregations, CTEs, window functions and filtered counts to examine diagnoses and group proportions.
- Prepare traceable metadata. Retain identifiers for audit, while specifying their exclusion from future model predictors.
See the core join used in the project
SELECT p.patient_id, l.lesion_id,
p.age, p.gender, l.diagnostic
FROM public.table1 AS p
JOIN public.table2 AS l
ON l.patient_id = p.patient_id;A shortened extract from the analytical workflow. The repository contains the complete script.
A clean join is only the beginning.
| Check | Result |
|---|---|
| Patient / lesion / joined rows | 1,088 / 1,088 / 1,088 |
| Unmatched lesion records | 0 |
| Repeated lesion ID values | 81, each appearing under two patients |
| Exact duplicate rows in the CSV | 0 |
| Unavailable skin type after zero conversion | 579 records (53.2%) |
| Unavailable diameter pairs after zero conversion | 581 records (53.4%) |
Repeated lesion IDs were not automatically deleted: the affected records belonged to different patients. The combined patient and lesion identifier was unique in the export, so it could support traceability while the original identifier convention remained unresolved.
The brief described 1,089 instances; the restored data and export contained 1,088. The reason for that difference was unconfirmed. All supplied records were retained.
Removing records solely because a lesion identifier repeats could discard distinct patient observations. Treating unavailable diameters as genuine zero measurements would distort lesion-size summaries.
Diagnosis patterns in 1,088 records.
ACK was the most frequent recorded diagnosis label. BCC, SCC and MEL together accounted for 346 records (31.8%). This combined category was used for descriptive comparisons, not as a newly validated diagnostic label.
View the diagnosis counts and percentages
| Label | Records | Share |
|---|---|---|
| ACK | 461 | 42.4% |
| BCC | 273 | 25.1% |
| NEV | 144 | 13.2% |
| SEK | 137 | 12.6% |
| SCC | 56 | 5.1% |
| MEL | 17 | 1.6% |
Age groups showed different proportions.
| Age band | All records | BCC/SCC/MEL | Within-band share |
|---|---|---|---|
| Under 30 | 57 | 2 | 3.5% |
| 30–49 | 221 | 49 | 22.2% |
| 50–69 | 513 | 174 | 33.9% |
| 70+ | 297 | 121 | 40.7% |
The proportion increased across the age bands in this dataset. These figures describe the supplied records; they do not estimate population incidence or an individual’s risk.
Useful patterns. Clear limits.
Measurement completeness differed substantially by diagnosis. Usable diameter pairs ranged from 14 of 137 SEK records to all 17 MEL records. Comparisons of lesion size could therefore reflect which records were measured as well as differences between groups.
The analysis was descriptive and unadjusted. Sampling, recruitment and the original label provenance were not established. Observed differences by age, symptoms or exposure do not establish causation or diagnostic accuracy. The other diagnosis labels should not all be grouped as “benign”.
Preparing a metadata export also does not make it ready for clinical modelling. Identifiers, biopsy status and related target labels require careful handling to avoid leakage.
Improve the evidence before extending the analysis.
- Clarify the record-count discrepancy and lesion identifier convention with the provider.
- Confirm the meaning of zero-coded values and investigate diagnosis-dependent missingness.
- Verify label provenance before supervised modelling.
- Use adjusted analysis and suitable independent data to investigate associations further.
What this project demonstrates
SQL joins and reusable views, explicit denominators, data-quality checks and cautious interpretation of health data. The central lesson is that reliable analysis depends on understanding the records before interpreting their patterns.
Project evidence
The findings above are drawn from the completed SQL capstone report and analytical script. The repository includes the report, queries, project context and instructions for running the supplied database.