CSE 340: Web Backend Development

W02 Assignment: Database Retrieval

Overview

In this assignment you will demonstrate your knowledge of this lesson by adding a new database entry, querying for that information in Node.js, and then displaying it in an EJS page.

For this assignment you will add Service Project Categories to your application.

Instructions

Follow these steps to complete the assignment:

Ensure the Learning Activity and Team Activity features are working

If you haven't already, complete all steps of the following activities:

Make sure that the application is deployed to your hosting site and working correctly for organizations and service projects. If anything is not working, you should fix that before proceeding.

Add Categories to the Database

Add service project categories to the database. Categories have the following requirements:

Complete the following:

  1. Decide on the table(s) you need.
  2. Create the table(s) in your database.
  3. Make sure to add any constraints you need.
  4. Add at least 3 categories relevant to service projects.
  5. Associate each project in your database with at least one category.
  6. Add these SQL statements your database setup.sql file so you can re-create your database in the future. (This is also how your database structure will be graded.)

Update Application to Retrieve and Display Categories

Update your application to retrieve and display the categories. At this point, you do not need to display the projects associated with the categories. You can simply display the list of category names.

Complete the following:

  1. Add a new file (src/models/categories.js) and function to get all categories from the database.
  2. Update your /categories route in server.js to call that function and pass the results to the EJS view that is rendered.
  3. Update your categories.ejs view to display the category name that come from your database.
  4. This display will only display the category names. You do not need to worry about displaying the projects associated with each category at this time, but you will add that functionality in your assignment next week.

Code Organization

Make sure to follow the same pattern for this model, route, and view that were used in the learning activities, including the same naming convention for files and functions.

Deploy and Test

Once you have everything working, deploy your code to your hosting server and verify that everything is working correctly there.

Requirements

Your assignment must implement the following requirements:

  1. Database Design: The database setup.sql script contains accurate SQL statements to create and insert data for organizations, projects, and categories. All relationships are modeled correctly and contain appropriate primary and foreign keys.
  2. End-to-End Data Flow: Data for organizations, projects, and categories flows from the database to Node.js to EJS without errors. The EJS pages render all required fields using dynamic data.
  3. Code Organization and Standards: New Node.js functions are placed in the correct files and use the exact required naming convention defined in the learning activities. All coding standards are followed.

Score

Your assignment will receive a score according to the following criteria:

If your assignment is graded as Incomplete, you should fix any issues and resubmit.

Submission

When you have finished this assignment:

Other Links: