This is a beginners guide to Structured Query Language (SQL) - Not to be confused with MS-SQL (Microsoft SQL Server)
SQL is the Query language used most often when interacting with relational databases.
In this tutorial we will be looking at:
- how to create and design a simple database
- interacting with a relational database using SQL
- what is an ORM and how to use it
- BONUS - caching my data using an in-memory data structure store
We will be creating a simple timesheet app to demonstrate relation data.
Consider the following data to be captured:
- Name
- Surname
- Project
- Date
- Time start
- Time end
- Duration
- Description
- Billable (true/false)
A table structure for that could be...
Name | Surname | Client | Project | Date | Time Started | Time ended | Duration | Description | Billable |
---|---|---|---|---|---|---|---|---|---|
John | Doe | Client X | Website | 2019-01-22 | 09:00 | 11:00 | 120 | I was rocking HTML5 | YES |
John | Doe | Client X | API | 2019-01-22 | 13:00 | 17:00 | 240 | Grafting on golang api | YES |
- Create database and SQL login
- Create and Run Initial migration
- Run Project and connect to SQL Database
- Insert and read some data
- Add Redis connection to project (Example)
- Save some data into Redis
- Read some data from Redis
- Normalize the Data structure
- Create a second migration to change your database into the normalized form
- Implement a "save" to redis on the PUT and POST endpoints
- Implement a try-read from redis on your GET calls (Try to read from redis, if key does not exists read from DB)