This repository contains multiple SQL projects. Current subprojects:
deforestation_exploration/– Udacity deforestation analysis (see that folder’s README for details).social_news_aggregator/– Udiddit schema redesign, migration, and validation.
Key files:
social_news_aggregator/instructions.md– full project write-up, DDL/DML, rubric notes, optional DQL.social_news_aggregator/schema.sql– normalized 5-table schema with constraints and indexes.social_news_aggregator/migration.sql– data migration frombad_posts/bad_comments.social_news_aggregator/validation_queries.sql– helper queries for checks and sample DQL.social_news_aggregator/bad-db.sql– source data (bad schema).
docker context use desktop-linux # if using Docker Desktop on Windows/WSL
docker run --name udiddit-pg -e POSTGRES_PASSWORD=password -e POSTGRES_USER=udiddit -e POSTGRES_DB=udiddit -p 55432:5432 -d postgres:15# load source
docker cp social_news_aggregator/bad-db.sql udiddit-pg:/tmp/
docker exec -i udiddit-pg psql -U udiddit -d udiddit -f /tmp/bad-db.sql
# create normalized schema
docker cp social_news_aggregator/schema.sql udiddit-pg:/tmp/
docker exec -i udiddit-pg psql -U udiddit -d udiddit -f /tmp/schema.sql
# migrate data (truncate first only if re-running)
docker cp social_news_aggregator/migration.sql udiddit-pg:/tmp/
docker exec -i udiddit-pg psql -U udiddit -d udiddit -f /tmp/migration.sqldocker exec udiddit-pg psql -U udiddit -d udiddit -c "SELECT count(*) FROM users;"
docker exec udiddit-pg psql -U udiddit -d udiddit -c "SELECT count(*) FROM topics;"
docker exec udiddit-pg psql -U udiddit -d udiddit -c "SELECT count(*) FROM posts;"
docker exec udiddit-pg psql -U udiddit -d udiddit -c "SELECT count(*) FROM comments;"
docker exec udiddit-pg psql -U udiddit -d udiddit -c "SELECT count(*) FROM votes;"Expected counts with provided data: users=11077, topics=89, posts=50000, comments=100000, votes≈499710.
docker rm -f udiddit-pg