SQL noob trying to make schema Drizzle ORM

My confusion comes from how to structure the database so that I don't save duplicate data and when I update I don't leave the data (like promoting agent to lead)

I have watched a lot of tutorials but I just can't seem to get the mental model on how to do this or even what would be the best way to do this.

where when a user logs in he is assigned a role
enum UserRole {
  SUPER = "super",
  ADMIN = "admin",
  HOD = "hod",
  MANAGER = "manager",
  LEAD = "lead",
  AGENT = "agent",
  USER = "user",
}


now those roles define what actions the user can perform.
  • agent has one lead
  • lead has one manager
  • lead is in charge of one brand
  • manager has one hod
  • manager is in charge of multiple brands
The code is here
https://stackoverflow.com/questions/77560683/sql-noob-trying-to-make-schema-drizzle-orm
Stack Overflow
My confusion comes from how to structure the database so that I don't save duplicate data and when I update I don't leave the data (like promoting agent to lead)
I am designing my db structure for ...
Was this page helpful?