This repository has been archived by the owner on Dec 9, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bookon.sql
219 lines (178 loc) · 6.07 KB
/
bookon.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
-- phpMyAdmin SQL Dump
-- version 3.4.10.1deb1
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Dec 15, 2014 at 03:41 PM
-- Server version: 5.5.31
-- PHP Version: 5.5.19-1+deb.sury.org~precise+1
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
--
-- Database: `bookon`
--
-- --------------------------------------------------------
--
-- Table structure for table `Author`
--
CREATE TABLE IF NOT EXISTS `Author` (
`AuthorId` int(11) NOT NULL AUTO_INCREMENT,
`FirstName` varchar(255) NOT NULL,
`LastName` varchar(255) NOT NULL,
`Birthdate` date DEFAULT NULL,
`HomeCountry` varchar(2) DEFAULT NULL,
PRIMARY KEY (`AuthorId`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=11 ;
-- --------------------------------------------------------
--
-- Table structure for table `Book`
--
CREATE TABLE IF NOT EXISTS `Book` (
`ISBN` bigint(13) NOT NULL,
`Title` varchar(511) NOT NULL,
`SalePrice` float NOT NULL,
`PageCount` int(6) NOT NULL,
`Edition` smallint(3) NOT NULL,
`Language` varchar(2) NOT NULL,
`Publisher` int(11) DEFAULT NULL,
PRIMARY KEY (`ISBN`),
KEY `Publisher` (`Publisher`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- --------------------------------------------------------
--
-- Table structure for table `BookAuthor`
--
CREATE TABLE IF NOT EXISTS `BookAuthor` (
`ISBN` bigint(13) NOT NULL,
`AuthorId` int(11) NOT NULL,
KEY `ISBN` (`ISBN`),
KEY `AuthorId` (`AuthorId`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- --------------------------------------------------------
--
-- Table structure for table `BookCollected`
--
CREATE TABLE IF NOT EXISTS `BookCollected` (
`CollectionId` int(11) NOT NULL,
`ISBN` bigint(13) NOT NULL,
KEY `CollectionId` (`CollectionId`),
KEY `ISBN` (`ISBN`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- --------------------------------------------------------
--
-- Table structure for table `BookCopy`
--
CREATE TABLE IF NOT EXISTS `BookCopy` (
`BookCopyId` bigint(20) NOT NULL AUTO_INCREMENT,
`IsForSale` tinyint(1) NOT NULL,
`HeldBy` int(11) DEFAULT NULL,
`ISBN` bigint(13) NOT NULL,
PRIMARY KEY (`BookCopyId`),
KEY `ISBN` (`ISBN`),
KEY `HeldBy` (`HeldBy`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=162 ;
-- --------------------------------------------------------
--
-- Table structure for table `BookRated`
--
CREATE TABLE IF NOT EXISTS `BookRated` (
`RatingId` int(11) NOT NULL AUTO_INCREMENT,
`CardNumber` int(11) NOT NULL,
`ISBN` bigint(13) NOT NULL,
`Rating` tinyint(1) NOT NULL,
`Review` text NOT NULL,
`Date` datetime DEFAULT NULL,
PRIMARY KEY (`RatingId`),
KEY `CardNumber` (`CardNumber`),
KEY `ISBN` (`ISBN`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
--
-- Table structure for table `BookTransaction`
--
CREATE TABLE IF NOT EXISTS `BookTransaction` (
`BookTransactionId` bigint(20) NOT NULL AUTO_INCREMENT,
`BookCopyId` bigint(20) NOT NULL,
`Time` datetime NOT NULL,
`ExpectedReturn` datetime DEFAULT NULL,
`ActualReturn` datetime DEFAULT NULL,
`CardNumber` int(11) NOT NULL,
PRIMARY KEY (`BookTransactionId`),
KEY `BookCopyId` (`BookCopyId`),
KEY `CardNumber` (`CardNumber`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
--
-- Table structure for table `Collection`
--
CREATE TABLE IF NOT EXISTS `Collection` (
`CollectionId` int(11) NOT NULL AUTO_INCREMENT,
`Name` varchar(255) NOT NULL,
`CardNumber` int(11) NOT NULL,
PRIMARY KEY (`CollectionId`),
KEY `CardNumber` (`CardNumber`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=4 ;
-- --------------------------------------------------------
--
-- Table structure for table `Publisher`
--
CREATE TABLE IF NOT EXISTS `Publisher` (
`PublisherId` int(11) NOT NULL AUTO_INCREMENT,
`Name` varchar(255) NOT NULL,
`Address` varchar(511) NOT NULL,
`Phone` bigint(11) NOT NULL,
PRIMARY KEY (`PublisherId`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=6 ;
-- --------------------------------------------------------
--
-- Table structure for table `User`
--
CREATE TABLE IF NOT EXISTS `User` (
`CardNumber` int(11) NOT NULL,
`IsEmployee` tinyint(1) NOT NULL,
`Name` varchar(255) NOT NULL,
`Password` varchar(72) NOT NULL,
`Email` varchar(255) NOT NULL,
`AccountStatus` tinyint(1) NOT NULL,
PRIMARY KEY (`CardNumber`),
UNIQUE KEY `Email` (`Email`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Constraints for dumped tables
--
--
-- Constraints for table `Book`
--
ALTER TABLE `Book`
ADD CONSTRAINT `Book_ibfk_1` FOREIGN KEY (`Publisher`) REFERENCES `Publisher` (`PublisherId`);
--
-- Constraints for table `BookAuthor`
--
ALTER TABLE `BookAuthor`
ADD CONSTRAINT `BookAuthor_ibfk_1` FOREIGN KEY (`ISBN`) REFERENCES `Book` (`ISBN`),
ADD CONSTRAINT `BookAuthor_ibfk_2` FOREIGN KEY (`AuthorId`) REFERENCES `Author` (`AuthorId`);
--
-- Constraints for table `BookCollected`
--
ALTER TABLE `BookCollected`
ADD CONSTRAINT `BookCollected_ibfk_1` FOREIGN KEY (`CollectionId`) REFERENCES `Collection` (`CollectionId`),
ADD CONSTRAINT `BookCollected_ibfk_2` FOREIGN KEY (`ISBN`) REFERENCES `Book` (`ISBN`);
--
-- Constraints for table `BookCopy`
--
ALTER TABLE `BookCopy`
ADD CONSTRAINT `BookCopy_ibfk_2` FOREIGN KEY (`HeldBy`) REFERENCES `User` (`CardNumber`),
ADD CONSTRAINT `BookCopy_ibfk_1` FOREIGN KEY (`ISBN`) REFERENCES `Book` (`ISBN`);
--
-- Constraints for table `BookTransaction`
--
ALTER TABLE `BookTransaction`
ADD CONSTRAINT `BookTransaction_ibfk_1` FOREIGN KEY (`BookCopyId`) REFERENCES `BookCopy` (`BookCopyId`),
ADD CONSTRAINT `BookTransaction_ibfk_2` FOREIGN KEY (`CardNumber`) REFERENCES `User` (`CardNumber`);
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;