Changes in / [1a9c843:a12988e]
- Files:
-
- 1 deleted
- 7 edited
-
iknow-api/Data/AppDbContext.cs (modified) (1 diff)
-
iknow-api/Models/Payment.cs (modified) (1 diff)
-
iknow-api/Models/User.cs (modified) (1 diff)
-
sql/advanced.sql (deleted)
-
sql/data_load.sql (modified) (1 diff)
-
sql/iknow.dbml (modified) (2 diffs)
-
sql/schema.md (modified) (3 diffs)
-
sql/schema_creation.sql (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
iknow-api/Data/AppDbContext.cs
r1a9c843 ra12988e 290 290 e.HasKey(p => p.Id); 291 291 e.Property(p => p.Id).HasColumnName("id"); 292 e.Property(p => p.UserId).HasColumnName("user_id"); 292 293 e.Property(p => p.EnrollmentInfoId).HasColumnName("enrollment_id"); 293 294 e.Property(p => p.Amount).HasColumnName("amount"); 294 295 295 // No user_id: the student comes from the enrolment. Removing it 296 // was the BCNF fix from Phase 5 (enrolled_id -> user_id). 296 e.HasOne(p => p.User) 297 .WithMany(u => u.Payments) 298 .HasForeignKey(p => p.UserId) 299 .OnDelete(DeleteBehavior.Cascade); 300 297 301 e.HasOne(p => p.EnrolledSemesters) 298 302 .WithMany(es => es.Users) -
iknow-api/Models/Payment.cs
r1a9c843 ra12988e 1 using System.ComponentModel.DataAnnotations.Schema; 2 1 3 namespace iknow_api.Models 2 4 { 3 /// <summary>4 /// The student is reached through the enrolment: enrolled_id -> user_id.5 /// A user_id here would be redundant and could contradict the enrolment,6 /// which is the BCNF violation found during normalization (Phase 5).7 /// </summary>8 5 public class Payment 9 6 { 10 7 public int Id { get; set; } 11 8 9 public int UserId { get; set; } 10 public User? User { get; set; } 12 11 public int EnrollmentInfoId { get; set; } 13 12 public int Amount { get; set; } 14 13 public EnrolledSemesters? EnrolledSemesters { get; set; } 14 15 15 } 16 16 } -
iknow-api/Models/User.cs
r1a9c843 ra12988e 28 28 public ICollection<UserDocuments>? Documents { get; set; } 29 29 30 // Named for the relationship it carries: Users 1 --pays-- N Payment. 31 public ICollection<Payment>? Payments { get; set; } 32 30 33 // Users 1 --submits-- N EnrolledSemesters 31 34 public ICollection<EnrolledSemesters>? Enrolments { get; set; } -
sql/data_load.sql
r1a9c843 ra12988e 115 115 (3, 1, 'tok_old789_stefan', '2026-01-01 00:00:00', FALSE); 116 116 117 INSERT INTO payment (id, enrollment_id, amount) VALUES118 (1, 1, 200),119 (2, 2, 200),120 (3, 3, 400),121 (4, 4, 200);117 INSERT INTO payment (id, user_id, enrollment_id, amount) VALUES 118 (1, 1, 1, 200), 119 (2, 1, 2, 200), 120 (3, 2, 3, 400), 121 (4, 3, 4, 200); 122 122 123 123 INSERT INTO major_subjects (major_id, subject_id, mandatory_semester) VALUES -
sql/iknow.dbml
r1a9c843 ra12988e 150 150 Table project.payment { 151 151 id integer [pk, increment] 152 user_id integer [not null] 152 153 enrollment_id integer [not null] 153 154 amount integer [not null] … … 187 188 Ref: project.contact.user_id - project.users.id // has_contact (1:1) 188 189 Ref: project.token.user_id > project.users.id // has_token 190 Ref: project.payment.user_id > project.users.id // pays 189 191 Ref: project.payment.enrollment_id > project.enrolled_semesters.id // for_enrollment 190 192 Ref: project.enrolled_semesters.user_id > project.users.id // submits -
sql/schema.md
r1a9c843 ra12988e 111 111 payment { 112 112 integer id PK 113 integer user_id FK 113 114 integer enrollment_id FK 114 115 integer amount … … 135 136 users ||--o| contact : has_contact 136 137 users ||--o{ token : has_token 138 users ||--o{ payment : pays 137 139 users ||--o{ enrolled_semesters : submits 138 140 users ||--o{ user_documents : owns … … 182 184 they differ. 183 185 - `professour_subjects` keeps the spelling used by the table in `schema_creation.sql`. 184 - `payment` has no `user_id`: the student is reached through `enrollment_id`.185 Storing it twice violated BCNF (`enrolled_id -> user_id`) and allowed a186 payment to contradict the enrolment it refers to. Removed in Phase 5. -
sql/schema_creation.sql
r1a9c843 ra12988e 115 115 CREATE TABLE payment ( 116 116 id INTEGER PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY, 117 user_id INTEGER NOT NULL REFERENCES users (id), 117 118 enrollment_id INTEGER NOT NULL REFERENCES enrolled_semesters (id), 118 119 amount INTEGER NOT NULL
Note:
See TracChangeset
for help on using the changeset viewer.
