Skip to content

Database Design

Shiva Nanda edited this page Aug 24, 2023 · 3 revisions

This page includes the database design changes in GSoC 23 Find the complete design here.

Collections

cl_user

image

  • This collection contains user details.
  • This collection doesnt store a list of followers or people this user is following but just stores the number of followers and following.
  • For the list of people following, we can refer to user_followers collection.

org_users

image

  • This collection resembles to a realation that stores users of an organization with various levels of permissions
  • permissions field: array of permissions that a user has
  • permissions:
    • 0: reviewer
    • 1: editor
    • 2: admin
    • 3: owner

org_subscribers:

image

  • This collection resembles to a relation that stores subscribers of an organization.
  • Fields:
    • org_handle: handle of the organization
    • uid: unique id of the user document

user_folloers

image

  • This collection resembles to a relation that stores users followers and following.
  • Fields (If user1 is following user2, then):
    • followingId: document id of user that is begin followed (user2)
    • followerId: document id of user that is following (user1)

cl_org_general

image

  • This collection has details of an organization
  • This just has contributors count, feed count and so on but not the list of contributors or feed.
  • To get a list of contributors and feed, we can refer org_users collection and tutorials collection respectively.
  • Fields:
    • followerCount: number of subscribers for an organization
    • contributorsCount: number of users with special permission level (look at org_users collection)
    • feedCount: number of tutorials under this organization.

tutorials

image

  • This collection stores all the information about a tutorial
  • This collection has a sub-collection to store steps
  • Each document under steps has some yjs collections that enables collaborative editing and sanitised HTML (content of that step)
  • It has upVotes, downVotes, commentsCount but not the list of users that voted or commented.

tutorial_likes

image

  • This collection stores likes of tutorials.
  • Fields:
    • uid: document id of user that liked a tutorial
    • tut_id: document id of the tutorial that was liked
    • value: 1 = like, -1 = dislike, 0 = no like

comment_likes

image

  • This collection stores likes of comments.
  • Fields:
    • uid: document id of user that liked a comment
    • comment_id: document id of the comment that was liked
    • value: 1 = like, -1 = dislike, 0 = no like

cl_comments

image

  • This collection contains comments of tutorials
  • Fields:
    • replyTo:
      1. If this is comment for tutorial, it stores tut_id
      2. If this is a reply to other comment, it stores document id of that comment
    • upVotes and downVotes are dount of respective votes.