๐ŸŒˆ InstagramDB

dev-jjunยท2022๋…„ 12์›” 24์ผ
0

Server

๋ชฉ๋ก ๋ณด๊ธฐ
3/33

๐ŸŽฏ ์š”๊ตฌ์‚ฌํ•ญ ๋ถ„์„

  • ๋งˆ์ดํŽ˜์ด์ง€ - User (๊ฐœ์ธ์ •๋ณด, ํšŒ์›๊ฐ€์ž…, ๋กœ๊ทธ์ธ)
  • ๊ฒŒ์‹œ๋ฌผ - ๊ฒ€์ƒ‰ (User, Post โ† Tag), ํ•ด์‹œํƒœ๊ทธ, ์œ ์ €ํƒœ๊ทธ, ์œ„์น˜ํ‘œ์‹œ, ์ด๋ฏธ์ง€
  • ๋ฉ”์ธํŽ˜์ด์ง€(ํƒ€์ž„๋ผ์ธ์— ๋ณด์—ฌ์งˆ Post)
  • ๋””์—  - ์ฑ„ํŒ…๋ฐฉ ๋ชฉ๋ก(์นด์นด์˜คํ†ก ์ฑ„ํŒ…๋ฐฉ์ด๋ž‘ ์œ ์‚ฌํ•˜๊ฒŒ ๊ด€๋ฆฌ)
  • ์Šคํ† ๋ฆฌ - ์Šคํ† ๋ฆฌ ์–ธ๊ธ‰, ์œ„์น˜ํƒœ๊ทธ, ์‚ฌ์ง„, ๋‚ด์šฉ, ๋ ˆ์ด์•„์›ƒ
  • ์Šคํ† ๋ฆฌ ํ•˜์ด๋ผ์ดํŠธ - ๋งˆ์ดํŽ˜์ด์ง€์—์„œ ๊ด€๋ฆฌ
  • ์•Œ๋ฆผ
  • (๋ฆด์Šค)

ERD ์„ค๊ณ„

User(์‚ฌ์šฉ์ž)

  • userId
  • username (์‹ค๋ช…)
  • nickname (์‚ฌ์šฉ์ž ์•„์ด๋””)
  • password
  • profileImgUrl
  • totalFollower (ํŒ”๋กœ์›Œ ์ˆ˜)
  • totalFollow (ํŒ”๋กœ์šฐ ์ˆ˜)
  • birth (์ƒ๋…„์›”์ผ)
  • website โ†’ null
  • intro โ†’ null
  • email
  • phone
  • gender
  • status (์ƒํƒœ - ํœด๋ฉด/ํƒˆํ‡ด/ํ™œ์„ฑ)

*์ข‹์•„์š”๋ฅผ User ํ…Œ์ด๋ธ”์— ๋„ฃ์–ด๋‘๊ณ  ๊ด€๊ณ„ ๋งคํ•‘์„ ๋‘ ๋ฒˆ ์ด์ƒ์œผ๋กœ ํ•  ๊ฒƒ์ธ๊ฐ€

Media(์‚ฌ์ง„,๋™์˜์ƒ)

  • mediaId
  • mediaUrl (์‚ฌ์ง„, ์˜์ƒ ์›๋ณธ ๋งํฌ)

Story(์Šคํ† ๋ฆฌ)

  • storyId (PK, ์Šคํ† ๋ฆฌ ๋ฒˆํ˜ธ)
  • storyImgUrl (text)
  • content
  • layout
  • isHighlight (ํ•˜์ด๋ผ์ดํŠธ ์—ฌ๋ถ€)
  • placeTag (FK)
  • hashTag (FK)
  • isPrivate (์นœํ•œ์นœ๊ตฌ ๋ชจ๋“œ)
  • createdAt *์ˆ˜์ •์€ ๋ถˆ๊ฐ€๋Šฅํ•˜๋ฏ€๋กœ ํ•„์š”X

