Lewati ke konten utama

BAB 25. ENTITY RELATIONSHIP DIAGRAM (ERD)

Pendahuluan

ERD menggambarkan struktur data dan relasi antar entitas dalam database TemuBelajar yang dirancang dengan prinsip tenant-ready, 3NF, dan Laravel Eloquent Friendly.


ERD Konseptual

erDiagram

SCHOOLS ||--o{ CLASSROOMS : "has"
SCHOOLS ||--o{ USERS : "has"
SCHOOLS ||--o{ SUBJECTS : "has"

CLASSROOMS ||--o{ STUDENTS : "contains"

USERS ||--o| STUDENTS : "is a"
USERS ||--o| TEACHERS : "is a"

STUDENTS ||--o{ STUDENT_SKILLS : "has"
SKILLS ||--o{ STUDENT_SKILLS : "categorized in"

SUBJECTS ||--o{ TOPICS : "has"

STUDENTS ||--o{ REQUESTS : "creates"
SUBJECTS ||--o{ REQUESTS : "referenced in"
TOPICS ||--o{ REQUESTS : "referenced in"

REQUESTS ||--o{ BOOKINGS : "generates"

BOOKINGS ||--|| MEETINGS : "scheduled as"

MEETINGS ||--o{ MEETING_PARTICIPANTS : "has"
MEETINGS ||--o{ RATINGS : "receives"
MEETINGS ||--o{ MEETING_DOCUMENTS : "has"

STUDENTS ||--o{ SOCIAL_IMPACT_SCORES : "accumulates"
STUDENTS ||--o{ ACHIEVEMENTS : "earns"
STUDENTS ||--o{ NOTIFICATIONS : "receives"

Entitas Inti

EntitasFungsiRelasi Utama
schoolsTenant sekolah (multi-tenant)Semua entitas
usersAutentikasi semua penggunastudents, teachers
studentsData akademik siswarequests, skills
teachersData gurumeetings (monitoring)
classroomsRombel/kelasstudents
subjectsMaster mata pelajaranrequests, topics
topicsMaster materi per mapelrequests
skillsMaster kompetensistudent_skills
student_skillsPivot siswa ↔ skillstudents, skills
requestsPermintaan bantuanbookings
bookingsPenjadwalan tutormeetings
meetingsSesi pertemuan validratings, documents
meeting_participantsPeserta sesimeetings, students
ratingsPenilaian sesimeetings, users
social_impact_scoresAkumulasi SISstudents
achievementsBadge dan pencapaianstudents
notificationsRiwayat notifikasiusers

ERD Detail — Core Tables

erDiagram

USERS {
bigint id PK
bigint school_id FK
string name
string username
string password
enum role
boolean must_change_password
timestamp created_at
}

STUDENTS {
bigint id PK
bigint user_id FK
bigint classroom_id FK
string nisn
int level
int xp
decimal sis_score
}

REQUESTS {
bigint id PK
bigint student_id FK
bigint subject_id FK
bigint topic_id FK
string description
string preferred_location
decimal lat
decimal lng
datetime preferred_time
int duration_minutes
int tutor_count
enum status
}

BOOKINGS {
bigint id PK
bigint request_id FK
bigint tutor_id FK
enum status
datetime scheduled_at
decimal matching_score
}

MEETINGS {
bigint id PK
bigint booking_id FK
string qr_token
datetime check_in_at
datetime check_out_at
int duration_actual
text summary
enum completion_status
}

RATINGS {
bigint id PK
bigint meeting_id FK
bigint rater_id FK
bigint ratee_id FK
tinyint score
text comment
boolean is_solved
}

USERS ||--o| STUDENTS : "is"
STUDENTS ||--o{ REQUESTS : "creates"
REQUESTS ||--o{ BOOKINGS : "generates"
BOOKINGS ||--|| MEETINGS : "becomes"
MEETINGS ||--o{ RATINGS : "receives"