academia/docs/architecture/diagrams/05-entity-relationship.puml

96 lines
2.0 KiB
Plaintext
Raw Normal View History

@startuml entity-relationship
!theme plain
skinparam linetype ortho
skinparam classBackgroundColor #F8F9FA
skinparam classBorderColor #495057
title Sistema de Registro de Estudiantes - Diagrama Entidad-Relación
entity "Users" as users {
* **Id** : int <<PK>>
--
* Username : nvarchar(50) <<unique>>
* PasswordHash : nvarchar(255)
* RecoveryCodeHash : nvarchar(255)
* Role : nvarchar(20)
StudentId : int <<FK, nullable>>
* CreatedAt : datetime2
LastLoginAt : datetime2
}
entity "Students" as students {
* **Id** : int <<PK>>
--
* Name : nvarchar(100)
* Email : nvarchar(255) <<unique>>
ActivationCodeHash : nvarchar(255)
ActivationExpiresAt : datetime2
* CreatedAt : datetime2
UpdatedAt : datetime2
}
entity "Professors" as professors {
* **Id** : int <<PK>>
--
* Name : nvarchar(100)
}
entity "Subjects" as subjects {
* **Id** : int <<PK>>
--
* Name : nvarchar(100)
* Credits : int {= 3}
* **ProfessorId** : int <<FK>>
}
entity "Enrollments" as enrollments {
* **Id** : int <<PK>>
--
* **StudentId** : int <<FK>>
* **SubjectId** : int <<FK>>
* EnrolledAt : datetime2
--
<<unique>> (StudentId, SubjectId)
}
' Relaciones
users ||--o| students : "vinculado a"
students ||--o{ enrollments : "tiene"
subjects ||--o{ enrollments : "inscripciones"
professors ||--|| subjects : "imparte 2"
note right of users
<b>Autenticación:</b>
- Password: PBKDF2-SHA256
- Roles: Admin, Student
- Recovery code para reset
end note
note right of students
<b>Restricciones:</b>
- Email único
- Máximo 3 enrollments
- Activación requerida
end note
note right of subjects
<b>Datos iniciales:</b>
10 materias
3 créditos cada una
end note
note right of professors
<b>Datos iniciales:</b>
5 profesores
2 materias cada uno
end note
note bottom of enrollments
<b>Reglas de negocio:</b>
- (StudentId, SubjectId) único
- Estudiante no puede tener
2 materias del mismo profesor
end note
@enduml