-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdatabase.sql
More file actions
36 lines (31 loc) · 952 Bytes
/
database.sql
File metadata and controls
36 lines (31 loc) · 952 Bytes
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
CREATE DATABASE IF NOT EXISTS get_search_select CHARACTER SET utf8 COLLATE utf8_general_ci;
USE get_search_select;
DROP TABLE IF EXISTS books;
DROP TABLE IF EXISTS genres;
CREATE TABLE genres (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(100) NOT NULL
);
CREATE TABLE books (
id INT AUTO_INCREMENT PRIMARY KEY,
title VARCHAR(100) NOT NULL,
author VARCHAR(100) NOT NULL,
genre_id INT NOT NULL
);
INSERT INTO genres (name) VALUES
('Fantasy'),
('Romance'),
('Drama'),
('Horror'),
('Classic');
INSERT INTO books (title, author, genre_id) VALUES
('Harry Potter', 'J. K. Rowling', 1),
('The Hobbit', 'J. R. R. Tolkien', 1),
('Pride and Prejudice', 'Jane Austen', 2),
('Romeo and Juliet', 'William Shakespeare', 3),
('Dracula', 'Bram Stoker', 4),
('1984', 'George Orwell', 5),
('Animal Farm', 'George Orwell', 5),
('The Shining', 'Stephen King', 4),
('Jane Eyre', 'Charlotte Bronte', 2),
('Hamlet', 'William Shakespeare', 3);