-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinsert-data.sql
More file actions
68 lines (61 loc) · 1.9 KB
/
insert-data.sql
File metadata and controls
68 lines (61 loc) · 1.9 KB
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
-- truncate table comments ;
-- truncate table followers ;
-- truncate table likes ;
-- truncate table posts ;
truncate table users cascade;
ALTER SEQUENCE users_user_id_seq RESTART WITH 1;
ALTER SEQUENCE posts_post_id_seq RESTART WITH 1;
ALTER SEQUENCE likes_like_id_seq RESTART WITH 1;
ALTER SEQUENCE followers_follower_id_seq RESTART WITH 1;
ALTER SEQUENCE comments_comments_id_seq RESTART WITH 1;
-- inserting users data
INSERT INTO users (name, email, phone_no)
VALUES
('John Smith', 'johnsmith@gmail.com', '1234567890'),
('Jane Doe', 'janedoe@yahoo.com', '0987654321'),
('Bob Johnson', 'bjohnson@gmail.com', '1112223333'),
('Alice Brown', 'abrown@yahoo.com', '985432534'),
('Mike Davis', 'mdavis@gmail.com', '5556667777');
-- alter table posts alter column image_url varchar(200);
-- Inserting into Posts table
INSERT INTO Posts (user_id, caption, image_url)
VALUES
(1, 'Beautiful sunset', '<https://www.example.com/sunset.jpg>'),
(2, 'My new puppy', '<https://www.example.com/puppy.jpg>'),
(3, 'Delicious pizza', '<https://www.example.com/pizza.jpg>'),
(4, 'Throwback to my vacation', '<https://www.example.com/vacation.jpg>'),
(5, 'Amazing concert', '<https://www.example.com/concert.jpg>');
-- Inserting into Comments table
INSERT INTO Comments (post_id, user_id, comment_text)
VALUES
(1, 2, 'Wow! Stunning.'),
(1, 3, 'Beautiful colors.'),
(2, 1, 'What a cutie!'),
(2, 4, 'Aww, I want one.'),
(3, 5, 'Yum!'),
(4, 1, 'Looks like an awesome trip.'),
(5, 3, 'Wish I was there!');
-- Inserting into Likes table
INSERT INTO Likes (post_id, user_id)
VALUES
(1, 2),
(1, 4),
(2, 1),
(2, 3),
(3, 5),
(4, 1),
(4, 2),
(4, 3),
(5, 4),
(5, 5);
-- Inserting into Followers table
INSERT INTO Followers (user_id, followers_user_id)
VALUES
(1, 2),
(2, 1),
(1, 3),
(3, 1),
(1, 4),
(4, 1),
(1, 5),
(5, 1);