-
Notifications
You must be signed in to change notification settings - Fork 9
Update database lesson material (Backend) #92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
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 b4a1ae2
Merge branch 'main' into 6-database-backend-content-update
marcorichetta 92cb4c5
Merge branch 'main' into 6-database-backend-content-update
marcorichetta 9924de3
Rename weeks modules and format them to match the template
marcorichetta c3c811b
update week 1 session goals
marcorichetta 0886edb
match template format
marcorichetta eaaf34b
add todo for session content
marcorichetta 667b8d6
update week 2 learning goals and main topics
marcorichetta 9d8ef42
format according to template + fixing links
marcorichetta 0ec4714
update preparation.md with video for an example on SQL Injection and …
marcorichetta 1ba77bc
include comment on using a tool other than dbeaver
marcorichetta c8c810d
add session plan for DB week1
marcorichetta c675b08
Merge branch 'main' into 6-database-backend-content-update
marcorichetta c9dc685
update preparation requirements and material
marcorichetta f85018b
small fixes to learning goals
marcorichetta 6f7c648
refactor assignment: modified the legacy content + adapted it to work…
marcorichetta d0c9616
lint:fix
marcorichetta f16bfec
use mariadb.com resources for reading list - much cleaner and stick t…
marcorichetta a8666a6
add mariadb resources for preparation
marcorichetta 9dbcc07
make the session goals more practical
marcorichetta 4db3a43
create session plan based on learning goals, focusing on using the sa…
marcorichetta 4c2980d
add sample api to work through the session-plan
marcorichetta bb66937
assignment todo
marcorichetta 0d4eeca
`./lint --fix`
marcorichetta e8293a6
refine module learning goals + add prerequisites
marcorichetta 33d31fd
correct some more content based on Adam's feedback
marcorichetta e304340
move example-api to correct directory
marcorichetta de008a9
update database filename and directory
marcorichetta ea5c0f6
rename tasks/db to tasks.sqlite3 for consistency
marcorichetta 13ffef1
set package type to avoid warning when running `npm run dev`
marcorichetta 5d29b51
improve setup notes
marcorichetta 111d763
improve aggregate functions wording
marcorichetta 16d7347
reorganize transactions content
marcorichetta c99af40
refine database types section + add summary
marcorichetta 941967e
add exercise for sql injection
marcorichetta 178d620
change ORM queries to parameterized ones
marcorichetta 6a97fc8
add interactivity to the ERD demo
marcorichetta 6f34dca
fix: clarify difference between CRUD goal on week 1
marcorichetta ed23a89
refactor: clarify session structure and add more incremental exercises
marcorichetta d75d4ed
refactor: improve the join explanation to be more incremental
marcorichetta 41542d3
refactor: small fixes
marcorichetta 0e0b12b
fix: remove ids to avoid duplicate id constraint and use autoincrement
marcorichetta ff6deb2
feat: add sample db with complete data from class. Also useful for as…
marcorichetta fb1c363
refactor: minimal fixes to the session plan
marcorichetta 0157bec
refactor: improve description, add tips and replace mysql for sqlite …
marcorichetta 5b90cfa
feat: add aggregate fns and more transaction resources
marcorichetta 19ba9fd
refactor: remove transactions from session plan
marcorichetta 25ec446
./lint --fix
marcorichetta 1718c02
Merge branch 'main' into 6-database-backend-content-update
marcorichetta 3202c98
./lint --fix
marcorichetta 203e207
fix: move course from Backend -> backend
marcorichetta 110d1a9
feat: add html elements to use collapsible sections
marcorichetta 9481d9a
./lint --fix
marcorichetta 116a453
fix: add clearer setup instructions for mentor and trainees
marcorichetta b3d11c1
feat: add section on database deployments: concepts, the why and setup
marcorichetta 18a65a0
fix: move example-api to the assignment repo and update instructions
marcorichetta 6e89b4c
small clarification
marcorichetta 8c3e734
Merge branch 'main' into 6-database-backend-content-update
marcorichetta defbc3b
remove example api
marcorichetta 198198e
fix lint errors
marcorichetta c9b5c5f
fix invalid links
marcorichetta 3c9cb05
Added directory structure for gitbook
adamblanchard b0187b0
updated language from school like terms
adamblanchard 886b4dc
another student replacement
adamblanchard bad5606
Improved wording of the cloud header
adamblanchard cb86a64
Removed sqlite3 file but give clear insturctions to mentor to recreat…
adamblanchard 658aaa2
add clearer instructions where the trainee should create the database…
adamblanchard 15be2c5
clarify that the assignment is built ontop of the working solution fr…
adamblanchard 806e02d
tidy up session plan week 2
adamblanchard b915463
Fixed broken reference to sample data
adamblanchard 01b0df0
fixed broken link on gitbook
adamblanchard 62fcbce
actually fixed gitbook link
adamblanchard File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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: | ||
|
|
||
| - [ ] ? | ||
marcorichetta marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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. | ||
marcorichetta marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| 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! | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) | ||
marcorichetta marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| The students should watch this video before class: <https://youtu.be/9hTKUT_SZWU> | ||
50 changes: 50 additions & 0 deletions
50
courses/Backend/databases/week1/session-materials/articles_example.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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"] | ||
| } | ||
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| # Lesson Plan - Databases - Week 2 | ||
|
|
||
marcorichetta marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ## 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). | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| # Introduction to Databases, Week 3 | ||
|
|
||
| ## Learning Goals | ||
|
|
||
| ## Main Topics | ||
|
|
||
| ## Resources | ||
marcorichetta marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| # Assignment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| ## Pre-Class Preparation |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| # Lesson plan |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.