Data Dictionary
Overview
This document describes the complete data structure used in TalaTalkโs Firebase Firestore database. All data is stored as NoSQL documents organized in collections with proper security rules and relationships.
User Management
users Collection
Purpose: Stores authentication and profile data for all users (teachers and parents)
User Fields
| Field | Type | Required | Description |
|---|---|---|---|
uid | string | โ | Firebase Auth UID (document ID) |
email | string | โ | Userโs email address |
fullName | string | โ | Userโs full name |
role | string | โ | User role: โteacherโ or โparentโ |
phoneNumber | string | โ | Userโs phone number |
profilePictureUrl | string | โ | URL to profile picture |
createdAt | Timestamp | โ | Account creation time |
updatedAt | Timestamp | โ | Last profile update |
verified | boolean | โ | Whether user is verified |
classroomCode | string | โ | Classroom code for teachers |
allow read, write: if request.auth != null && request.auth.uid == userId
Classroom Management
classrooms Collection
Purpose: Stores classroom information created by teachers
Classroom Fields
| Field | Type | Required | Description |
|---|---|---|---|
id | string | โ | Document ID (auto-generated) |
school_id | string | โ | School identifier |
classroom_code | string | โ | Unique classroom code |
room_number | string | โ | Physical room number |
grade_level | string | โ | Grade level (e.g., โGrade 1โ) |
section | string | โ | Section (e.g., โAโ, โBโ) |
capacity | number | โ | Maximum students allowed |
teacher_id | string | โ | Teacherโs UID |
subject_area | string | โ | Subject taught |
academic_year | string | โ | Academic year |
created_at | Timestamp | โ | Creation timestamp |
qr_code_data | string | โ | QR code for easy access |
classroom_parents Collection
Purpose: Links parents to classrooms for access control
Classroom Parents Fields
| Field | Type | Required | Description |
|---|---|---|---|
parent_id | string | โ | Parentโs UID |
classroom_id | string | โ | Classroom ID |
joined_at | Timestamp | โ | When parent joined |
Student Management
students Collection
Purpose: Stores student information
Student Fields
| Field | Type | Required | Description |
|---|---|---|---|
id | string | โ | Document ID (auto-generated) |
student_number | string | โ | Unique student number |
first_name | string | โ | Studentโs first name |
last_name | string | โ | Studentโs last name |
date_of_birth | string/Date | โ | Date of birth |
gender | string | โ | Gender: โmaleโ, โfemaleโ, โotherโ |
grade_level | string | โ | Current grade level |
address | string | โ | Home address |
emergency_contact | string | โ | Emergency contact details |
enrollment_date | Timestamp | โ | When enrolled |
status | string | โ | Status: โactiveโ, โinactiveโ, โgraduatedโ |
parent_ids | array | โ | Array of parent UIDs |
student_classrooms Collection
Purpose: Tracks student enrollment in classrooms
Student Classrooms Fields
| Field | Type | Required | Description |
|---|---|---|---|
student_id | string | โ | Studentโs document ID |
classroom_id | string | โ | Classroom ID |
enrolled_at | Timestamp | โ | Enrollment timestamp |
status | string | โ | Status: โactiveโ, โdroppedโ, โcompletedโ |
final_grade | number | โ | Final grade if completed |
parent_students Collection
Purpose: Links parents to their children
Parent Students Fields
| Field | Type | Required | Description |
|---|---|---|---|
parent_id | string | โ | Parentโs UID |
student_id | string | โ | Studentโs document ID |
relationship_type | string | โ | โfatherโ, โmotherโ, โguardianโ, โsiblingโ |
is_primary_contact | boolean | โ | Whether primary contact |
created_at | Timestamp | โ | Relationship creation time |
Communication System
messages Collection
Purpose: Stores direct messages between users
Message Fields
| Field | Type | Required | Description |
|---|---|---|---|
id | string | โ | Document ID (auto-generated) |
sender_id | string | โ | Senderโs UID |
receiver_id | string | โ | Receiverโs UID |
classroom_id | string | โ | Associated classroom |
subject | string | โ | Message subject |
message_content | string | โ | Message text content |
sent_at | Timestamp | โ | When message was sent |
read_at | Timestamp | โ | When message was read |
priority_level | string | โ | โlowโ, โmediumโ, โhighโ, โurgentโ |
message_type | string | โ | โdirectโ, โannouncementโ, โalertโ |
is_read | boolean | โ | Whether message has been read |
parent_message_id | string | โ | For reply threading |
attachment_url | string | โ | URL to attached file |
conversation_id | string | โ | For conversation grouping |
conversations Collection
Purpose: Groups messages into conversations for better organization
Conversation Fields
| Field | Type | Required | Description |
|---|---|---|---|
id | string | โ | Document ID (auto-generated) |
participants | array | โ | Array of user UIDs (always 2 for direct) |
conversation_type | string | โ | โdirectโ |
last_message | string | โ | Last message content |
last_message_at | Timestamp | โ | When last message was sent |
last_message_sender | string | โ | UID of last message sender |
created_at | Timestamp | โ | Conversation creation time |
updated_at | Timestamp | โ | Last update time |
unread_count | object | โ | {userId: count} for each participant |
announcements Collection
Purpose: Stores announcements made by teachers
Announcement Fields
| Field | Type | Required | Description |
|---|---|---|---|
id | string | โ | Document ID (auto-generated) |
teacher_id | string | โ | Teacherโs UID |
classroom_id | string | โ | Associated classroom |
title | string | โ | Announcement title |
content | string | โ | Announcement content |
posted_at | Timestamp | โ | When posted |
expires_at | Timestamp | โ | When announcement expires |
priority_level | string | โ | โlowโ, โmediumโ, โhighโ, โurgentโ |
announcement_type | string | โ | โgeneralโ, โacademicโ, โeventโ, โemergencyโ |
is_active | boolean | โ | Whether currently active |
attachment_url | string | โ | URL to attached file |
attachments | array | โ | Array of AnnouncementAttachment objects |
Document Management
documents Collection
Purpose: Stores metadata for uploaded documents
Document Fields
| Field | Type | Required | Description |
|---|---|---|---|
id | string | โ | Document ID (auto-generated) |
teacher_id | string | โ | Teacher who uploaded |
classroom_id | string | โ | Associated classroom |
file_name | string | โ | Original filename |
file_url | string | โ | Firebase Storage URL |
file_size | number | โ | File size in bytes |
file_type | string | โ | MIME type |
uploaded_by | string | โ | Teacherโs name |
uploaded_at | Timestamp | โ | Upload timestamp |
Event Management
events Collection
Purpose: Stores calendar events and activities
Event Fields
| Field | Type | Required | Description |
|---|---|---|---|
id | string | โ | Document ID (auto-generated) |
created_by | string | โ | Creatorโs UID |
classroom_id | string | โ | Associated classroom |
event_title | string | โ | Event title |
description | string | โ | Event description |
start_datetime | Date/Timestamp | โ | Event start time |
end_datetime | Date/Timestamp | โ | Event end time |
location | string | โ | Event location |
event_type | string | โ | โmeetingโ, โconferenceโ, โactivityโ, โexamโ, โholidayโ |
status | string | โ | โscheduledโ, โongoingโ, โcompletedโ, โcancelledโ |
is_recurring | boolean | โ | Whether event repeats |
recurrence_pattern | string | โ | Recurrence pattern if applicable |
Notification System
notifications Collection
Purpose: Stores system notifications for users
Notification Fields
| Field | Type | Required | Description |
|---|---|---|---|
id | string | โ | Document ID (auto-generated) |
user_id | string | โ | Recipientโs UID |
title | string | โ | Notification title |
content | string | โ | Notification content |
notification_type | string | โ | โmessageโ, โannouncementโ, โeventโ, โgradeโ, โattendanceโ |
conversation_id | string | โ | Related conversation ID |
is_read | boolean | โ | Whether notification has been read |
is_push_sent | boolean | โ | Whether push notification was sent |
created_at | Timestamp | โ | Creation timestamp |
sent_at | Timestamp | โ | When notification was sent |
user_device_tokens Collection
Purpose: Stores FCM tokens for push notifications
Device Token Fields
| Field | Type | Required | Description |
|---|---|---|---|
id | string | โ | Document ID (auto-generated) |
user_id | string | โ | Userโs UID |
fcm_token | string | โ | Firebase Cloud Messaging token |
device_type | string | โ | โandroidโ, โwebโ |
created_at | Timestamp | โ | Token creation time |
updated_at | Timestamp | โ | Last update time |
Data Relationships
Key Relationships
- Users โ Classrooms (One-to-Many via
teacher_id) - Classrooms โ Students (Many-to-Many via
student_classrooms) - Parents โ Students (Many-to-Many via
parent_students) - Users โ Messages (One-to-Many via
sender_id/receiver_id) - Classrooms โ Announcements (One-to-Many via
classroom_id) - Users โ Notifications (One-to-Many via
user_id)
Security Rules
Firestore Security Rules
Usage Patterns
Common Queries
- Get userโs classrooms:
classroomswhereteacher_id == user.uid - Get classroom students:
studentswhereclassroom_id == classroom.id - Get user messages:
messageswherereceiver_id == user.uid - Get classroom announcements:
announcementswhereclassroom_id == classroom.id - Get user notifications:
notificationswhereuser_id == user.uid
Data Flow
- Teacher creates classroom โ
classroomscollection - Teacher adds students โ
students+student_classroomscollections - Parent joins classroom โ
classroom_parentscollection - Teacher creates announcement โ
announcementscollection - User sends message โ
messages+conversationscollections - System creates notification โ
notificationscollection
Notes
Important Notes
- All timestamps use Firebase
Timestamptype - Document IDs are auto-generated unless specified
- Arrays are used for multi-value fields (e.g.,
participants,parent_ids) - Optional fields are marked with โ in the Required column
- All collections require authentication (
request.auth != null) - Storage paths follow the pattern:
///