Post(๊ฒŒ์‹œ๋ฌผ)

  • postId
  • postImgUrl
  • order
  • content
  • createdAt
  • updatedAt
  • writer (FK, User)

โ†’ ์ข‹์•„์š” ์ˆ˜, ๋Œ“๊ธ€ ์ˆ˜, ํ•ด์‹œํƒœ๊ทธ ์—ฌ๋ถ€, ์œ„์น˜ํƒœ๊ทธ ์—ฌ๋ถ€

DM(์ฑ„ํŒ…)

  • roomId
  • dialog (๋Œ€ํ™”๋‚ด์šฉ) โ†’ ์‚ฌ์ง„, ๋ฌธ์„œ ํŒŒ์ผ ๋“ฑ ๋ชจ๋‘ ๊ด€๋ฆฌ ์–ด๋–ป๊ฒŒ?

โ†’ ๋Œ€ํ™”๋ฐฉ์— ์ฐธ์—ฌ์ค‘์ธ ์œ ์ € ๋ชฉ๋ก, ์ตœ๊ทผ์— ๋„์ฐฉํ•œ ๋ฉ”์‹œ์ง€ (์•Œ๋ฆผ)

์นด์นด์˜คํ†ก ์ฑ„ํŒ…๋ฐฉ ๊ด€๋ฆฌ์™€ ์œ ์‚ฌํ•˜๊ฒŒ
โ†’ ๊ฒŒ์‹œ๋ฌผ ๊ณต์œ , ์‚ฌ์šฉ์ž ํ”„๋กœํ•„ ๊ณต์œ  ๋“ฑ์˜ ๊ธฐ๋Šฅ

PostLike(๊ฒŒ์‹œ๋ฌผ ์ข‹์•„์š”)

  • likeId
  • postId(FK)
  • userId(FK)

PostComment(๊ฒŒ์‹œ๋ฌผ ๋Œ“๊ธ€)

  • commentId
  • content (๋‚ด์šฉ)
  • commentOrder(๋Œ“๊ธ€ ์ˆœ์„œ)
  • isDeleted(์‚ญ์ œ์—ฌ๋ถ€)
  • createdAt
  • updatedAt

๋Œ€๋Œ“๊ธ€๋„ ๊ณ ๋ ค โ†’ ์ž๊ธฐ์ž์‹ ๊ณผ ์ผ๋Œ€์ผ ๊ด€๊ณ„ (๋ถ€๋ชจ๋Œ“๊ธ€๋ฒˆํ˜ธ; parent_comment)

StoryLike(์Šคํ† ๋ฆฌ ์ข‹์•„์š”)

  • likeId
  • postUser(FK)
  • replyUser(FK)

StoryReply(์Šคํ† ๋ฆฌ ๋‹ต๋ณ€)

  • commentId(PK)
  • commentDepth (๋Œ€๋Œ“๊ธ€์˜ ๊ฐœ์ˆ˜ โ†’ ํŠธ๋ฆฌ๊ตฌ์กฐ๋กœ?)
  • StoryEmoji(์Šคํ† ๋ฆฌ ๋ฐ˜์‘)
  • dmId (dm.roomId๋ฅผ FK๋กœ)
  • postUser(FK)
  • replyUser(FK)

Reels(๋ฆด์Šค)

  • reelsId(PK)
  • videoContent โ†’ text(url๋กœ ์ฒ˜๋ฆฌ?)

HashTag(ํ•ด์‹œํƒœ๊ทธ)

  • tagId
  • tagName(ํƒœ๊ทธ๋ช…) โ†’ VARCHAR *๊ธ€์ž์ˆ˜์ œํ•œํ•˜๊ธฐ
  • postId(FK) *๊ฒŒ์‹œ๋ฌผ์—์„œ ํƒœ๊ทธ๋ฅผ ์‚ฌ์šฉํ•œ ๊ฒฝ์šฐ
  • userId(FK) *์‚ฌ์šฉ์ž๊ฐ€ ์Šคํ† ๋ฆฌ์—์„œ ํƒœ๊ทธ๋ฅผ ์‚ฌ์šฉํ•œ ๊ฒฝ์šฐ

