-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathschema.sql
More file actions
39 lines (36 loc) · 1.07 KB
/
Copy pathschema.sql
File metadata and controls
39 lines (36 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
DROP TABLE IF EXISTS AttendanceRecords;
DROP TABLE IF EXISTS Sessions;
DROP TABLE IF EXISTS Users;
CREATE TABLE Users (
id TEXT PRIMARY KEY,
email TEXT UNIQUE NOT NULL,
passwordHash TEXT NOT NULL,
role TEXT NOT NULL, -- 'teacher' or 'student'
name TEXT NOT NULL,
studentId TEXT, -- Only for students
createdAt DATETIME DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE Sessions (
id TEXT PRIMARY KEY,
teacherId TEXT NOT NULL,
teacherLat REAL NOT NULL,
teacherLng REAL NOT NULL,
rangeMeters REAL NOT NULL DEFAULT 10,
createdAt DATETIME DEFAULT CURRENT_TIMESTAMP,
endedAt DATETIME,
FOREIGN KEY(teacherId) REFERENCES Users(id)
);
CREATE TABLE AttendanceRecords (
id TEXT PRIMARY KEY,
sessionId TEXT NOT NULL,
studentUserId TEXT NOT NULL,
photoData TEXT NOT NULL,
studentLat REAL NOT NULL,
studentLng REAL NOT NULL,
distanceMeters REAL NOT NULL,
deviceFingerprint TEXT,
createdAt DATETIME DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY(sessionId) REFERENCES Sessions(id),
FOREIGN KEY(studentUserId) REFERENCES Users(id),
UNIQUE(sessionId, studentUserId)
);