-
Notifications
You must be signed in to change notification settings - Fork 18
/
student_management.sql
76 lines (69 loc) · 2.26 KB
/
student_management.sql
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
DROP SCHEMA IF EXISTS student_management CASCADE;
CREATE SCHEMA IF NOT EXISTS student_management;
DROP TABLE IF EXISTS student_management.user_login;
CREATE TABLE IF NOT EXISTS student_management.user_login (
user_id TEXT PRIMARY KEY,
user_password TEXT,
first_name TEXT,
last_name TEXT,
sign_up_on DATE,
email_id TEXT
);
DROP TABLE IF EXISTS student_management.parent_details;
CREATE TABLE IF NOT EXISTS student_management.parent_details (
parent_id TEXT PRIMARY KEY,
father_first_name TEXT,
father_last_name TEXT,
father_email_id TEXT,
father_mobile TEXT,
father_occupation TEXT,
mother_first_name TEXT,
mother_last_name TEXT,
mother_email_id TEXT,
mother_mobile TEXT,
mother_occupation TEXT
);
DROP TABLE IF EXISTS student_management.teachers;
CREATE TABLE IF NOT EXISTS student_management.teachers (
teacher_id TEXT PRIMARY KEY,
first_name TEXT,
last_name TEXT,
date_of_birth DATE,
email_id TEXT,
contact TEXT,
registration_date DATE,
registration_id TEXT UNIQUE
);
DROP TABLE IF EXISTS student_management.class_details;
CREATE TABLE IF NOT EXISTS student_management.class_details (
class_id TEXT PRIMARY KEY,
class_teacher TEXT REFERENCES student_management.teachers (teacher_id),
class_year TEXT
);
DROP TABLE IF EXISTS student_management.student_details;
CREATE TABLE IF NOT EXISTS student_management.student_details (
student_id TEXT PRIMARY KEY,
first_name TEXT,
last_name TEXT,
date_of_birth DATE,
class_id TEXT REFERENCES student_management.class_details (class_id),
roll_no TEXT,
email_id TEXT,
parent_id TEXT REFERENCES student_management.parent_details (parent_id),
registration_date DATE,
registration_id TEXT UNIQUE
);
DROP TABLE IF EXISTS student_management.subject;
CREATE TABLE IF NOT EXISTS student_management.subject (
subject_id TEXT PRIMARY KEY,
subject_name TEXT,
class_year TEXT,
subject_head TEXT REFERENCES student_management.teachers (teacher_id)
);
DROP TABLE IF EXISTS student_management.subject_tutors;
CREATE TABLE IF NOT EXISTS student_management.subject_tutors (
row_id SERIAL PRIMARY KEY,
subject_id TEXT REFERENCES student_management.subject (subject_id),
teacher_id TEXT REFERENCES student_management.teachers (teacher_id),
class_id TEXT REFERENCES student_management.class_details (class_id)
);