PlaceTag(์žฅ์†Œํƒœ๊ทธ)

  • tagId
  • place(์žฅ์†Œ๋ช…)
  • address(์œ„์น˜์ขŒํ‘œ) โ†’ text, null *์‹ค์ œ ์žฅ์†Œ๊ฐ€ ์•„๋‹Œ ๊ฒฝ์šฐ๋„ ์žˆ์Œ
  • postId(FK) *๊ฒŒ์‹œ๋ฌผ์—์„œ ํƒœ๊ทธ๋ฅผ ์‚ฌ์šฉํ•œ ๊ฒฝ์šฐ
  • userId(FK) *์‚ฌ์šฉ์ž๊ฐ€ ์Šคํ† ๋ฆฌ์—์„œ ํƒœ๊ทธ๋ฅผ ์‚ฌ์šฉํ•œ ๊ฒฝ์šฐ

Alert(์•Œ๋ฆผ)

  • alertId(์•Œ๋ฆผ๋ฒˆํ˜ธ)
  • content(๋‚ด์šฉ)
  • alertType(์•Œ๋ฆผ์ข…๋ฅ˜)
  • time(์‹œ๊ฐ„)
  • isChecked(ํ™•์ธ์—ฌ๋ถ€)

UserTag(์œ ์ €ํƒœ๊ทธ)

  • tagId
  • userId

Quick DBD ๋ฅผ ์ด์šฉํ•œ ERD ์„ค๊ณ„

User
-
userId PK int
nickname UNIQUE varchar(20)
password varchar(25)
username varchar(20)  
profileImgUrl text
totalFollower int
totalFollow int
birth varchar(20)
website NULL text
email NULL varchar(50)
phone NULL varchar(30)
gender int
status int

Story
-
storyId PK int
storyImg NULL int FK >-< Media.mediaId
userId int FK >- User.userId
content text
layout NULL int
isPrivate int
isHighLight int
createdAt timestamp
placeTag NULL int FK >- PlaceTag.tagId
hashTag NULL int FK >-< HashTag.tagId
userTag NULL int FK >-< UserTag.tagUser

StoryReply
-
replyId PK int
storyId int FK >- Story.storyId
dmRoom int FK >- DM.roomId
storyEmoji int
postUser int FK >- User.userId
replyUser int FK >- User.userId

StoryHighlight
-
highlightId PK int
thumbnail text
storyId int FK >-< Story.storyId
userId int FK >- User.userId

StoryHeart
- 
userId int FK >- User.userId
storyId int FK >- Story.storyId

Media
-
mediaId PK int
mediaUrl text

Post
- 
postId PK int
postImg int FK >-< Media.mediaId
postImgUrl text
order int
createdAt timestamp
updatedAt timestamp
writer int FK >- User.userId
placeTag NULL varchar(50) FK >- PlaceTag.tagId
hashTag NULL varchar(50) FK >-< HashTag.tagId
userTag NULL int FK >-< UserTag.tagUser
totalLikes int
totalComments int

PostLike
- 
postId int FK >- Post.postId
userId int FK >- User.userId

PostComment
-
commentId PK int
content text
commentOrder int
commentDepth int
isDeleted int
createdAt timestamp
updatedAt timestamp
writer int FK >- User.userId

PostCommentLike
-
postId int FK >- Post.postId
userId int FK >- User.userId

DM
- 
roomId PK int
dialog text
chatUser int FK >-< User.userId

HashTag
- 
tagId PK int
tagName UNIQUE varchar(50)

PlaceTag
-
tagId PK int
place varchar(50)
address NULL text

UserTag
-
userId int FK - User.userId
tagUser int FK >- User.userId

