-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdb.sql
257 lines (206 loc) · 6.71 KB
/
db.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
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
-- phpMyAdmin SQL Dump
-- version 5.0.4
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: May 16, 2021 at 11:03 AM
-- Server version: 10.4.17-MariaDB
-- PHP Version: 8.0.2
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;
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 utf8mb4 */;
--
-- Database: `book store`
--
-- --------------------------------------------------------
--
-- Table structure for table `author`
--
CREATE TABLE `author` (
`AuthorID` int(9) NOT NULL,
`Firstname` varchar(50) NOT NULL,
`Lastname` varchar(50) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `author`
--
INSERT INTO `author` (`AuthorID`, `Firstname`, `Lastname`) VALUES
(1, 'Harper', 'Lee'),
(2, 'Ben', 'Graham'),
(3, 'Peter', 'Lynch');
-- --------------------------------------------------------
--
-- Table structure for table `book`
--
CREATE TABLE `book` (
`BookID` int(9) NOT NULL,
`AuthorID` int(9) NOT NULL,
`publisherid` int(9) NOT NULL,
`categoryid` int(9) NOT NULL,
`Title` varchar(50) NOT NULL,
`EditionNumber` int(9) NOT NULL,
`Language` varchar(15) NOT NULL,
`Price` float NOT NULL,
`Descriptions` text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `book`
--
INSERT INTO `book` (`BookID`, `AuthorID`, `publisherid`, `categoryid`, `Title`, `EditionNumber`, `Language`, `Price`, `Descriptions`) VALUES
(1, 2, 2, 1, 'The Intelligent Investor', 1, 'English', 170, 'The Intelligent Investor by Benjamin Graham, first published in 1949, is a widely acclaimed book on value investing. The book teaches readers strategies on how to successfully use value investing in the stock market.'),
(2, 1, 2, 2, 'To Kill a Mockingbird', 1, 'English', 25, 'To Kill a Mockingbird is a novel by the American author Harper Lee. It was published in 1960 and was instantly successful. In the United States, it is widely read in high schools and middle schools. To Kill a Mockingbird has become a classic of modern American literature, winning the Pulitzer Prize'),
(4, 3, 1, 1, 'One Up on Wall Street', 1, 'English', 25, 'In easy-to-follow terminology, Lynch offers directions for sorting out the long shots from the no shots by spending just a few minutes with a company\'s financial statements. His advice for producing \"tenbaggers\" can turn a stock portfolio into a star performer!');
-- --------------------------------------------------------
--
-- Table structure for table `category`
--
CREATE TABLE `category` (
`CategoryID` int(9) NOT NULL,
`Title` varchar(50) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `category`
--
INSERT INTO `category` (`CategoryID`, `Title`) VALUES
(1, 'Investment'),
(2, 'Novels');
-- --------------------------------------------------------
--
-- Table structure for table `orders`
--
CREATE TABLE `orders` (
`OrderID` int(9) NOT NULL,
`UserID` int(9) NOT NULL,
`BookID` int(9) NOT NULL,
`OrderDate` date NOT NULL,
`Total` float NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `orders`
--
INSERT INTO `orders` (`OrderID`, `UserID`, `BookID`, `OrderDate`, `Total`) VALUES
(4, 1, 2, '2021-05-14', 25),
(5, 2, 2, '2021-05-14', 25);
-- --------------------------------------------------------
--
-- Table structure for table `publisher`
--
CREATE TABLE `publisher` (
`PublisherID` int(9) NOT NULL,
`Title` varchar(50) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `publisher`
--
INSERT INTO `publisher` (`PublisherID`, `Title`) VALUES
(1, 'Jangal Publications'),
(2, 'Planet Independent Publications');
-- --------------------------------------------------------
--
-- Table structure for table `user`
--
CREATE TABLE `user` (
`UserID` int(9) NOT NULL,
`Firstname` varchar(50) NOT NULL,
`Lastname` varchar(50) NOT NULL,
`Email` varchar(50) NOT NULL,
`Password` varchar(40) NOT NULL,
`PostalCode` varchar(10) NOT NULL,
`Phonenumber` varchar(11) NOT NULL,
`Address` text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `user`
--
INSERT INTO `user` (`UserID`, `Firstname`, `Lastname`, `Email`, `Password`, `PostalCode`, `Phonenumber`, `Address`) VALUES
(1, 'Shabnam', 'Zare', '[email protected]', 'abc123', '00601', '0912222222', 'Vanak'),
(2, 'Taha', 'Shieenavaz', '[email protected]', '1200', '4444', '93700000000', 'Karaj');
--
-- Indexes for dumped tables
--
--
-- Indexes for table `author`
--
ALTER TABLE `author`
ADD PRIMARY KEY (`AuthorID`);
--
-- Indexes for table `book`
--
ALTER TABLE `book`
ADD PRIMARY KEY (`BookID`),
ADD KEY `author_id` (`AuthorID`),
ADD KEY `publisherid` (`publisherid`),
ADD KEY `categoryid` (`categoryid`);
--
-- Indexes for table `category`
--
ALTER TABLE `category`
ADD PRIMARY KEY (`CategoryID`);
--
-- Indexes for table `orders`
--
ALTER TABLE `orders`
ADD PRIMARY KEY (`OrderID`);
--
-- Indexes for table `publisher`
--
ALTER TABLE `publisher`
ADD PRIMARY KEY (`PublisherID`);
--
-- Indexes for table `user`
--
ALTER TABLE `user`
ADD PRIMARY KEY (`UserID`),
ADD UNIQUE KEY `Email` (`Email`),
ADD UNIQUE KEY `Phonenumber` (`Phonenumber`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `author`
--
ALTER TABLE `author`
MODIFY `AuthorID` int(9) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;
--
-- AUTO_INCREMENT for table `book`
--
ALTER TABLE `book`
MODIFY `BookID` int(9) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;
--
-- AUTO_INCREMENT for table `category`
--
ALTER TABLE `category`
MODIFY `CategoryID` int(9) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
--
-- AUTO_INCREMENT for table `orders`
--
ALTER TABLE `orders`
MODIFY `OrderID` int(9) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=8;
--
-- AUTO_INCREMENT for table `publisher`
--
ALTER TABLE `publisher`
MODIFY `PublisherID` int(9) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
--
-- AUTO_INCREMENT for table `user`
--
ALTER TABLE `user`
MODIFY `UserID` int(9) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7;
--
-- Constraints for dumped tables
--
--
-- Constraints for table `book`
--
ALTER TABLE `book`
ADD CONSTRAINT `book_ibfk_1` FOREIGN KEY (`AuthorID`) REFERENCES `author` (`AuthorID`),
ADD CONSTRAINT `book_ibfk_2` FOREIGN KEY (`publisherid`) REFERENCES `publisher` (`PublisherID`),
ADD CONSTRAINT `book_ibfk_3` FOREIGN KEY (`categoryid`) REFERENCES `category` (`CategoryID`);
COMMIT;
/*!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 */;