데이터 모델 대략적인 정리 - 3jins/blog-renewal GitHub Wiki

이건 문서는 아니고, 바로 코드에 반영할 시간은 없는데 생각나는 부분 있으면 여기에다가 추가해놓고 추후 반영하려고 함. 초안 기준으로 작성돼있기 때문에 나중에 코드랑 비교해서 맞게 업데이트 필요.

Member

{
  id: uuid,
  member_no: number,
  auth_token: string,
  name: string,
  role_level: number
}
  • role_level:
    • 0: blog master
    • 1: blog admin (may not be implemented)
    • 2~9: reserved
    • 10: authorized (commit days >= 20 || accepted by admin)
    • 11: ordinary (commit days < 20 || not accepted by admin)
  • 네아로
    • 기본적으로 로그인은 깃허브 계정으로 하는 것을 권장하며, 개발자가 아니라서 깃허브 계정이 없는 경우(부모님 등)를 위해 존재.
    • 따라서 네아로 버튼은 숨겨야 함. "GitHub 계정이 없으신가요?" 와 같은 링크를 통해서 접근 가능하도록.
    • 깃허브 로그인시에는 커밋 일수만 채워져 있으면 바로 활동 승인 상태가 되지만, 네아로시에는 무조건 관리자 승인이 있어야만 활동 가능.

Post

{
  id: uuid,
  post_no: number,
  title: string,
  content: string,
  thumbnail_content: string,
  updated_record_list: Array<{post_id: uuid, updated_date: Date}>,
  last_updated_date: Date,
  is_last_updated_version: boolean, 
  is_rough_sketch: boolean,
}
  • id vs postNo
    • id: post의 각 히스토리에 대한 고유값
    • postNo: 모든 히스토리를 총괄해서 그 post 자체에 대한 고유값

PostMeta

{
  id: uuid,
  ref_post_no: number,
  ref_category_no: number,
  ref_tag_no_list: number[],
  ref_series_no: number,
  created_date: Date,
  last_assurance_date: Date,
  comment_count: integer,
}
  • 히스토리에 상관없이 전체 Post를 관통하여 동일하게 적용되는 데이터들.
  • Batch job for synchronizing post.comment_count and count(comment) is necessary.
  • last_assurance_date:
    • 이 일자를 기준으로 시간이 오래 지나면 deprecated 경고를 보여줄 예정.
    • 관리자는 deprecated 경고가 보이는 글에 대해서 UI 상에서 간단하게 이 필드를 현재 일자로 업데이트하여 시간이 지났어도 여전히 유효한 글임을 보증할 수 있게 하면 좋을 것 같음.
      • 실수로 업데이트 하거나 대충 읽고 잘못 업데이트 했다가 며칠 뒤에 깨닫는 경우에 대한 롤백 플랜도 생각해봐야 할 듯.
        • Meta에 넣지 않고 Post에 넣어서 추가하는 형태가 되면 되긴 함.
        • 그게 과하다면, 타입을 Date[]으로 받아서 스택 형식으로 처리하는 방법도 가능.

Category

{
  id: uuid,
  category_no: number,
  ref_parent_category_no: number,
  name: string
}
  • Category has a tree structure.
  • Number of categories wouldn't be big enough (less than 1000), so direction of reference is single-directed.

Tag

{
  id: uuid,
  tag_no: number,
  name: string,
  ref_post_no_list: Array<number>
}

Series

{
  id: uuid,
  series_no: number,
  name: string
}

Comment

{
  id: uuid,
  comment_no: number,
  ref_post_no: number,
  ref_comment_no: number,
  ref_member_no: number,
  is_post_author: boolean,
  content: string
}
  • comment_no: Comments in each post has its own numbering system.
  • ref_comment_no:
    • If comment B is a reply for comment A, ref_comment_no of B is comment_no of A.
    • If comment A doesn't refer any other comments, ref_comment_no of A is null.
  • Indexing might be helpful for performance.
    db.collection.createIndex({ ref_post_no: 1, comment_no: -1 })
    db.collection.find({ref_post_no: 111, ref_comment_no: null}).sort({comment_no: -1})
    db.collection.createIndex({ ref_comment_no: -1, comment_no: -1 })
    db.collection.find({ref_comment_no: 222}).sort({comment_no: -1})
    
    • Find out how to test if indexing is working well.
⚠️ **GitHub.com Fallback** ⚠️