forked from ironhack-labs/lab-java-sql
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Script-1.sql
36 lines (29 loc) · 817 Bytes
/
Script-1.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
USE lab1_week3;
DROP TABLE IF EXISTS blog;
DROP TABLE IF EXISTS author;
CREATE TABLE author (
id INT NOT NULL AUTO_INCREMENT,
author VARCHAR(255),
PRIMARY KEY(id));
CREATE TABLE blog (
blog_title VARCHAR(255) NOT NULL,
word_count INT,
views INT,
author_id INT NOT NULL,
PRIMARY KEY(blog_title),
FOREIGN KEY (author_id) REFERENCES author(id)
);
INSERT INTO author (author) VALUES
('Maria Charlotte'),
('Juan Perez'),
('Gemma Alcocer');
INSERT INTO blog (blog_title, word_count, views, author_id) VALUES
('Best Paint Colors', 814, 14, 1),
('Small Space Decorating Tips', 1146, 221, 2),
('Hot Accessories', 986,105, 1),
('Mixing Textures', 765, 22, 1),
('Kitchen Refresh', 1242, 307, 2),
('Homemade Art Hacks', 1002, 193, 1),
('Refinishing Wood Floors', 1571, 7542, 3);
SELECT * FROM author;
SELECT * FROM blog;