forked from Lokesh-debug/SE-project
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInvDB.sql
More file actions
107 lines (94 loc) · 2.64 KB
/
InvDB.sql
File metadata and controls
107 lines (94 loc) · 2.64 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
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
Create database invi_app;
use invi_app;
use invi;
Create table user( userId varchar(15) NOT NULL primary key,
username varchar(233) NOT NULL,
password varchar(233) NOT NULL,
logDate date ,
logTime time,
role int
);
Alter table user ADD role int;
CREATE TABLE department(
deptid varchar(3) NOT NULL,
deptname varchar(255) NOT NULL,
Constraint d_pk primary key(deptid)
);
CREATE TABLE faculty(
fid varchar(15) NOT NULL primary key,
fname varchar(233) NOT NULL,
deptid varchar(233) NOT NULL,
femail varchar(255) NOT NULL,
fphone varchar(255) NOT NULL,
Constraint f_fk foreign key(fid) references user(userId)
);
ALTER TABLE faculty ADD mon varchar(30),
ADD tue varchar(30),
ADD wed varchar(30),
ADD thu varchar(30),
ADD fri varchar(30),
ADD sat varchar(30);
CREATE TABLE classroom (
roomno int(255) NOT NULL primary key,
capacity int(255) NOT NULL
);
Create table course(
Courseid varchar(100) primary key,
Cname varchar(100)
);
create table branch(
deptid varchar(3) NOT NULL ,
sec varchar(1),
nos int,
primary key(deptid,sec),
Constraint b_fk foreign key(deptid) references department(deptid)
);
create table course_branch(
Courseid varchar(100) not null,
deptid varchar(3) NOT NULL ,
sec varchar(1) not null,
primary key(deptid,sec,Courseid),
Constraint cb_fk foreign key(deptid,sec) references branch(deptid,sec),
Constraint cb_fk1 foreign key(Courseid) references course(Courseid)
);
CREATE TABLE exam(
examid int(23) NOT NULL primary key,
examdate date NOT NULL,
courseid varchar(100),
Constraint e_fk foreign key(courseid) references course(Courseid)
);
Create table coe(
Coeid varchar(15),
ndays int,
sdate date not null,
edate date not null,
cdate date not null,
primary key(Coeid,sdate,edate),
constraint c_fk foreign key(Coeid) references user(userId)
);
Create table allocation(
Examid int(23),
courseid varchar(100),
Rnos int not null,
Roomno int(255) ,
Invid varchar(15),
Conf varchar(2),
primary key(Examid,Roomno),
Constraint a_fk1 foreign key(courseid) references course(Courseid),
Constraint a_fk2 foreign key(Examid) references exam(Examid),
Constraint a_fk3 foreign key(Roomno) references classroom(roomno),
Constraint a_fk4 foreign key(Invid) references faculty(fid)
);
Insert into user (userId,username,password,logDate,logTime,role) values
('T12','Lathika','lathi123','2019-11-09','19:20:10',0),
('C10','Lokesh','lok123','2019-11-09','13:20:10',1),
('T11','Srehari','sre123','2019-11-07','19:20:10',0);
delete from user where userId=12345;
select * from allocation;
select * from classroom;
select * from coe;
select * from course;
select * from department;
select * from exam;
select * from faculty;
select * from user;