You signed in with another tab or window.Reload to refresh your session.You signed out in another tab or window.Reload to refresh your session.You switched accounts on another tab or window.Reload to refresh your session.Dismiss alert
In this challenge, you design and build a Data Model and a RESTful API that stores data into a Relational Database.
Instructions
Read these instructions carefully. Understand exactly what is expectedbefore starting this Sprint Challenge.
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.
If the instructions are not clear, please seek support from your TL and Instructor on Slack.
The Minimum Viable Product must be completed in three hours.
Follow these steps to set up and work on your project:
Create a forked copy of this project.
Add yourTeam Lead as collaborator on Github.
Clone your forked version of the Repository.
Create a new Branch on the clone: git checkout -bfirstName-lastName.
Implement the project on this Branch, committing changes regularly.
Push commits: git push originfirstName-lastName.
Follow these steps for completing your project.
Submit a Pull-Request to mergefirstName-lastName Branch into master onyour fork, don't make Pull Requests against Lambda's repository.
Please don't merge your own pull request.
Add yourTeam Lead as a Reviewer on the Pull-request
YourTeam Lead will count the challenge as done by merging the branch intomaster.
Commits
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.
Self-Study/Essay Questions
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.
Explain the difference betweenRelational Databases andSQL.
Why do tables need aprimary key?
What is the name given to a table column that references the primary key on another table.
What do we need in order to have amany to many relationship between two tables.
Minimum Viable Product
Take the steps necessary to complete the project from scratch. Start by initializing your project with apackage.json and go from there.
Complete the following tasks:
Design the data model and useknex migrations to create the database and tables.
Build an API with endpoints for:
adding resources.
retrieving a list of resources.
adding projects.
retrieving a list of projects.
adding tasks.
retrieving a list of tasks.The list of tasks should include the project name and project description.
When returningproject ortask information, thecompleted property should betrue orfalse.
For example, instead of returning atask that looks like this:
{id:1,name:'convert to boolean',completed:1// the database stores a 1 to represent true values on a boolean field}
The API should return:
{id:1,name:'convert to boolean',completed:true// write code to convert the 1 to true and 0 to false}
Business Rules
aproject can have multipletasks.
atask belongs to only oneproject.
aproject can use multipleresources.
the sameresource can be used in multipleprojects.
when addingprojects the client must provide a name, the description is optional.
when addingresources the client must provide a name, the description is optional.
when adding atask the client must provide a description, the notes are optional.
when adding atask the client must provide theid of an existing project.
forprojects andtasks if no value is provided for thecompleted property, the API should provide a default value offalse.
Entities
Aproject is what needs to be done. We want to store the following data about aproject:
a unique Id.
a name. This column is required.
a description.
a boolean that indicates if the project has been completed. This column cannot be NULL, the default value should befalse.
Aresource 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 aresource:
a unique Id.
a name. This column is required.
a description.
The database should not allow resources with duplicate names.
Antask one of the steps needed to complete the project. We want to store the following data about antask.
a unique id.
a description of what needs to be done. This column is required.
a notes column to add additional information.
a boolean that indicates if the task has been completed. This column cannot be NULL, the default value should befalse.
Stretch Problem
This section isoptional and not counted towards MVP. Start working on it after you're done with the main assignment.
Add an endpoint for retrieving aproject by itsid that returns an object with the following structure:
{id:1,name:'project name here',description:'the project description',completed:false,// or true, the database will return 1 for true and 0 for falsetasks:[{id:1,description:'task description',notes:'the task notes',completed:false// or true},{id:7,description:'another task description',notes:'the task notes',completed:false// or true}],resources:[{id:1,name:'Lambda Student',description:'a soon to be hired developer'},{id:2,name:'MacBook Pro #1'description:'an overly expensive laptop computer'}]}
Add the remaining CRUD operations for projects and tasks.
Useknex to adddata seeding scripts for projects and tasks.
Add support for the concept ofcontexts. A context is something likeat home,at work orat computer. The idea is that some tasks require one or morecontexts in order to be worked on. For example, the task offile income taxes may require that you areat home,at computer andonline so if you areat 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.
Acontext can be applied to more than onetask. An task can be tied to more than one context, like in the example above.
When retrieving antask byid, add a property that lists all thecontexts related to that task.