|
123 | 123 | "```\n", |
124 | 124 | "Enrollment table with composite key (student_id, course_id)\n", |
125 | 125 | "┌────────────┬───────────┬──────────────┬──────────────┬───────────────┐\n", |
126 | | - "│*student_id │*course_id │ student_name │ student_email│ course_title │\n", |
| 126 | + "│student_id* │course_id* │ student_name │ student_email│ course_title │\n", |
127 | 127 | "├────────────┼───────────┼──────────────┼──────────────┼───────────────┤\n", |
128 | 128 | "│ 1 │ CS101 │ Alice │ [email protected] │ Databases │\n", |
129 | 129 | "│ 1 │ CS102 │ Alice │ [email protected] │ Algorithms │ ← Redundant!\n", |
|
143 | 143 | "```\n", |
144 | 144 | "Student table: Course table: Enrollment table:\n", |
145 | 145 | "┌────────────┬──────┬───────┐ ┌───────────┬──────────┐ ┌────────────┬───────────┐\n", |
146 | | - "│*student_id │ name │ email │ │*course_id │ title │ │*student_id │*course_id │\n", |
| 146 | + "│student_id* │ name │ email │ │course_id* │ title │ │ student_id*│ course_id*│\n", |
147 | 147 | "├────────────┼──────┼───────┤ ├───────────┼──────────┤ ├────────────┼───────────┤\n", |
148 | 148 | "│ 1 │ Alice│ a@edu │ │ CS101 │ Databases│ │ 1 │ CS101 │\n", |
149 | 149 | "│ 2 │ Bob │ b@edu │ │ CS102 │ Algos │ │ 1 │ CS102 │\n", |
|
191 | 191 | "```\n", |
192 | 192 | "Student table: Department table:\n", |
193 | 193 | "┌────────────┬──────┬────────┐ ┌─────────────┬─────────┬──────────┐\n", |
194 | | - "│*student_id │ name │ dept │ │*dept_code │ name │ building │\n", |
| 194 | + "│student_id* │ name │ dept │ │ dept_code* │ name │ building │\n", |
195 | 195 | "├────────────┼──────┼────────┤ ├─────────────┼─────────┼──────────┤\n", |
196 | 196 | "│ 1 │ Alice│ CS │ │ CS │ Comp Sci│ Bldg A │\n", |
197 | 197 | "│ 2 │ Bob │ CS │ │ MATH │ Math │ Bldg B │\n", |
|
593 | 593 | "# The relationship is semantically broken, even though FK constraint is satisfied\n", |
594 | 594 | "\n", |
595 | 595 | "# DELETE makes this explicit:\n", |
596 | | - "(Mouse & {'mouse_id': 1}).delete() # ERROR: Experiment references this mouse!\n", |
597 | | - "# Forces you to delete and repopulate the dependent data\n", |
| 596 | + "(Mouse & {'mouse_id': 1}).delete() # Experiment references this mouse!\n", |
| 597 | + "# Cascades the delete to Experiment forces you to repopulate the dependent data\n", |
598 | 598 | "```" |
599 | 599 | ] |
600 | 600 | }, |
|
0 commit comments