Skip to content

Instantly share code, notes, and snippets.

@fractalwrench
Created September 29, 2020 19:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fractalwrench/54692911ea470f70c506b9b82ea72e23 to your computer and use it in GitHub Desktop.
Save fractalwrench/54692911ea470f70c506b9b82ea72e23 to your computer and use it in GitHub Desktop.
Cat API database instructions

The Cat API needs a database to persist information about cats permanently, so that users don't lose their data when the server restarts.

Your mission, should you choose to accept it, is to spike into determining what needs to be done to setup a SQL database for your Cat API project. This is a common thing to do when there are technical uncertainties, and will allow us to better define the app's requirements.

App Requirements

  1. Information must be persisted in a database so that user data is available when the Express.js server is restarted
  2. The database should be a relational database rather than Nosql because our data schema (cats and breeds) is well defined and unlikely to change
  3. The database should be lightweight in terms of performance and easy to operate

Sqlite is a good choice which fulfills all the above requirements. In a production project you might end up picking another database from this list depending on your project's needs.

What you should do in the spike

  1. Branch from master on the Cat API
  2. Setup sqlite to open a sample database from a file on disk using this node module
  3. When the express JS server starts up, run a query that selects all the employees and logs them out to the console
  4. Find out whether it's possible to start SQLite automatically whenever the ExpressJs app starts

Ensure you document any gotchas with the node module along the way, and note down any questions or uncertainties - as these will need to be turned into requirements in the next step.

Writing requirements

Software projects often have technical design documents, so it'd be good practice to try writing one of your own. As a general rule, a good design document would have enough detail about what will change and how, that one of your colleagues could go off and implement the feature themselves. Adapting an existing project you've worked on to use a database will be a great introduction to this.

The existing Cat API requirements won't change, and serve as a good template. Stackoverflow also has a very detailed template, which you could adapt to your needs (by deleting all the unnecessary sections).

Ask lots of questions about the design spec structure along the way, and then get me to review it - then you'll implement the change :)

@fractalwrench
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment