-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.sql
36 lines (33 loc) · 1.09 KB
/
init.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
-- Create Articles table
CREATE TABLE articles (
id INTEGER PRIMARY KEY AUTOINCREMENT,
title VARCHAR(100),
content TEXT,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
-- Create Comments table
CREATE TABLE comments (
id INTEGER PRIMARY KEY AUTOINCREMENT,
article_id INT,
comment TEXT,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (article_id) REFERENCES articles(id)
);
-- Insert two demo articles
INSERT INTO articles (title, content) VALUES
('First Article', '# First Article\nThis is the first demo article.'),
('Second Article', '# Second Article\nThis is the second demo article.');
-- Insert five comments for each article
INSERT INTO comments (article_id, comment) VALUES
(1, 'Great article!'),
(1, 'Very informative.'),
(1, 'Thanks for sharing.'),
(1, 'Interesting read.'),
(1, 'Looking forward to more articles like this.'),
(2, 'Excellent article!'),
(2, 'Well written.'),
(2, 'Very helpful.'),
(2, 'Good job.'),
(2, 'Keep up the good work.');