ajoliat23 / blockBook

0 stars 0 forks source link

Proposed MySQL schema and potential queries for like and comment retrieval #22

Closed E0MCH1NA closed 1 year ago

E0MCH1NA commented 1 year ago

Proposed changes

These proposed changes create the schema for the MySQL database that we will hope to leverage in order to store our post relevant information. Along with the schema I have added in a few potential queries that can be called via command line in order to retrieve necessary data in the future.

These changes are all new feature based so there is no interference with the code that is already present in main.

I have run this through a MySQL linter and was greeted with no apparent syntax errors in terms of the database schema.

In terms of describing the schema of the database, it is relatively simple in design. There is a main table that houses necessary information regarding the post itself. Starting with such things as the author, topic, content, and timestamp. Using an auto incrementing primary key of post_id we will be able to select and then reference posts easily in the two other tables which utilize a foreign key which references this post_id. The two other main tables will store all likes that have been made to posts and the other will house all made comments.

With the latter of the two tables a discussion needs to be had on how we want to concatenate all comments onto a post and also tally of of the made likes. I have addressed this issue with potential queries that can be executed via command line in order to retrieve the total likes on a post along with a list of all comments on a post based upon the use of the primary key of post_id.