Alert
-
alertId PK int
content varchar(50)
alertType int
time timestamp
isChecked int
userId int FK >- User.userId

Reels
-
reelsId PK int
writer FK >- User.userId
videoContent text

Query๋ฌธ ์ž‘์„ฑํ•˜๊ธฐ

์„œ๋น„์Šค ์ฃผ์š” ๊ธฐ๋Šฅ

  1. ๋กœ๊ทธ์ธ
  2. ๋งˆ์ดํŽ˜์ด์ง€ (๋‚ด ํ”„๋กœํ•„ ๋ณด๊ธฐ)
  3. ๊ฒŒ์‹œ๋ฌผ ์ข‹์•„์š” ๊ฐœ์ˆ˜ ์กฐํšŒ
  4. ๊ฒŒ์‹œ๋ฌผ ์ข‹์•„์š” ๋ชฉ๋ก ์กฐํšŒ
  5. ๊ฒŒ์‹œ๋ฌผ ์œ„์น˜ ์กฐํšŒ (์œ„์น˜ํƒœ๊ทธ)
  6. ๊ฒŒ์‹œ๋ฌผ ์ž‘์„ฑ / ์Šคํ† ๋ฆฌ ์ž‘์„ฑ
  7. ๊ฒŒ์‹œ๋ฌผ ์ˆ˜์ • / ์Šคํ† ๋ฆฌ ์ˆ˜์ •
  8. ๊ฒŒ์‹œ๋ฌผ ์‚ญ์ œ / ์Šคํ† ๋ฆฌ ์‚ญ์ œ
  9. ํ•ด์‹œํƒœ๊ทธ ๊ฒ€์ƒ‰ํ•˜๊ธฐ
  10. ์ž์‹ ์ด ํƒœ๊ทธ๋œ ๊ฒŒ์‹œ๋ฌผ ์กฐํšŒ
  11. ๊ฒŒ์‹œ๋ฌผ ์—…๋กœ๋“œ ์‹œ๊ฐ„ ์กฐํšŒ
  12. ์Šคํ† ๋ฆฌ ํ•˜์ด๋ผ์ดํŠธ ๋ชฉ๋ก ์กฐํšŒ

๋”๋ฏธ๋ฐ์ดํ„ฐ ์ƒ์„ฑ

User

desc User;
INSERT INTO User(userId, nickname, password, username, profileImgUrl, totalFollower, totalFollow, birth, website, email, phone, gender, status)
VALUES(NULL, "abc_def", "1234567", "๋„๋ ˆ๋ฏธ", "url", 0, 0, "2000๋…„ 1์›” 1์ผ", NULL, NULL, "010-1234-5678", 0, 0); 
INSERT INTO User(userId, nickname, password, username, profileImgUrl, totalFollower, totalFollow, birth, website, email, phone, gender, status)
VALUES(NULL, "jj_qwe", "1234567", "์•ˆ๋…•", "url", 0, 0, "2000๋…„ 1์›” 1์ผ", NULL, NULL, "010-1234-5678", 0, 0); 
INSERT INTO User(userId, nickname, password, username, profileImgUrl, totalFollower, totalFollow, birth, website, email, phone, gender, status)
VALUES(NULL, "ccc_gf", "1234567", "ํ–‰๋ณตํ•ด", "url", 0, 0, "2000๋…„ 1์›” 1์ผ", NULL, NULL, "010-1234-5678", 0, 0); 

Post

