W02 Team Activity: Database Entities for Service Projects
Overview
For this team activity, you will meet for a 1-hour synchronous team meeting using Microsoft Teams video sharing.
Please make every effort to attend this meeting. If you cannot attend, you must complete the Absent from Meeting Checklist.
In this activity, you will work with your team to add Service Projects to your individual projects, including from the database all the way through display in an EJS page.
Activity Instructions
Before the Meeting
Before the meeting begins, each person should individually do the following:
- Complete all of the Learning Activities for this week.
For the meeting, follow these steps.
Determine the Leader for the Meeting
Choose one person that will be the leader for this meeting. Their role will be to help guide the rest of the team through the steps of the meeting. Try to rotate so that each person gets a chance to be the leader of at least one meeting.
Group Discussion
Throughout this activity, you will see group discussion question boxes like this one. The leader for the meeting should ask these questions, and you should discuss them as a group. After the activity, there will be a quiz question very similar to each discussion question.
Begin with Prayer
One person on the team should begin the meeting with a prayer.
Code Review (10 minutes)
Select one person to share their screen and share some of their code from the last week. (Try to rotate so that each person gets a chance to share at least once during the course.)
- What was particularly well done or interesting?
- Do you have any suggestions for improvement?
Understand the Requirements
In the learning activities, you added Organizations to your application. For this activity, you will add Service Projects according to the following specifications:
- Every Service Project should relate to a single Organization that sponsors it.
- Each Service Project should have the following information:
- Project ID
- Organization ID (of the organization that sponsors it)
- Title
- Description
- Location
- Date
Add service projects to the database
The first step is to design your table(s) and add it to the database.
Questions to discuss:
- What table(s) do you need to create?
- What columns should be in each table?
- What data types should each column be?
- What constraints should you add to each column?
Once you have discussed and agreed on the design, each person should complete the following steps (it may be helpful for one person to share their screen):
- Create the table(s) in the database.
- Insert at least 5 sample service projects for each organization in your database (assuming you have at least 3 organizations, that is at least 15 projects).
- Verify that the data has been inserted correctly by running a SELECT statement on the table.
- Add your SQL commands to your setup.sql file so that you can re-create your database in the future.
Remember: AI can be helpful
Remember that AI can be very helpful in generating SQL for both the Create Table scripts as well as the scripts to insert the data.
If you have AI generate SQL for you, make sure to carefully review each line to ensure that you understand everything in your commands. If there is something in the SQL that you don't understand, ask AI to explain it.
Group Discussion
- What would happen if you included the organization_id column in the project table, but did not include a foreign key constraint for it?
Update the Application Code
Update your Node.js application code to retrieve and display the service projects. You will need to complete the following:
- Create a file
src/models/projects.jsand add a function to get all projects along with their organization names (this will require a join). - Add a call to that function in
server.jsand display the results to the console to verify it is working.
Hint: Make sure to follow the example of src/models/organizations.js that you completed in a learning activity.
Group Discussion
- What are the benefits of separating the code that performs the database query into its own module (for example, src/models/projects.js) instead of keeping database queries directly in server.js?
Add a Service Projects EJS page
Create a new EJS page to display the service projects along with their organization names.
- Update the route in server.js to call the
getAllProjects()to get the Service Project and send it to the rendering of the EJS page. - Update the EJS page
views/projects.ejsto display the projects along with the organizations. - On the EJS page, iterate through the list of projects and for each one, display the project title and the organization name in the format: Date: Project Title (Organization Name).
- Make sure to format the date in a user-friendly way.
Group Discussion
- What is the difference between EJS tags:
<%= ... %>and<%- ... %>? When should each be used?
Deploy and Test
Once you have everything working, deploy your code to your hosting server and verify that it works there.
Submission
Once you have finished this activity, return to Canvas to submit a quiz.
Other Links:
- Return to: Week Overview | Course Home