Changeset c42181c for iknow-api


Ignore:
Timestamp:
09/16/26 14:48:55 (7 days ago)
Author:
Stefan-Saveski <stefansaveski19@…>
Branches:
master
Children:
8ee90bd
Parents:
ea40556
Message:

Refactor payment model to remove redundant user_id, addressing BCNF violation in Phase 5 normalization

Location:
iknow-api
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • iknow-api/Data/AppDbContext.cs

    rea40556 rc42181c  
    290290                e.HasKey(p => p.Id);
    291291                e.Property(p => p.Id).HasColumnName("id");
    292                 e.Property(p => p.UserId).HasColumnName("user_id");
    293292                e.Property(p => p.EnrollmentInfoId).HasColumnName("enrollment_id");
    294293                e.Property(p => p.Amount).HasColumnName("amount");
    295294
    296                 e.HasOne(p => p.User)
    297                  .WithMany(u => u.Payments)
    298                  .HasForeignKey(p => p.UserId)
    299                  .OnDelete(DeleteBehavior.Cascade);
    300 
     295                // No user_id: the student comes from the enrolment. Removing it
     296                // was the BCNF fix from Phase 5 (enrolled_id -> user_id).
    301297                e.HasOne(p => p.EnrolledSemesters)
    302298                 .WithMany(es => es.Users)
  • iknow-api/Models/Payment.cs

    rea40556 rc42181c  
    1 using System.ComponentModel.DataAnnotations.Schema;
    2 
    31namespace iknow_api.Models
    42{
     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>
    58    public class Payment
    69    {
    710        public int Id { get; set; }
    811
    9         public int UserId { get; set; }
    10         public User? User { get; set; }
    1112        public int EnrollmentInfoId { get; set; }
    1213        public int Amount { get; set; }
    1314        public EnrolledSemesters? EnrolledSemesters { get; set; }
    14 
    1515    }
    1616}
  • iknow-api/Models/User.cs

    rea40556 rc42181c  
    2828        public ICollection<UserDocuments>? Documents { get; set; }
    2929
    30         // Named for the relationship it carries: Users 1 --pays-- N Payment.
    31         public ICollection<Payment>? Payments { get; set; }
    32 
    3330        // Users 1 --submits-- N EnrolledSemesters
    3431        public ICollection<EnrolledSemesters>? Enrolments { get; set; }
Note: See TracChangeset for help on using the changeset viewer.