-
Notifications
You must be signed in to change notification settings - Fork 0
/
Bookstore.sql
35 lines (26 loc) · 1.03 KB
/
Bookstore.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
CREATE TABLE `Books` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`title` varchar(150) DEFAULT NULL,
`author` varchar(150) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `Orders`(
`order_id` int(11) NOT NULL AUTO_INCREMENT,
`book_id` int(11) DEFAULT NULL,
`quantity` int(11) DEFAULT NULL,
`cart` varchar(30) DEFAULT NULL,
PRIMARY KEY (`order_id`),
CONSTRAINT `FK_book_id` FOREIGN KEY (`book_id`) REFERENCES `Books`(`id`)
)ENGINE = INNODB DEFAULT CHARSET=utf8;
INSERT INTO `Books` (title, author)
Values ('The Girl with the Dragon Tattoo','Stieg Larsson');
INSERT INTO `Books` (title, author)
Values ('Harry Potter and the Half-Blood Prince','J.K. Rowling');
INSERT INTO `Books` (title, author)
Values ('A Thousand Splendid Suns','Khaled Hosseini');
INSERT INTO `Books` (title, author)
Values ('The Alchemist','Paulo Coelho');
INSERT INTO `Books` (title, author)
Values ('Life of Pi','Yann Martel');
INSERT INTO `Books` (title, author)
Values ('The Girl on the Train','Paula Hawkins');