desc Post;
INSERT INTO Post(postId, postImg, postImgUrl, createdAt, updatedAt, writer, placeTag, hashTag, userTag, totalLikes, totalComments)
VALUES(NULL, 1, "img_link", now(), now(), 1, NULL, NULL, NULL, 0, 0);
INSERT INTO Post(postId, postImg, postImgUrl, createdAt, updatedAt, writer, placeTag, hashTag, userTag, totalLikes, totalComments)
VALUES(NULL, 1, "img_link2", now(), now(), 1, NULL, NULL, NULL, 0, 0);
INSERT INTO Post(postId, postImg, postImgUrl, createdAt, updatedAt, writer, placeTag, hashTag, userTag, totalLikes, totalComments)
VALUES(NULL, 1, "img_link3", now(), now(), 3, NULL, NULL, 1, 0, 0);
  • Post3 - User1์ด ์ž‘์„ฑ
  • Post4 - User1์ด ์ž‘์„ฑ
  • Post5 - User3์ด ์ž‘์„ฑ + User1 ํƒœ๊ทธ
DELIMITER $$
DROP PROCEDURE IF EXISTS loopInsert$$

CREATE PROCEDURE loopInsert()
BEGIN
    DECLARE i INT DEFAULT 1;

    WHILE i <= 500 DO
        INSERT INTO Post (postId, postImg, postImgUrl, createdAt, updatedAt, writer, placeTag, hashTag, userTag, totalLikes, totalComments)
          VALUES(NULL, 1, concat('image',i), now(), now(), 1, NULL, NULL, NULL, 0, 0);
        SET i = i + 1;
    END WHILE;
END$$
DELIMITER $$

CALL loopInsert;

Story

desc Story;
INSERT INTO Story(storyId, storyImg, userId, content, layout, isPrivate, isHighLight, createdAt, placeTag, hashTag, userTag) 
VALUES (NULL, 1, 1, "Hello!", NULL, 0, 0, now(), 1, NULL, NULL);
INSERT INTO Story(storyId, storyImg, userId, content, layout, isPrivate, isHighLight, createdAt, placeTag, hashTag, userTag) 
VALUES (NULL, 1, 2, "Hello!", NULL, 0, 0, now(), 1, NULL, 1);
INSERT INTO Story(storyId, storyImg, userId, content, layout, isPrivate, isHighLight, createdAt, placeTag, hashTag, userTag) 
VALUES (NULL, 1, 2, "Hello!", NULL, 0, 0, now(), 1, NULL, 1);
  • Story1 - User1์ด ์ž‘์„ฑ
  • Story2 - User2์ด ์ž‘์„ฑ
  • Story3 - User2์ด ์ž‘์„ฑ

HashTag

desc HashTag;
INSERT INTO HashTag (tagId, tagName)
VALUES (NULL, "#ํ•ด์‹œํƒœ๊ทธ")
INSERT INTO HashTag (tagId, tagName)
VALUES (NULL, "#ํ…Œ์ŠคํŠธ")

UserTag

desc UserTag;
INSERT INTO UserTag(userId, tagUser)
VALUES(3, 1);

Media

desc Media;
INSERT INTO Media(mediaId, mediaUrl)
VALUES(1, "https://www.naver.com");

PostLike

desc PostLike;
INSERT INTO PostLike(postId, userId)
VALUES (3, 1);
INSERT INTO PostLike(postId, userId)
VALUES (3, 2);
INSERT INTO PostLike(postId, userId)
VALUES (3, 3);
INSERT INTO PostLike(postId, userId)
VALUES (4, 1);
  • User1์ด Post3์„ ์ข‹์•„ํ•จ
  • User2์ด Post3์„ ์ข‹์•„ํ•จ
  • User3์ด Post3์„ ์ข‹์•„ํ•จ
  • User1์ด Post4์„ ์ข‹์•„ํ•จ

*์ข‹์•„์š” ์ˆœ์œผ๋กœ ๊ฒŒ์‹œ๋ฌผ ์ •๋ ฌํ•ด๋ณด๊ธฐ

PlaceTag

INSERT INTO PlaceTag(tagId, place, address)
VALUES (NULL, "์„œ์šธ์‹œ(Seoul)", "์šฉ์‚ฐ๊ตฌ ํ•œ๋‚จ๋™");

StoryHighlight

desc StoryHighlight

