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

FieldTypeRequiredDescription
uidstringโœ…Firebase Auth UID (document ID)
emailstringโœ…Userโ€™s email address
fullNamestringโœ…Userโ€™s full name
rolestringโœ…User role: โ€œteacherโ€ or โ€œparentโ€
phoneNumberstringโŒUserโ€™s phone number
profilePictureUrlstringโŒURL to profile picture
createdAtTimestampโœ…Account creation time
updatedAtTimestampโœ…Last profile update
verifiedbooleanโŒWhether user is verified
classroomCodestringโŒClassroom code for teachers
Security Rule: allow read, write: if request.auth != null && request.auth.uid == userId

Classroom Management

classrooms Collection

Purpose: Stores classroom information created by teachers

Classroom Fields

FieldTypeRequiredDescription
idstringโœ…Document ID (auto-generated)
school_idstringโœ…School identifier
classroom_codestringโœ…Unique classroom code
room_numberstringโŒPhysical room number
grade_levelstringโŒGrade level (e.g., โ€œGrade 1โ€)
sectionstringโŒSection (e.g., โ€œAโ€, โ€œBโ€)
capacitynumberโœ…Maximum students allowed
teacher_idstringโœ…Teacherโ€™s UID
subject_areastringโŒSubject taught
academic_yearstringโŒAcademic year
created_atTimestampโœ…Creation timestamp
qr_code_datastringโŒQR code for easy access

classroom_parents Collection

Purpose: Links parents to classrooms for access control

Classroom Parents Fields

FieldTypeRequiredDescription
parent_idstringโœ…Parentโ€™s UID
classroom_idstringโœ…Classroom ID
joined_atTimestampโœ…When parent joined

Student Management

students Collection

Purpose: Stores student information

Student Fields

FieldTypeRequiredDescription
idstringโœ…Document ID (auto-generated)
student_numberstringโœ…Unique student number
first_namestringโœ…Studentโ€™s first name
last_namestringโœ…Studentโ€™s last name
date_of_birthstring/Dateโœ…Date of birth
genderstringโœ…Gender: โ€œmaleโ€, โ€œfemaleโ€, โ€œotherโ€
grade_levelstringโœ…Current grade level
addressstringโŒHome address
emergency_contactstringโŒEmergency contact details
enrollment_dateTimestampโœ…When enrolled
statusstringโœ…Status: โ€œactiveโ€, โ€œinactiveโ€, โ€œgraduatedโ€
parent_idsarrayโŒArray of parent UIDs

student_classrooms Collection

Purpose: Tracks student enrollment in classrooms

Student Classrooms Fields

FieldTypeRequiredDescription
student_idstringโœ…Studentโ€™s document ID
classroom_idstringโœ…Classroom ID
enrolled_atTimestampโœ…Enrollment timestamp
statusstringโœ…Status: โ€œactiveโ€, โ€œdroppedโ€, โ€œcompletedโ€
final_gradenumberโŒFinal grade if completed

parent_students Collection

Purpose: Links parents to their children

Parent Students Fields

FieldTypeRequiredDescription
parent_idstringโœ…Parentโ€™s UID
student_idstringโœ…Studentโ€™s document ID
relationship_typestringโœ…โ€œfatherโ€, โ€œmotherโ€, โ€œguardianโ€, โ€œsiblingโ€
is_primary_contactbooleanโœ…Whether primary contact
created_atTimestampโœ…Relationship creation time

Communication System

messages Collection

Purpose: Stores direct messages between users

Message Fields

FieldTypeRequiredDescription
idstringโœ…Document ID (auto-generated)
sender_idstringโœ…Senderโ€™s UID
receiver_idstringโœ…Receiverโ€™s UID
classroom_idstringโŒAssociated classroom
subjectstringโŒMessage subject
message_contentstringโœ…Message text content
sent_atTimestampโœ…When message was sent
read_atTimestampโŒWhen message was read
priority_levelstringโœ…โ€œlowโ€, โ€œmediumโ€, โ€œhighโ€, โ€œurgentโ€
message_typestringโœ…โ€œdirectโ€, โ€œannouncementโ€, โ€œalertโ€
is_readbooleanโœ…Whether message has been read
parent_message_idstringโŒFor reply threading
attachment_urlstringโŒURL to attached file
conversation_idstringโŒFor conversation grouping

conversations Collection

Purpose: Groups messages into conversations for better organization

Conversation Fields

FieldTypeRequiredDescription
idstringโœ…Document ID (auto-generated)
participantsarrayโœ…Array of user UIDs (always 2 for direct)
conversation_typestringโœ…โ€œdirectโ€
last_messagestringโŒLast message content
last_message_atTimestampโŒWhen last message was sent
last_message_senderstringโŒUID of last message sender
created_atTimestampโœ…Conversation creation time
updated_atTimestampโœ…Last update time
unread_countobjectโŒ{userId: count} for each participant

announcements Collection

Purpose: Stores announcements made by teachers

Announcement Fields

