|
| 1 | +# Sprint Challenge: Node DB Sprint |
| 2 | + |
| 3 | +## Description |
| 4 | + |
| 5 | +In this challenge, you design and build a Data Model and a RESTful API that stores data into a Relational Database. |
| 6 | + |
| 7 | +## Instructions |
| 8 | + |
| 9 | +**Read these instructions carefully. Understand exactly what is expected _before_ starting this Sprint Challenge.** |
| 10 | + |
| 11 | +This is an individual assessment, please work on it alone. It is an opportunity to demonstrate proficiency in the concepts and objectives introduced and practiced in preceding days. |
| 12 | + |
| 13 | +If the instructions are not clear, please seek support from your TL and Instructor on Slack. |
| 14 | + |
| 15 | +The Minimum Viable Product must be completed in three hours. |
| 16 | + |
| 17 | +Follow these steps to set up and work on your project: |
| 18 | + |
| 19 | +- [ ] Create a forked copy of this project. |
| 20 | +- [ ] Add your _Team Lead_ as collaborator on Github. |
| 21 | +- [ ] Clone your forked version of the Repository. |
| 22 | +- [ ] Create a new Branch on the clone: git checkout -b `firstName-lastName`. |
| 23 | +- [ ] Implement the project on this Branch, committing changes regularly. |
| 24 | +- [ ] Push commits: git push origin `firstName-lastName`. |
| 25 | + |
| 26 | +Follow these steps for completing your project. |
| 27 | + |
| 28 | +- [ ] Submit a Pull-Request to merge `firstName-lastName` Branch into master on **your fork, don't make Pull Requests against Lambda's repository**. |
| 29 | +- [ ] Please don't merge your own pull request. |
| 30 | +- [ ] Add your _Team Lead_ as a Reviewer on the Pull-request |
| 31 | +- [ ] Your _Team Lead_ will count the challenge as done by merging the branch into _master_. |
| 32 | + |
| 33 | +## Commits |
| 34 | + |
| 35 | +Commit your code regularly and use descriptive messages. This helps both you (in case you ever need to return to old code) and your Team Lead. |
| 36 | + |
| 37 | +## Self-Study/Essay Questions |
| 38 | + |
| 39 | +Demonstrate your understanding of this week's concepts by answering the following free-form questions. Edit this document to include your answers after each question. Make sure to leave a blank line above and below your answer so it is clear and easy to read by your project manager. |
| 40 | + |
| 41 | +- [ ] Explain the difference between `Relational Databases` and `SQL`. |
| 42 | + |
| 43 | +- [ ] Why do tables need a `primary key`? |
| 44 | + |
| 45 | +- [ ] What is the name given to a table column that references the primary key on another table. |
| 46 | + |
| 47 | +- [ ] What do we need in order to have a _many to many_ relationship between two tables. |
| 48 | + |
| 49 | +## Minimum Viable Product |
| 50 | + |
| 51 | +Take the steps necessary to complete the project from scratch. Start by initializing your project with a `package.json` and go from there. |
| 52 | + |
| 53 | +Complete the following tasks: |
| 54 | + |
| 55 | +- [ ] Design the data model and use _knex migrations_ to create the database and tables. |
| 56 | +- [ ] Build an API with endpoints for: |
| 57 | + - [ ] adding resources. |
| 58 | + - [ ] retrieving a list of resources. |
| 59 | + - [ ] adding projects. |
| 60 | + - [ ] retrieving a list of projects. |
| 61 | + - [ ] adding tasks. |
| 62 | + - [ ] retrieving a list of tasks. **The list of tasks should include the project name and project description**. |
| 63 | +- [ ] When returning `project` or `task` information, the `completed` property should be `true` or `false`. |
| 64 | + |
| 65 | +For example, instead of returning a `task` that looks like this: |
| 66 | + |
| 67 | +```js |
| 68 | +{ |
| 69 | + id: 1, |
| 70 | + name: 'convert to boolean', |
| 71 | + completed: 1 // the database stores a 1 to represent true values on a boolean field |
| 72 | +} |
| 73 | +``` |
| 74 | + |
| 75 | +The API should return: |
| 76 | + |
| 77 | +```js |
| 78 | +{ |
| 79 | + id: 1, |
| 80 | + name: 'convert to boolean', |
| 81 | + completed: true // write code to convert the 1 to true and 0 to false |
| 82 | +} |
| 83 | +``` |
| 84 | + |
| 85 | +### Business Rules |
| 86 | + |
| 87 | +- a `project` can have multiple `tasks`. |
| 88 | +- a `task` belongs to only one `project`. |
| 89 | +- a `project` can use multiple `resources`. |
| 90 | +- the same `resource` can be used in multiple `projects`. |
| 91 | +- when adding `projects` the client must provide a name, the description is optional. |
| 92 | +- when adding `resources` the client must provide a name, the description is optional. |
| 93 | +- when adding a `task` the client must provide a description, the notes are optional. |
| 94 | +- when adding a `task` the client must provide the `id` of an existing project. |
| 95 | +- for `projects` and `tasks` if no value is provided for the `completed` property, the API should provide a default value of `false`. |
| 96 | + |
| 97 | +### Entities |
| 98 | + |
| 99 | +A `project` is what needs to be done. We want to store the following data about a `project`: |
| 100 | + |
| 101 | +- [ ] a unique Id. |
| 102 | +- [ ] a name. This column is required. |
| 103 | +- [ ] a description. |
| 104 | +- [ ] a boolean that indicates if the project has been completed. This column cannot be NULL, the default value should be `false`. |
| 105 | + |
| 106 | +A `resource` is anything needed to complete a project, some examples are: a person, a tool, a meeting room or a software license. We want to store the following data about a `resource`: |
| 107 | + |
| 108 | +- [ ] a unique Id. |
| 109 | +- [ ] a name. This column is required. |
| 110 | +- [ ] a description. |
| 111 | + |
| 112 | +The database should not allow resources with duplicate names. |
| 113 | + |
| 114 | +An `task` one of the steps needed to complete the project. We want to store the following data about an `task`. |
| 115 | + |
| 116 | +- [ ] a unique id. |
| 117 | +- [ ] a description of what needs to be done. This column is required. |
| 118 | +- [ ] a notes column to add additional information. |
| 119 | +- [ ] a boolean that indicates if the task has been completed. This column cannot be NULL, the default value should be `false`. |
| 120 | + |
| 121 | +## Stretch Problem |
| 122 | + |
| 123 | +This section is **optional** and not counted towards MVP. Start working on it after you're done with the main assignment. |
| 124 | + |
| 125 | +Add an endpoint for retrieving a `project` by its `id` that returns an object with the following structure: |
| 126 | + |
| 127 | +```js |
| 128 | +{ |
| 129 | + id: 1, |
| 130 | + name: 'project name here', |
| 131 | + description: 'the project description', |
| 132 | + completed: false, // or true, the database will return 1 for true and 0 for false |
| 133 | + tasks: [ |
| 134 | + { |
| 135 | + id: 1, |
| 136 | + description: 'task description', |
| 137 | + notes: 'the task notes', |
| 138 | + completed: false // or true |
| 139 | + }, |
| 140 | + { |
| 141 | + id: 7, |
| 142 | + description: 'another task description', |
| 143 | + notes: 'the task notes', |
| 144 | + completed: false // or true |
| 145 | + } |
| 146 | + ], |
| 147 | + resources: [ |
| 148 | + { |
| 149 | + id: 1, |
| 150 | + name: 'Lambda Student', |
| 151 | + description: 'a soon to be hired developer' |
| 152 | + }, |
| 153 | + { |
| 154 | + id: 2, |
| 155 | + name: 'MacBook Pro #1' |
| 156 | + description: 'an overly expensive laptop computer' |
| 157 | + } |
| 158 | + ] |
| 159 | +} |
| 160 | +``` |
| 161 | + |
| 162 | +Add the remaining CRUD operations for projects and tasks. |
| 163 | + |
| 164 | +Use `knex` to add _data seeding_ scripts for projects and tasks. |
| 165 | + |
| 166 | +Add support for the concept of `contexts`. A context is something like _at home_, _at work_ or _at computer_. The idea is that some tasks require one or more `contexts` in order to be worked on. For example, the task of _file income taxes_ may require that you are _at home_, _at computer_ and _online_ so if you are _at work_ and look at the list of pending tasks you could do in your current context, filing your taxes will not be one of them. |
| 167 | + |
| 168 | +A `context` can be applied to more than one `task`. An task can be tied to more than one context, like in the example above. |
| 169 | + |
| 170 | +When retrieving an `task` by _id_, add a property that lists all the `contexts` related to that task. |
| 171 | + |
| 172 | +_Good luck and have fun!_ |
0 commit comments