Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
d7b0e00
Scaffolding of backend - db - week 2/3
marcorichetta May 27, 2025
b4a1ae2
Merge branch 'main' into 6-database-backend-content-update
marcorichetta May 27, 2025
92cb4c5
Merge branch 'main' into 6-database-backend-content-update
marcorichetta Jul 5, 2025
9924de3
Rename weeks modules and format them to match the template
marcorichetta Jul 5, 2025
c3c811b
update week 1 session goals
marcorichetta Jul 8, 2025
0886edb
match template format
marcorichetta Jul 8, 2025
eaaf34b
add todo for session content
marcorichetta Jul 8, 2025
667b8d6
update week 2 learning goals and main topics
marcorichetta Jul 8, 2025
9d8ef42
format according to template + fixing links
marcorichetta Jul 8, 2025
0ec4714
update preparation.md with video for an example on SQL Injection and …
marcorichetta Jul 9, 2025
1ba77bc
include comment on using a tool other than dbeaver
marcorichetta Jul 23, 2025
c8c810d
add session plan for DB week1
marcorichetta Jul 24, 2025
c675b08
Merge branch 'main' into 6-database-backend-content-update
marcorichetta Jul 24, 2025
c9dc685
update preparation requirements and material
marcorichetta Jul 25, 2025
f85018b
small fixes to learning goals
marcorichetta Jul 25, 2025
6f7c648
refactor assignment: modified the legacy content + adapted it to work…
marcorichetta Jul 25, 2025
d0c9616
lint:fix
marcorichetta Jul 25, 2025
f16bfec
use mariadb.com resources for reading list - much cleaner and stick t…
marcorichetta Jul 25, 2025
a8666a6
add mariadb resources for preparation
marcorichetta Jul 28, 2025
9dbcc07
make the session goals more practical
marcorichetta Jul 28, 2025
4db3a43
create session plan based on learning goals, focusing on using the sa…
marcorichetta Jul 28, 2025
4c2980d
add sample api to work through the session-plan
marcorichetta Jul 28, 2025
bb66937
assignment todo
marcorichetta Jul 28, 2025
0d4eeca
`./lint --fix`
marcorichetta Jul 28, 2025
e8293a6
refine module learning goals + add prerequisites
marcorichetta Jul 30, 2025
33d31fd
correct some more content based on Adam's feedback
marcorichetta Jul 30, 2025
e304340
move example-api to correct directory
marcorichetta Jul 30, 2025
de008a9
update database filename and directory
marcorichetta Jul 30, 2025
ea5c0f6
rename tasks/db to tasks.sqlite3 for consistency
marcorichetta Aug 4, 2025
13ffef1
set package type to avoid warning when running `npm run dev`
marcorichetta Aug 4, 2025
5d29b51
improve setup notes
marcorichetta Aug 4, 2025
111d763
improve aggregate functions wording
marcorichetta Aug 4, 2025
16d7347
reorganize transactions content
marcorichetta Aug 4, 2025
c99af40
refine database types section + add summary
marcorichetta Aug 4, 2025
941967e
add exercise for sql injection
marcorichetta Aug 4, 2025
178d620
change ORM queries to parameterized ones
marcorichetta Aug 4, 2025
6a97fc8
add interactivity to the ERD demo
marcorichetta Aug 4, 2025
6f34dca
fix: clarify difference between CRUD goal on week 1
marcorichetta Aug 20, 2025
ed23a89
refactor: clarify session structure and add more incremental exercises
marcorichetta Aug 21, 2025
d75d4ed
refactor: improve the join explanation to be more incremental
marcorichetta Aug 21, 2025
41542d3
refactor: small fixes
marcorichetta Aug 21, 2025
0e0b12b
fix: remove ids to avoid duplicate id constraint and use autoincrement
marcorichetta Aug 21, 2025
ff6deb2
feat: add sample db with complete data from class. Also useful for as…
marcorichetta Aug 21, 2025
fb1c363
refactor: minimal fixes to the session plan
marcorichetta Aug 21, 2025
0157bec
refactor: improve description, add tips and replace mysql for sqlite …
marcorichetta Aug 21, 2025
5b90cfa
feat: add aggregate fns and more transaction resources
marcorichetta Aug 21, 2025
19ba9fd
refactor: remove transactions from session plan
marcorichetta Aug 21, 2025
25ec446
./lint --fix
marcorichetta Aug 21, 2025
1718c02
Merge branch 'main' into 6-database-backend-content-update
marcorichetta Aug 21, 2025
3202c98
./lint --fix
marcorichetta Aug 21, 2025
203e207
fix: move course from Backend -> backend
marcorichetta Aug 21, 2025
110d1a9
feat: add html elements to use collapsible sections
marcorichetta Aug 22, 2025
9481d9a
./lint --fix
marcorichetta Aug 22, 2025
116a453
fix: add clearer setup instructions for mentor and trainees
marcorichetta Oct 7, 2025
b3d11c1
feat: add section on database deployments: concepts, the why and setup
marcorichetta Oct 14, 2025
18a65a0
fix: move example-api to the assignment repo and update instructions
marcorichetta Oct 14, 2025
6e89b4c
small clarification
marcorichetta Oct 14, 2025
8c3e734
Merge branch 'main' into 6-database-backend-content-update
marcorichetta Oct 14, 2025
defbc3b
remove example api
marcorichetta Oct 14, 2025
198198e
fix lint errors
marcorichetta Oct 14, 2025
c9b5c5f
fix invalid links
marcorichetta Oct 14, 2025
3c9cb05
Added directory structure for gitbook
adamblanchard Oct 14, 2025
b0187b0
updated language from school like terms
adamblanchard Oct 14, 2025
886b4dc
another student replacement
adamblanchard Oct 14, 2025
bad5606
Improved wording of the cloud header
adamblanchard Oct 28, 2025
cb86a64
Removed sqlite3 file but give clear insturctions to mentor to recreat…
adamblanchard Oct 28, 2025
658aaa2
add clearer instructions where the trainee should create the database…
adamblanchard Oct 28, 2025
15be2c5
clarify that the assignment is built ontop of the working solution fr…
adamblanchard Oct 28, 2025
806e02d
tidy up session plan week 2
adamblanchard Oct 28, 2025
b915463
Fixed broken reference to sample data
adamblanchard Oct 28, 2025
01b0df0
fixed broken link on gitbook
adamblanchard Oct 28, 2025
62fcbce
actually fixed gitbook link
adamblanchard Oct 28, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 24 additions & 4 deletions courses/Backend/databases/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,28 @@
# Databases