์ฟผ๋ฆฌ๋ฌธ

  1. ๋กœ๊ทธ์ธ ์„ฑ๊ณต ์‹œ ์œ ์ € ๋งˆ์ดํŽ˜์ด์ง€๋กœ ๋„˜์–ด์˜ค๊ธฐ

    # ์‹ค์ œ ์„œ๋น„์Šค์—์„œ๋Š” ๋‹‰๋„ค์ž„, ์ „ํ™”๋ฒˆํ˜ธ, ์ด๋ฉ”์ผ์ฃผ์†Œ ๋ชจ๋‘ ๋กœ๊ทธ์ธ ์‹œ ์•„์ด๋””๋กœ ์‚ฌ์šฉ๊ฐ€๋Šฅํ•˜๋‹ค.
    # ์•„์ด๋””์™€ ๋น„๋ฐ€๋ฒˆํ˜ธ์™€ ๋ชจ๋‘ ์ผ์น˜ํ•œ๋‹ค๋ฉด ๋กœ๊ทธ์ธ ์„ฑ๊ณต์œผ๋กœ ์ฒ˜๋ฆฌํ•˜๊ณ  ๋งˆ์ดํŽ˜์ด์ง€๋กœ ๋„˜์–ด๊ฐ„๋‹ค.
    SELECT nickname, username, profileImgUrl, totalFollower, totalFollow 
    FROM User
    WHERE (nickname='abc_def' OR phone='010-6410-6452' OR email=?) AND password='1234567';

    Untitled

  2. ๊ฒŒ์‹œ๋ฌผ ์ข‹์•„์š” ๋ชฉ๋ก ์กฐํšŒ - Post3์˜ ์ข‹์•„์š” ๋ชฉ๋ก์„ ์กฐํšŒํ•˜๊ณ  totalLikes๋ฅผ 1์ฆ๊ฐ€์‹œํ‚จ๋‹ค.

    # where๋ฌธ์œผ๋กœ Post3์˜ ์ข‹์•„์š” ๋ชฉ๋ก์„ ์กฐํšŒํ•œ๋‹ค.
    SELECT *
    FROM Post LEFT OUTER JOIN PostLike
    ON Post.postId = PostLike.postId
    WHERE Post.postId=3;
  3. ๊ฒŒ์‹œ๋ฌผ ์ข‹์•„์š” ๊ฐœ์ˆ˜ ์กฐํšŒ - Post3์˜ ์ข‹์•„์š” ๊ฐœ์ˆ˜๋ฅผ ์กฐํšŒํ•˜๊ณ  Post์˜ totalLikes ํ•„๋“œ ๊ฐ’์„ ์ˆ˜์ •ํ•œ๋‹ค.

    # ์ง‘๊ณ„ํ•จ์ˆ˜๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๊ฒŒ์‹œ๋ฌผ์˜ ์ข‹์•„์š” ๊ฐœ์ˆ˜๋ฅผ ๊ตฌํ•œ๋‹ค.
    # Post์˜ ์ข‹์•„์š” ๊ฐœ์ˆ˜์ธ totalLikes๋ฅผ ๋ชฉ๋ก ๊ฐœ์ˆ˜๋กœ ์„ค์ •ํ•œ๋‹ค.
    SELECT COUNT(*)
    FROM Post LEFT OUTER JOIN PostLike
    ON Post.postId = PostLike.postId
    WHERE Post.postId=3;
  4. ๊ฒŒ์‹œ๋ฌผ ์œ„์น˜ ์กฐํšŒ

    SELECT place, address, postId FROM Post
    RIGHT OUTER JOIN PlaceTag
    ON Post.placeTag = PlaceTag.tagId
    WHERE Post.postId=3;
  5. ๊ฒŒ์‹œ๋ฌผ / ์Šคํ† ๋ฆฌ ์ˆ˜์ • - ๊ฒŒ์‹œ๋ฌผ์—์„œ ํ•ด์‹œํƒœ๊ทธ๋ฅผ ์ถ”๊ฐ€ํ•œ๋‹ค.

    UPDATE Post SET HashTag=1
    WHERE Post.postId=?;
  6. ๊ฒŒ์‹œ๋ฌผ / ์Šคํ† ๋ฆฌ ์‚ญ์ œ - ๋” ๋‚˜์ค‘์—(์ตœ๊ทผ์—) ์˜ฌ๋ฆฐ ์Šคํ† ๋ฆฌ๋ถ€ํ„ฐ ์‚ญ์ œํ•  ์ˆ˜ ์žˆ๋‹ค.

    # 2๊ฐœ์˜ ์Šคํ† ๋ฆฌ๋ฅผ ๊ฒŒ์‹œํ•œ ์‚ฌ์šฉ์ž2๊ฐ€ ์ตœ๊ทผ์— ์—…๋กœ๋“œํ•œ ์Šคํ† ๋ฆฌ๋ฅผ ์‚ญ์ œํ•œ๋‹ค.
    DELETE FROM Story
    WHERE Story.userId=2
    ORDER BY createdAt DESC LIMIT 1;   # ๋‚ด๋ฆผ์ฐจ์ˆœ ์ •๋ ฌ ํ›„ ๊ฐ€์žฅ ์œ„์— ์œ„์น˜ํ•œ ๋ ˆ์ฝ”๋“œ๋ฅผ ์‚ญ์ œ
  7. ํ•ด์‹œํƒœ๊ทธ๋กœ ๊ฒŒ์‹œ๋ฌผ ๊ฒ€์ƒ‰ํ•˜๊ธฐ (โ€#ํ…Œ์ŠคํŠธโ€๋ผ๋Š” ํƒœ๊ทธ๊ฐ€ ์žˆ๋Š” ๊ฒŒ์‹œ๋ฌผ ๋ชฉ๋ก ์กฐํšŒ)

    SELECT postId, postImg, postImgUrl, tagName from Post
    LEFT OUTER JOIN HashTag
    ON Post.hashTag = HashTag.tagId
    WHERE HashTag.tagId=2
  8. ์ž์‹ ์ด ํƒœ๊ทธ๋œ ๊ฒŒ์‹œ๋ฌผ ์กฐํšŒ

    SELECT postId, postImg, postImgUrl, userTag from Post
    LEFT OUTER JOIN UserTag
    ON Post.userTag = UserTag.tagUser AND Post.writer != UserTag.userId
    WHERE Post.writer = 3
  9. ๊ฒŒ์‹œ๋ฌผ ์—…๋กœ๋“œ ์‹œ๊ฐ„ ์กฐํšŒ

    # ์‚ฌ์šฉ์ž1์ด ์ž‘์„ฑํ•œ ๊ฒŒ์‹œ๋ฌผ์˜ ์—…๋กœ๋“œ ์‹œ๊ฐ„ ๋ชฉ๋ก ์กฐํšŒ
    SELECT postId, createdAt from Post
    LEFT OUTER JOIN User
    ON Post.writer = User.userId
    WHERE User.userId=1
  10. ์Šคํ† ๋ฆฌ ํ•˜์ด๋ผ์ดํŠธ ๋ชฉ๋ก ์กฐํšŒ

    # ์‚ฌ์šฉ์ž1์˜ ํ•˜์ด๋ผ์ดํŠธ ๋ชฉ๋ก์— ์Šคํ† ๋ฆฌ1,2,3์ด ์žˆ๋Š” ๊ฒฝ์šฐ
    
profile
์„œ๋ฒ„ ๊ฐœ๋ฐœ์ž๋ฅผ ๊ฟˆ๊พธ๋ฉฐ ์„ฑ์žฅํ•˜๋Š” ์ญŒ์ž…๋‹ˆ๋‹ค ๐Ÿ˜ฝ

0๊ฐœ์˜ ๋Œ“๊ธ€