@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 "Students" as students {
    * **Id** : int <<PK>>
    --
    * Name : nvarchar(100)
    * Email : nvarchar(255) <<unique>>
    * 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
students ||--o{ enrollments : "tiene"
subjects ||--o{ enrollments : "inscripciones"
professors ||--|| subjects : "imparte 2"

note right of students
  <b>Restricciones:</b>
  - Email único
  - Máximo 3 enrollments
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
