-
Notifications
You must be signed in to change notification settings - Fork 1
/
nwlibcosc.sql
233 lines (202 loc) · 8.62 KB
/
nwlibcosc.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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
-- MySQL Workbench Forward Engineering
SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL,ALLOW_INVALID_DATES';
-- -----------------------------------------------------
-- Schema mydb
-- -----------------------------------------------------
-- -----------------------------------------------------
-- Schema librarynewprojectcosc
-- -----------------------------------------------------
-- -----------------------------------------------------
-- Schema librarynewprojectcosc
-- -----------------------------------------------------
CREATE SCHEMA IF NOT EXISTS `librarynewprojectcosc` DEFAULT CHARACTER SET latin1 ;
USE `librarynewprojectcosc` ;
-- -----------------------------------------------------
-- Table `librarynewprojectcosc`.`book`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `librarynewprojectcosc`.`book` ;
CREATE TABLE IF NOT EXISTS `librarynewprojectcosc`.`book` (
`bookId` VARCHAR(8) NOT NULL,
`bookName` VARCHAR(45) NOT NULL,
`isbn` VARCHAR(12) NOT NULL,
`bookAuthor` VARCHAR(45) NOT NULL,
`bookPublisher` VARCHAR(45) NOT NULL,
`bookNumber` INT(11) NOT NULL,
`Language_languageId` INT(11) NOT NULL,
PRIMARY KEY (`bookId`))
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8;
-- -----------------------------------------------------
-- Table `librarynewprojectcosc`.`bookcopy`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `librarynewprojectcosc`.`bookcopy` ;
CREATE TABLE IF NOT EXISTS `librarynewprojectcosc`.`bookcopy` (
`bookcopyId` INT(11) NOT NULL AUTO_INCREMENT,
`bookcopyName` VARCHAR(45) NOT NULL,
`bookcopyStatus` TINYINT(1) NULL DEFAULT NULL,
`Book_bookId` VARCHAR(8) NOT NULL,
PRIMARY KEY (`bookcopyId`),
INDEX `fk_BookCopy_Book1_idx` (`Book_bookId` ASC),
CONSTRAINT `fk_BookCopy_Book1`
FOREIGN KEY (`Book_bookId`)
REFERENCES `librarynewprojectcosc`.`book` (`bookId`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8;
-- -----------------------------------------------------
-- Table `librarynewprojectcosc`.`employee`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `librarynewprojectcosc`.`employee` ;
CREATE TABLE IF NOT EXISTS `librarynewprojectcosc`.`employee` (
`empId` INT(11) NOT NULL,
`empName` VARCHAR(45) NOT NULL,
`empContactNo` VARCHAR(11) NOT NULL,
`empAddress` VARCHAR(45) NOT NULL,
`empUsername` VARCHAR(45) NOT NULL,
`empPassword` VARCHAR(45) NOT NULL,
`empAccess` VARCHAR(10) NOT NULL,
PRIMARY KEY (`empId`))
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8;
-- -----------------------------------------------------
-- Table `librarynewprojectcosc`.`member`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `librarynewprojectcosc`.`member` ;
CREATE TABLE IF NOT EXISTS `librarynewprojectcosc`.`member` (
`memberId` INT(11) NOT NULL,
`memberName` VARCHAR(45) NOT NULL,
`memberContactNo` INT(11) NULL DEFAULT NULL,
`memberAddress` VARCHAR(45) NOT NULL,
`memberStatus` TINYINT(1) NOT NULL,
PRIMARY KEY (`memberId`))
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8;
-- -----------------------------------------------------
-- Table `librarynewprojectcosc`.`borrow`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `librarynewprojectcosc`.`borrow` ;
CREATE TABLE IF NOT EXISTS `librarynewprojectcosc`.`borrow` (
`borrowId` INT(11) NOT NULL AUTO_INCREMENT,
`borrowDate` DATETIME NOT NULL,
`borrowExpDate` DATETIME NOT NULL,
`Member_memberId` INT(11) NOT NULL,
`Employee_empId` INT(11) NOT NULL,
`bookcopy_bookcopyId` INT(11) NOT NULL,
PRIMARY KEY (`borrowId`),
INDEX `fk_Borrow_Member1_idx` (`Member_memberId` ASC),
INDEX `fk_Borrow_Employee1_idx` (`Employee_empId` ASC),
INDEX `fk_borrow_bookcopy1_idx` (`bookcopy_bookcopyId` ASC),
CONSTRAINT `fk_Borrow_Employee1`
FOREIGN KEY (`Employee_empId`)
REFERENCES `librarynewprojectcosc`.`employee` (`empId`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_Borrow_Member1`
FOREIGN KEY (`Member_memberId`)
REFERENCES `librarynewprojectcosc`.`member` (`memberId`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_borrow_bookcopy1`
FOREIGN KEY (`bookcopy_bookcopyId`)
REFERENCES `librarynewprojectcosc`.`bookcopy` (`bookcopyId`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8;
-- -----------------------------------------------------
-- Table `librarynewprojectcosc`.`returnbook`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `librarynewprojectcosc`.`returnbook` ;
CREATE TABLE IF NOT EXISTS `librarynewprojectcosc`.`returnbook` (
`returnBookId` INT(11) NOT NULL AUTO_INCREMENT,
`returnBookDatel` DATETIME NOT NULL,
`Member_memberId` INT(11) NOT NULL,
`Employee_empId` INT(11) NOT NULL,
`bookcopy_bookcopyId` INT(11) NOT NULL,
PRIMARY KEY (`returnBookId`),
INDEX `fk_ReturnBook_Member1_idx` (`Member_memberId` ASC),
INDEX `fk_ReturnBook_Employee1_idx` (`Employee_empId` ASC),
INDEX `fk_returnbook_bookcopy1_idx` (`bookcopy_bookcopyId` ASC),
CONSTRAINT `fk_ReturnBook_Employee1`
FOREIGN KEY (`Employee_empId`)
REFERENCES `librarynewprojectcosc`.`employee` (`empId`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_ReturnBook_Member1`
FOREIGN KEY (`Member_memberId`)
REFERENCES `librarynewprojectcosc`.`member` (`memberId`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_returnbook_bookcopy1`
FOREIGN KEY (`bookcopy_bookcopyId`)
REFERENCES `librarynewprojectcosc`.`bookcopy` (`bookcopyId`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8;
-- -----------------------------------------------------
-- Table `librarynewprojectcosc`.`fine`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `librarynewprojectcosc`.`fine` ;
CREATE TABLE IF NOT EXISTS `librarynewprojectcosc`.`fine` (
`fineId` INT(11) NOT NULL AUTO_INCREMENT,
`overdueDays` INT(11) NOT NULL,
`overdueFine` DOUBLE NOT NULL,
`Member_memberId` INT(11) NOT NULL,
`employee_empId` INT(11) NOT NULL,
`returnbook_returnBookId` INT(11) NOT NULL,
PRIMARY KEY (`fineId`),
INDEX `fk_Fine_Member1_idx` (`Member_memberId` ASC),
INDEX `fk_fine_employee1_idx` (`employee_empId` ASC),
INDEX `fk_fine_returnbook1_idx` (`returnbook_returnBookId` ASC),
CONSTRAINT `fk_Fine_Member1`
FOREIGN KEY (`Member_memberId`)
REFERENCES `librarynewprojectcosc`.`member` (`memberId`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_fine_employee1`
FOREIGN KEY (`employee_empId`)
REFERENCES `librarynewprojectcosc`.`employee` (`empId`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_fine_returnbook1`
FOREIGN KEY (`returnbook_returnBookId`)
REFERENCES `librarynewprojectcosc`.`returnbook` (`returnBookId`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8;
-- -----------------------------------------------------
-- Table `librarynewprojectcosc`.`guaranter`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `librarynewprojectcosc`.`guaranter` ;
CREATE TABLE IF NOT EXISTS `librarynewprojectcosc`.`guaranter` (
`guaranterId` INT(11) NOT NULL,
`guaranterName` VARCHAR(45) NOT NULL,
`guaranterContactNo` INT(11) NULL DEFAULT NULL,
`guaranterEmail` VARCHAR(20) NULL DEFAULT NULL,
`guaranterAddress` VARCHAR(45) NOT NULL,
`member_memberId` INT(11) NOT NULL,
PRIMARY KEY (`guaranterId`),
INDEX `fk_guaranter_member1_idx` (`member_memberId` ASC),
CONSTRAINT `fk_guaranter_member1`
FOREIGN KEY (`member_memberId`)
REFERENCES `librarynewprojectcosc`.`member` (`memberId`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8;
SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
-- -----------------------------------------------------
-- Data for table `librarynewprojectcosc`.`employee`
-- -----------------------------------------------------
START TRANSACTION;
USE `librarynewprojectcosc`;
INSERT INTO `librarynewprojectcosc`.`employee` (`empId`, `empName`, `empContactNo`, `empAddress`, `empUsername`, `empPassword`, `empAccess`) VALUES (111, 'wishwa', '123', 'Mora', 'admin', 'admin', 'admin');
INSERT INTO `librarynewprojectcosc`.`employee` (`empId`, `empName`, `empContactNo`, `empAddress`, `empUsername`, `empPassword`, `empAccess`) VALUES (222, 'prabodha', '456', 'Panadura', 'q', 'q', 'user');
COMMIT;