-
Notifications
You must be signed in to change notification settings - Fork 0
/
blog_app.sql
48 lines (42 loc) · 1.73 KB
/
blog_app.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
37
38
39
40
41
42
43
44
45
46
47
48
-- Create the users table
CREATE TABLE users (
id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
username VARCHAR(45) NOT NULL,
email VARCHAR(255) NOT NULL,
password VARCHAR(255) NOT NULL,
img VARCHAR(255)
);
-- Create the posts table
CREATE TABLE posts (
id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
title VARCHAR(500) NOT NULL,
`desc` VARCHAR(5000) NOT NULL,
img VARCHAR(255) NOT NULL,
date DATETIME,
category VARCHAR(45) NOT NULL,
uid INT NOT NULL,
FOREIGN KEY (uid) REFERENCES users(id)
);
-- Create the drafts table
CREATE TABLE drafts (
id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
title VARCHAR(500),
`desc` VARCHAR(5000),
img VARCHAR(255),
category VARCHAR(45),
uid INT NOT NULL,
FOREIGN KEY (uid) REFERENCES users(id)
);
-- Add some dummy data to the users table
INSERT INTO users (username, email, password) VALUES
('john_doe', '[email protected]', 'password123'),
('jane_doe', '[email protected]', 'password456');
-- Add some dummy data to the posts table ( Note: make sure to add valid img links in the img column )
INSERT INTO posts (title, description, img, date, category, uid) VALUES
('First Post', 'This is the description of the first post.', 'post1.jpg', NOW(), 'Category1', 1),
('Second Post', 'This is the description of the second post.', 'post2.jpg', NOW(), 'Category2', 2);
-- Add some dummy data to the drafts table ( Note: make sure to add valid img links in the img column )
INSERT INTO drafts (title, description, img, category, uid) VALUES
('Draft Post 1', 'This is the description of the first draft.', 'draft1.jpg', 'Category1', 1),
('Draft Post 2', 'This is the description of the second draft.', 'draft2.jpg', 'Category2', 2);
-- Adjust the dummy data as needed.