-
Notifications
You must be signed in to change notification settings - Fork 0
/
SQLQuery1.sql
122 lines (102 loc) · 3.74 KB
/
SQLQuery1.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
CREATE DATABASE StudentAttendance
GO
USE StudentAttendance
GO
CREATE TABLE Teacher (
TeacherID int NOT NULL,
FullName nvarchar(64) NOT NULL,
Email varchar(256) NOT NULL UNIQUE,
Password varchar(256) NOT NULL,
CONSTRAINT PK_Teacher PRIMARY KEY (TeacherID)
)
CREATE TABLE Class (
ClassID varchar(15) NOT NULL,
ClassName nvarchar(256) NOT NULL,
TeacherID int NOT NULL,
ClassTime int,
CONSTRAINT PK_Class PRIMARY KEY (ClassID),
CONSTRAINT FK_Class_Teacher FOREIGN KEY (TeacherID) REFERENCES Teacher(TeacherID)
)
CREATE TABLE Student(
StudentID varchar(15) NOT NULL,
FullName nvarchar(64) NOT NULL,
Class nvarchar(20),
Email varchar(256),
CONSTRAINT PK_Student PRIMARY KEY (StudentID)
)
CREATE TABLE StudentImage (
ImageID int NOT NULL IDENTITY(1, 1),
StudentID varchar(15) NOT NULL,
EncodedImage VARBINARY(MAX),
CONSTRAINT PK_StudentImage PRIMARY KEY (ImageID),
CONSTRAINT FK_StudentImage_Student FOREIGN KEY (StudentID) REFERENCES Student(StudentID)
)
CREATE TABLE StudentClass(
StudentID varchar(15) NOT NULL,
ClassID varchar(15) NOT NULL,
AbsenceTimes int NOT NULL,
CONSTRAINT PK_StudentClass PRIMARY KEY (StudentID, ClassID),
CONSTRAINT FK_StudentClass_Class FOREIGN KEY (StudentID) REFERENCES Student(StudentID),
CONSTRAINT FK_StudentClass_Student FOREIGN KEY (ClassID) REFERENCES Class(ClassID)
)
CREATE TABLE Attendance(
AttendanceID int NOT NULL IDENTITY(1, 1),
StudentID varchar(15) NOT NULL,
ClassID varchar(15) NOT NULL,
AttendanceDate date,
AttendanceTime time,
CONSTRAINT PK_Attendance PRIMARY KEY (AttendanceID),
CONSTRAINT FK_Attendance_StudentClass FOREIGN KEY (StudentID, ClassID) REFERENCES StudentClass(StudentID, ClassID)
)
USE StudentAttendance
GO
INSERT INTO Student VALUES
('18IT269', N'Nguyễn Ngọc Định', '18IT5', '[email protected]'),
('18IT351', N'Nguyễn Thị Thanh Thúy', '18IT5', '[email protected]'),
('BG', N'Bill Gates', 'A', '[email protected]'),
('ELM', N'Elon Musk', 'A', '[email protected]')
INSERT INTO Teacher VALUES
(1, N'Nguyễn Văn A', '[email protected]', 'e10adc3949ba59abbe56e057f20f883e'),
(2, N'Admin', '[email protected]', 'e10adc3949ba59abbe56e057f20f883e'),
(3, N'Nguyễn Thị B', '[email protected]', 'e10adc3949ba59abbe56e057f20f883e'),
(4, N'Nguyễn C', '[email protected]', 'e10adc3949ba59abbe56e057f20f883e')
INSERT INTO Class VALUES
('XLA1', N'Xử lý ảnh (1)', 1, 2),
('XLA2', N'Xử lý ảnh (2)', 1, 2),
('ISS3', N'Bảo mật và An toàn Hệ thống Thông tin (1)', 1, 3),
('KTPM4', N'Kiểm thử phần mềm (4)', 1, 1),
('KTPM1', N'Kiểm thử phần mềm (1)', 2, 4),
('DSP1', N'Xử lý tín hiệu số (1)', 1, 5),
('DSP2', N'Xử lý tín hiệu số (2)', 1, 5),
('ISS4', N'Bảo mật và An toàn Hệ thống Thông tin (4)', 1, 5)
INSERT INTO StudentClass VALUES
('18IT269', 'DSP1', 0),
('ELM', 'DSP1', 0),
('BG', 'DSP1', 0),
('18IT351', 'DSP1', 0),
('18IT269', 'ISS4', 0),
('ELM', 'ISS4', 0),
('BG', 'ISS4', 0),
('18IT351', 'ISS4', 0),
('18IT269', 'XLA1', 0),
('18IT351', 'XLA1', 0),
('ELM', 'XLA1', 1),
('BG', 'XLA1', 1)
SELECT * FROM StudentClass
INSERT INTO Attendance(StudentID, ClassID, AttendanceDate, AttendanceTime) VALUES
('18IT269', 'DSP1', '2021-07-03', '08:15:30'),
('18IT351', 'DSP1', '2021-07-03', '08:15:35'),
('ELM', 'DSP1', '2021-07-03', '08:15:40'),
('BG', 'DSP1', '2021-07-03', '08:15:45'),
('18IT269', 'XLA1', '2021-07-06', '13:15:15'),
('ELM', 'XLA1', '2021-07-06', '13:15:42'),
('BG', 'XLA1', '2021-07-06', '13:15:45')
SELECT * FROM Attendance
SELECT ClassID, ClassName FROM Class WHERE TeacherID = 1 AND ClassTime = 5
SELECT * FROM Teacher
SELECT * FROM Class
SELECT * FROM StudentImage
curselectClass = todayClassListbox.curselection()
if curselectClass != 0:
classId = todayClassList[curselectClass].ClassID
print(classId)