Database design

In this section, we are going to look at the database design. We are going to have three collections; namely, user, thread and message. Any visitor to our forum will be able to view the threads and replies. But they cannot post a reply or create a thread or like a reply/thread till they log in. The user collection will have the following schema:

  • Name: User's full name.
  • Email: User's email address.
  • Password: User's login password.
  • Role: Will have two values, user and admin. The default value is user.

The thread collection will have the following schema:

  • Title: The title of the thread.
  • Description: The description of the thread.
  • Tags: The searchable tags for the thread.
  • Is Pinned: The boolean values that pins this thread on top of other threads. Default is false.
  • Likes: The number of likes on this thread. Default zero.
  • Created By: The MongoDB Object ID of the user who has created this thread.
  • Created At: The time at which the record was created.
  • Last Update By: The MongoDB Object ID of the user who has updated this thread.
  • Last Update At: The time at which the record was updated.

The message collection will have the following schema:

  • Thread: The MongoDB Object ID of the thread to which this message belongs to.
  • Description: The message contents.
  • Likes: The number of likes on this thread. Default zero.
  • Created By: The MongoDB Object ID of the user who has created this message.
  • Created At: The time at which the record was created
  • Last Update By: The MongoDB Object ID of the user who has updated this message.
  • Last Update At: The time at which the record was updated.

We will be updating the message schema as we keep working with various Google Cloud AI services. This concludes the database schema walk-through. In the next section, we are going to look at the APIs exposed by SmartExchange app.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.47.218