-
Notifications
You must be signed in to change notification settings - Fork 0
/
ddl.sql
47 lines (43 loc) · 1 KB
/
ddl.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
-- Create STUDENT table
CREATE TABLE STUDENT (
USN VARCHAR(10) PRIMARY KEY,
SNAME VARCHAR(25),
ADDRESS VARCHAR(25),
PHONE VARCHAR(10),
GENDER CHAR(1)
);
-- Create SEMSEC table
CREATE TABLE SEMSEC (
SSID VARCHAR(5) PRIMARY KEY,
SEM INTEGER,
SEC CHAR(1)
);
-- Create CLASS table
CREATE TABLE CLASS (
USN VARCHAR(10),
SSID VARCHAR(5),
PRIMARY KEY (USN, SSID),
FOREIGN KEY (USN) REFERENCES STUDENT(USN),
FOREIGN KEY (SSID) REFERENCES SEMSEC(SSID)
);
-- Create SUBJECT table
CREATE TABLE SUBJECT (
SUBCODE VARCHAR(8) PRIMARY KEY,
TITLE VARCHAR(20),
SEM INTEGER,
CREDITS INTEGER
);
-- Create IAMARKS table
CREATE TABLE IAMARKS (
USN VARCHAR(10),
SUBCODE VARCHAR(8),
SSID VARCHAR(5),
TEST1 INTEGER,
TEST2 INTEGER,
TEST3 INTEGER,
FINALIA INTEGER,
PRIMARY KEY (USN, SUBCODE, SSID),
FOREIGN KEY (USN) REFERENCES STUDENT(USN),
FOREIGN KEY (SUBCODE) REFERENCES SUBJECT(SUBCODE),
FOREIGN KEY (SSID) REFERENCES SEMSEC(SSID)
);