-
Notifications
You must be signed in to change notification settings - Fork 0
/
data.sql
executable file
·85 lines (57 loc) · 1.62 KB
/
data.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
PRAGMA FOREIGN_KEY = ON;
create table if not exists admins (
id integer primary key autoincrement,
username varchar(50) not null,
password varchar(100) not null,
phone varchar(50) not null,
email text not null
);
create table if not exists books (
name varchar(100) not null ,
id integer primary key autoincrement,
author varchar(50) not null ,
category text
);
create table if not exists students (
id integer primary key autoincrement,
cardnum integer unique,
name varchar(50),
dob date,
doj date,
address text,
phone varchar(50),
borrowlimit integer default 2,
password varchar(150) not null,
email text not null
);
create table if not exists issue (
transID integer primary key autoincrement,
bookid integer,
studentid integer,
adminid integer,
issuedate date,
foreign key(bookid) references books(id) on update cascade on delete cascade,
foreign key(studentid) references students(id) on update cascade on delete cascade,
foreign key(adminid) references admins(id) on update cascade on delete cascade
);
create table if not exists issue_history (
transID integer primary key,
bookid integer,
studentid integer,
issuedbyid integer,
issueDate date,
returnDate date,
lateFees integer,
foreign key(bookid) references books(id) on update cascade on delete cascade,
foreign key(studentid) references students(id) on update cascade on delete cascade,
foreign key(issuedbyid) references admins(id) on update cascade on delete cascade
);
create table if not exists student_reg(
regID integer primary key autoincrement,
name varchar(50),
dob date,
address text,
phone varchar(10),
password varchar(150) not null,
email text not null
);