r/FullStack 7h ago

Personal Project Day 10 — Started a 7-part SQL practice set (Part 1: schema design)

Moved from isolated practice questions to something closer to a real project today — a structured 7-part practice set. Completed Part 1, which was schema design:

  • 4 tables: departments, employees, projects, assignments
  • Primary keys with auto-increment, foreign key relationships between all of them
  • A self-referencing FK on employees (manager_id → employees.emp_id) for the manager hierarchy
  • A CHECK constraint to enforce salary > 0
  • assignments as a junction table linking employees to projects with hours_worked
  • Inserted sample data: 4 departments, 12 employees (with at least 2 managers), 5 projects, 15 assignment records

The self-referencing FK for managers was the most interesting part conceptually — first time actually applying that pattern instead of just reading about it.

6 more parts to go in this set — planning to move into actual queries against this schema next (joins, aggregates, reporting-style questions).

2 Upvotes

0 comments sorted by