Social Media CASE STUDY using SQL

 DROP TABLE IF EXISTS users;

DROP TABLE IF EXISTS posts;


CREATE TABLE users (

    user_id INT PRIMARY KEY,

    first_name VARCHAR(50),

    last_name VARCHAR(50),

    join_date DATE

);


CREATE TABLE posts (

    post_id INT PRIMARY KEY,

    user_id INT,

    content TEXT,

    creation_time DATETIME 

);


INSERT INTO users (user_id, first_name, last_name, join_date) VALUES

(1, 'Alice', 'Smith', '2021-01-10'),

(2, 'Bob', 'Johnson', '2021-02-15'),

(3, 'Carol', 'Williams', '2021-03-20'),

(4, 'David', 'Brown', '2021-04-25'),

(5, 'Eve', 'Davis', '2021-05-30'),

(6, 'Frank', 'Miller', '2021-06-15'),

(7, 'Rob', 'David', '2021-08-15');



INSERT INTO posts (post_id, user_id, content, creation_time) VALUES

(1, 1, 'Excited to join SocialSphere!', '2021-01-11 08:30:00'),

(2, 2, 'Beautiful day for a walk!', '2021-02-16 09:45:00'),

(3, 1, 'Loving the new features!', '2021-01-12 10:00:00'),

(4, 3, 'Check out my new blog post!', '2021-03-21 14:20:00'),

(5, 2, 'Had a great time at the concert last night!', '2021-02-20 23:00:00'),

(6, 5, 'Just finished a 10k run!', '2021-05-31 07:30:00'),

(7, 6, 'Anyone up for a movie night?', '2021-06-16 19:45:00'),

(8, 4, 'Happy to be part of this community!', '2021-04-26 12:00:00');



 SELECT * from posts

  SELECT * from users

Comments

Popular posts from this blog

50 Essential SQL Questions to Land Your Dream Job

How to find all the customers who placed orders on three consecutive days | SQL Scenario questions

ACCENTURE SQL INTERVIEW QUESTION | Change the ProductIDs