FieldTypeRequiredDescription
idstringโœ…Document ID (auto-generated)
teacher_idstringโœ…Teacherโ€™s UID
classroom_idstringโŒAssociated classroom
titlestringโœ…Announcement title
contentstringโœ…Announcement content
posted_atTimestampโœ…When posted
expires_atTimestampโŒWhen announcement expires
priority_levelstringโœ…โ€œlowโ€, โ€œmediumโ€, โ€œhighโ€, โ€œurgentโ€
announcement_typestringโœ…โ€œgeneralโ€, โ€œacademicโ€, โ€œeventโ€, โ€œemergencyโ€
is_activebooleanโœ…Whether currently active
attachment_urlstringโŒURL to attached file
attachmentsarrayโŒArray of AnnouncementAttachment objects

Document Management

documents Collection

Purpose: Stores metadata for uploaded documents

Document Fields

FieldTypeRequiredDescription
idstringโœ…Document ID (auto-generated)
teacher_idstringโœ…Teacher who uploaded
classroom_idstringโŒAssociated classroom
file_namestringโœ…Original filename
file_urlstringโœ…Firebase Storage URL
file_sizenumberโœ…File size in bytes
file_typestringโœ…MIME type
uploaded_bystringโœ…Teacherโ€™s name
uploaded_atTimestampโœ…Upload timestamp

Event Management

events Collection

Purpose: Stores calendar events and activities

Event Fields

FieldTypeRequiredDescription
idstringโœ…Document ID (auto-generated)
created_bystringโœ…Creatorโ€™s UID
classroom_idstringโŒAssociated classroom
event_titlestringโœ…Event title
descriptionstringโŒEvent description
start_datetimeDate/Timestampโœ…Event start time
end_datetimeDate/Timestampโœ…Event end time
locationstringโŒEvent location
event_typestringโœ…โ€œmeetingโ€, โ€œconferenceโ€, โ€œactivityโ€, โ€œexamโ€, โ€œholidayโ€
statusstringโœ…โ€œscheduledโ€, โ€œongoingโ€, โ€œcompletedโ€, โ€œcancelledโ€
is_recurringbooleanโœ…Whether event repeats
recurrence_patternstringโŒRecurrence pattern if applicable

Notification System

notifications Collection

Purpose: Stores system notifications for users

Notification Fields

FieldTypeRequiredDescription
idstringโœ…Document ID (auto-generated)
user_idstringโœ…Recipientโ€™s UID
titlestringโœ…Notification title
contentstringโœ…Notification content
notification_typestringโœ…โ€œmessageโ€, โ€œannouncementโ€, โ€œeventโ€, โ€œgradeโ€, โ€œattendanceโ€
conversation_idstringโŒRelated conversation ID
is_readbooleanโœ…Whether notification has been read
is_push_sentbooleanโœ…Whether push notification was sent
created_atTimestampโœ…Creation timestamp
sent_atTimestampโŒWhen notification was sent

user_device_tokens Collection

Purpose: Stores FCM tokens for push notifications

Device Token Fields

FieldTypeRequiredDescription
idstringโœ…Document ID (auto-generated)
user_idstringโœ…Userโ€™s UID
fcm_tokenstringโœ…Firebase Cloud Messaging token
device_typestringโœ…โ€œandroidโ€, โ€œwebโ€
created_atTimestampโœ…Token creation time
updated_atTimestampโœ…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

rules_version = '2';
service cloud.firestore {
  match /databases/{database}/documents {
    // Users collection
    match /users/{userId} {
      allow read, write: if request.auth != null && 
        (request.auth.uid == userId || request.auth.uid in resource.data.participants);
    }
    
    // Students collection
    match /students/{studentId} {
      allow read, write: if request.auth != null;
    }
    
    // Student classrooms collection
    match /student_classrooms/{enrollmentId} {
      allow read, write: if request.auth != null;
    }
    
    // Classrooms collection
    match /classrooms/{classroomId} {
      allow read, write: if request.auth != null;
    }
    
    // Messages collection
    match /messages/{messageId} {
      allow read, write: if request.auth != null && 
        (resource.data.sender_id == request.auth.uid || 
         resource.data.receiver_id == request.auth.uid);
    }
    
    // Conversations collection
    match /conversations/{conversationId} {
      allow read, write: if request.auth != null && 
        request.auth.uid in resource.data.participants;
    }
    
    // Notifications collection
    match /notifications/{notificationId} {
      allow read, write: if request.auth != null && 
        resource.data.user_id == request.auth.uid;
    }
    
    // Device tokens collection
    match /user_device_tokens/{userId} {
      allow read, write: if request.auth != null && 
        resource.data.user_id == request.auth.uid;
    }
  }
}

Usage Patterns

Common Queries

  • Get userโ€™s classrooms: classrooms where teacher_id == user.uid
  • Get classroom students: students where classroom_id == classroom.id
  • Get user messages: messages where receiver_id == user.uid
  • Get classroom announcements: announcements where classroom_id == classroom.id
  • Get user notifications: notifications where user_id == user.uid

Data Flow

  1. Teacher creates classroom โ†’ classrooms collection
  2. Teacher adds students โ†’ students + student_classrooms collections
  3. Parent joins classroom โ†’ classroom_parents collection
  4. Teacher creates announcement โ†’ announcements collection
  5. User sends message โ†’ messages + conversations collections
  6. System creates notification โ†’ notifications collection

Notes

Important Notes

  • All timestamps use Firebase Timestamp type
  • 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: ///
โŒ˜I