-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathschema.sql
More file actions
76 lines (70 loc) · 2.3 KB
/
schema.sql
File metadata and controls
76 lines (70 loc) · 2.3 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
PRAGMA foreign_keys = ON;
-- Users table (common login table)
CREATE TABLE IF NOT EXISTS users (
id INTEGER PRIMARY KEY AUTOINCREMENT,
email TEXT UNIQUE NOT NULL,
password_hash TEXT NOT NULL,
role TEXT NOT NULL,
is_active INTEGER DEFAULT 1,
created_at DATETIME DEFAULT CURRENT_TIMESTAMP
);
-- Student profile
CREATE TABLE IF NOT EXISTS students (
id INTEGER PRIMARY KEY AUTOINCREMENT,
user_id INTEGER UNIQUE NOT NULL,
full_name TEXT NOT NULL,
phone TEXT,
branch TEXT,
cgpa REAL,
resume_path TEXT,
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY(user_id) REFERENCES users(id) ON DELETE CASCADE
);
-- Company profile
CREATE TABLE IF NOT EXISTS companies (
id INTEGER PRIMARY KEY AUTOINCREMENT,
user_id INTEGER UNIQUE NOT NULL,
company_name TEXT NOT NULL,
website TEXT,
description TEXT,
approval_status TEXT DEFAULT 'Pending',
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY(user_id) REFERENCES users(id) ON DELETE CASCADE
);
-- Placement drives created by companies
CREATE TABLE IF NOT EXISTS placement_drives (
id INTEGER PRIMARY KEY AUTOINCREMENT,
company_id INTEGER NOT NULL,
job_title TEXT NOT NULL,
job_description TEXT,
eligibility TEXT,
package TEXT,
min_cgpa REAL,
max_applicants INTEGER,
location TEXT,
application_deadline DATETIME,
status TEXT DEFAULT 'Pending',
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY(company_id) REFERENCES companies(id) ON DELETE CASCADE
);
-- Applications submitted by students
CREATE TABLE IF NOT EXISTS applications (
id INTEGER PRIMARY KEY AUTOINCREMENT,
student_id INTEGER NOT NULL,
drive_id INTEGER NOT NULL,
status TEXT DEFAULT 'Applied',
applied_at DATETIME DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY(student_id) REFERENCES students(id) ON DELETE CASCADE,
FOREIGN KEY(drive_id) REFERENCES placement_drives(id) ON DELETE CASCADE,
UNIQUE(student_id, drive_id)
);
-- Admin activity log (optional but useful)
CREATE TABLE IF NOT EXISTS admin_logs (
id INTEGER PRIMARY KEY AUTOINCREMENT,
admin_id INTEGER NOT NULL,
action TEXT,
target_type TEXT,
target_id INTEGER,
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY(admin_id) REFERENCES users(id) ON DELETE CASCADE
);