Skip to content

Remove hardcoded IDs from SQL examples in databases week1#297

Open
urbanogilson wants to merge 1 commit intoHackYourFuture-CPH:mainfrom
urbanogilson:main
Open

Remove hardcoded IDs from SQL examples in databases week1#297
urbanogilson wants to merge 1 commit intoHackYourFuture-CPH:mainfrom
urbanogilson:main

Conversation

@urbanogilson
Copy link
Copy Markdown
Member

Why

Hardcoded IDs teach students a fragile pattern that breaks when rows are inserted in a different order. Using subqueries on stable natural keys is the correct habit to build from the start.

Summary

  • Replace hardcoded user_id/task_id integers in user_task inserts with subqueries on user.email and task.title
  • Replace hardcoded status_id integers with subqueries on status.name
  • Add PRAGMA foreign_keys = ON to tasks-solution.sql and session-plan.md to fix silent ON DELETE CASCADE failures in SQLite
  • Add inline notes explaining the DEFAULT 1 and PRAGMA SQLite limitations

@urbanogilson urbanogilson self-assigned this Apr 19, 2026
@urbanogilson urbanogilson added the bug Something isn't working label Apr 19, 2026
@urbanogilson urbanogilson requested a review from a team as a code owner April 19, 2026 10:40
@urbanogilson urbanogilson added documentation Improvements or additions to documentation backend Issues related to the backend course labels Apr 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend Issues related to the backend course bug Something isn't working documentation Improvements or additions to documentation

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

1 participant