-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathseed.py
More file actions
62 lines (57 loc) · 1.47 KB
/
Copy pathseed.py
File metadata and controls
62 lines (57 loc) · 1.47 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
import sqlite3
con = sqlite3.connect("aeg_reg.db")
cur = con.cursor()
# Create `students` table
cur.execute("""
DROP TABLE IF EXISTS `students`;
""")
cur.execute("""
CREATE TABLE `students` (
`uid` INTEGER PRIMARY KEY NOT NULL,
`user_password` varchar(12) NOT NULL,
`user_firstname` varchar(32) NOT NULL,
`user_lastname` varchar(32) NOT NULL,
`user_major` varchar(64) NOT NULL,
`tid` INTEGER NOT NULL,
FOREIGN KEY (tid) REFERENCES teachers (tid)
)
""")
# Create `courses` table
cur.execute("""
DROP TABLE IF EXISTS `courses`;
""")
cur.execute("""
CREATE TABLE `courses` (
`cid` INTEGER PRIMARY KEY NOT NULL,
`name` varchar(50) NOT NULL,
`classroom` varchar(15) NOT NULL,
`bldg` CHAR(3) NOT NULL,
`tidClass` INTEGER NOT NULL,
FOREIGN KEY (tidClass) REFERENCES teachers (tid)
)
""")
# Create `registered` table
cur.execute("""
DROP TABLE IF EXISTS `registered`;
""")
cur.execute("""
CREATE TABLE `registered` (
`uidR` INTEGER,
`cidR` INTEGER,
PRIMARY KEY (uidR, cidR),
FOREIGN KEY (uidR) REFERENCES students (uid),
FOREIGN KEY (cidR) REFERENCES courses (cid) -- Assuming 'courses' table exists with 'cid' as a primary key
);
""")
# Create `teachers` table
cur.execute("""
DROP TABLE IF EXISTS `teachers`;
""")
cur.execute("""
CREATE TABLE `teachers` (
`tid` INTEGER PRIMARY KEY NOT NULL,
`user_password` varchar(12) NOT NULL,
`name` TEXT NOT NULL,
`department` TEXT NOT NULL,
`dob` DATE NOT NULL)
""")