After all setup, we are in the stage of data modeling where I have to define the schema of the data I am going to use in my web app.
- Code Pasting using Code mirror
- Making snippets private
- Adding search page with a random snippet option
Upcoming features include starring someone's code snippet and adding a count of the number of views of that snippet.
These many features will require me to add several tables:-
- One table to store users data
- One for tags
- And the last one for codes
One basic rule you must follow is-
Never put same string data twice. Use relationship instead.
This means if you are using this table named 'cities_info'
here 'Tamil Nadu' is coming twice which is not good for our database. Thus there should be another table storing all the states
and then a foreign key will be added in the table 'cities_info' instead of a State column. So the resulting table 'cities_info' will be
In this integers are repeating but that's not the problem. The problem is with repeating strings.
In my case, the tables and their relationship are as follows:-
These tables satisfied all the functionalities of my web app like storing code snippets in the code table, the language in language table and tags in the tag table.
One interesting table is tag_code which is a perfect example of the basic rule I discussed earlier.
Next post, is going to be about hasura data API and postman collection for querying them.
Here is the index of all the post regarding this series of snipcode developemnt
Part I: App Idea
Part II: App prototype
Part III: Local Development
Part IV: G for Git
Part V: Data Modeling
Part VI: Data & Auth APIs
Part VII: Basic Functionalities
Part VIII: App Screen 1
Part IX: App Screen 2
Part X: App Screen 3
Part XI: User Reviews
Part X: Final Submission