I am a computer science student from Germany and I work at a small IT startup. I have been assigned a project with challenging requirements. The customer wants a human resources management tool that includes a work planner, holiday planner, payroll administration, and more. The challenge is that the customer wants to track every property change throughout the entire system, and each property needs a "validFrom" property. Additionally, some properties require a "validUntil" property as well.
The ultimate goal is to be able to view the system state for a given point in time and also to be able to supplement changes or add future changes. This means that we need to implement a system that keeps track of every property change and allows us to access the system state at any given point in time.
The project is a winforms application with c# and a sqlite database with optional entity framework layer.
A basic example: We have users in the system:
class User
{
public int Id { get; set; }
public string Name { get; set; }
public string Password { get; set; }
public ICollection<Permission> Permissions { get; set; }
}
To be able to track changes for "Name", "Password", and "Permissions", we have a separate database table for each of them:
class UserNameRecord
{
public int Id { get; set; }
public int UserId { get; set; }
public string Name { get; set; }
public DateTime ValidFrom { get; set; }
public DateTime CreatedAt { get; set; }
public DateTime DeletedAt { get; set; }
}
and for collection something like:
class UserPermissionsRecord
{
public int Id { get; set; }
public int UserId { get; set; }
public CollectionAction Action { get; set; } // added or removed
public Permission Permission { get; set; }
public DateTime ValidFrom { get; set; }
public DateTime CreatedAt { get; set; }
public DateTime DeletedAt { get; set; }
}
The problem is that we have over 200 tables, and the number keeps growing. Fetching data for the views is quite complicated and takes a noticeable amount of time. Additionally, validating constraints is a nightmare.
I want to address this problem because it is causing significant slowdowns for me, and I need some advice on how to do it better.