TODO
This module is part of the Backend specialism course and goes deep on databases, including SQL topics like CRUD, relationships and other advanced concepts. It should also covers security and NoSQL on a theoretical level # TODO

Lesson1 is already been covered in foundation. These is the remaining content:
## Contents

Week 1: [legacy lesson2](../../../legacy/databases/lesson2/)
Week 2: [legacy lesson3](../../../legacy/databases/lesson3/)
| Week | Topic | Preparation | Lesson Plan | Assignment |
| ---- | ------------------------------------ | ------------------------------------- | ----------------------------------------------------- | ----------------------------------- |
| 1. | [Introduction to Databases, Week 2](./week1/README.md) | [Preparation](./week1/preparation.md) | [Session Plan](./week1/session-plan.md) (for mentors) | [Assignment](./week1/assignment.md) |
| 2. | [# TODO - Review this content](./week2/README.md) | [Preparation](./week2/preparation.md) | [Session Plan](./week2/session-plan.md) (for mentors) | [Assignment](./week2/assignment.md) |

## Module Learning Goals

By the end of this module, you will be able to:

- [ ] Explain the purpose of databases in web applications
- [ ] Perform basic CRUD operations using SQL
- [ ] Understand and implement relationships between tables in SQL
- [ ] Write SQL queries involving joins and aggregations
- [ ] Describe the differences between SQL and NoSQL databases
- [ ] Performance?
- [ ] Security?

## Prerequisites

You should have completed or understand the learning goals in the following modules before proceeding:

- [ ] ?
37 changes: 37 additions & 0 deletions courses/Backend/databases/week1/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Introduction to Databases, Week 2

This session is about building CRUD functionality using SQL statements and understanding database relationships.

## Contents

- [Preparation](./preparation.md)
- [Session Plan](./session-plan.md) (for mentors)
- [Assignment](./assignment.md)

## Session Learning Goals

By the end of this session, you will be able to:

- [ ] Build CRUD functionality using SQL statements (INSERT INTO, UPDATE, DELETE)
- [ ] Create an entity relationship diagram from a qualitative description of data requirements
- [ ] Translate an entity relationship diagram into a database schema
- [ ] Use simple foreign keys and join tables
- [ ] Explain and model many-to-many relationships
- [ ] Use aggregate functions (COUNT, AVG, SUM, MIN, MAX)
- [ ] Describe the difference between relational and NoSQL databases (theoretical overview)


## Main Topics

- **CRUD operations:**
- **Create:** INSERT INTO
- **Read:** SELECT
- **Update:** UPDATE
- **Delete:** DELETE
- **Introduction to relationships:**
- Simple foreign keys and joining tables (theory and simple examples)
- Many-to-many relationships (theory and simple examples)
- **Aggregate functions:**
COUNT, AVG, SUM, MIN, MAX
- **NoSQL:**
Brief theoretical overview only—focus remains on relational databases.
49 changes: 49 additions & 0 deletions courses/Backend/databases/week1/assignment.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Assignment

## Part 1: Working with tasks

Write the following sql queries:

- Add a task with these attributes: `title, description, created, updated, due_date, status_id, user_id`
- Change the title of a task
- Change a task due date
- Change a task status
- Mark a task as complete
- Delete a task

In all the above queries, you choose which is the task that you will modify/delete.

## Part 2: School database

- Create a new database containing the following tables:
- **Class**: with the columns: id, name, begins (date), ends (date)
- **Student**: with the columns: id, name, email, phone, class_id (foreign key)
- If you are done with the above tasks, you can continue with these advanced tasks:
- Create an index on the name column of the student table.
- Add a new column to the class table named **status** which can only have the following values: not-started, ongoing, finished (hint: enumerations).

## Part 3: More queries

You should do these queries on the database `hyf_lesson2`, which we created last class.
You can find the data [here](lesson2-data.sql) if you need to create the DB again.

- Get all the tasks assigned to users whose email ends in `@spotify.com`
- Get all the tasks for 'Donald Duck' with status 'Not started'
- Get all the tasks for 'Maryrose Meadows' that were created in september (hint: `month(created)=month_number`)
- Find how many tasks where created in each month, e.g. how many tasks were created in october, how many tasks were created in november, etc. (hint: use group by)

## Part 4: Creating a database

Using an entity relationship diagram, design the data model for an application of your choice. This can be anything, previous students have used a small business (with staff, offices, and job titles), a library (with books, genres, racks, members, and a borrowing log), or a farm (with animals, barns, and farmers).

Your application must include at least one many-to-many relationship and any supporting tables (linking tables) that are needed. The entity relationship diagram must describe what tables you will need, the columns in these tables, which column is the primary key, and the relationships between tables.

Next, using the entity relationship diagram as a starting point, write all the necessary `CREATE TABLE` statements to create all tables and relationships (foreign key constraints) for this data model.

Submit an image or PDF of your entity relationship diagram, and a `.sql` file with the `CREATE TABLE` statements.

### Hand in assignment

Need to brush up on the homework hand-in process?

Check [this resource](https://github.com/HackYourFuture-CPH/Git/blob/main/homework-submission.md) to remember how to hand in the homework correctly!
7 changes: 7 additions & 0 deletions courses/Backend/databases/week1/preparation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## Pre-Class Preparation

- [Falsehoods Programmers Believe About Names](https://www.kalzumeus.com/2010/06/17/falsehoods-programmers-believe-about-names/)
- [What is a Database Foreign Key](https://www.educative.io/blog/what-is-foreign-key-database)
- [Example Entity Relationship Diagram (including associative entities)](https://users.csc.calpoly.edu/~jdalbey/308/Lectures/HOWTO-ERD.html)

The students should watch this video before class: <https://youtu.be/9hTKUT_SZWU>
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
[
{
"id": 1,
"authors": [
{
"id": 1,
"name": "James Smith"
},
{
"id": 2,
"name": "Jane Jones"
}
],
"title": "BREAKING NEWS: Water is wet!",
"content": "Scientists have discovered that water is wet, it's amazing what.... ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.",
"tags": ["science", "breaking"]
},
{
"id": 2,
"authors": [
{
"id": 3,
"name": "Aliya Awad"
},
{
"id": 4,
"name": "Igor Vladimir"
}
],
"title": "Heavy Snowfall Expected this Weekend",
"content": "Lots of snow is expected... Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.",
"tags": ["weather", "winter"]
},
{
"id": 3,
"authors": [
{
"id": 2,
"name": "Jane Jones"
},
{
"id": 5,
"name": "Kim Jensen"
}
],
"title": "BREAKING NEWS: These 10 Clickbait Titles Are Bad for Your Health, Number 7 Will SHOCK You!",
"content": "Haha, you clicked! Minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat ",
"tags": ["clickbait", "breaking"]
}
]
11 changes: 11 additions & 0 deletions courses/Backend/databases/week1/session-plan.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Lesson Plan - Databases - Week 2

## Queries

1. Get all the tasks assigned to `Pavel`;
2. Find how many tasks each user is responsible for;
3. Find how many tasks with a `status=Done` each user is responsible for;

## Design and implement a database for existing data

Design an ER model and implement the respective database for the data in [this file](assets/articles_example.json).
7 changes: 7 additions & 0 deletions courses/Backend/databases/week2/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Introduction to Databases, Week 3

## Learning Goals

## Main Topics

## Resources
1 change: 1 addition & 0 deletions courses/Backend/databases/week2/assignment.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Assignment
1 change: 1 addition & 0 deletions courses/Backend/databases/week2/preparation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
## Pre-Class Preparation
1 change: 1 addition & 0 deletions courses/Backend/databases/week2/session-plan.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Lesson plan
Loading