Mod 2 Review
Today, we are going to build a small application to practice what we’ve learned in Mod2! Read throught the entire spec below before starting!
The Daily Planet
- Create a Console Application in Visual Studio.
- You can call the project and solution
Newspaper
- You can call the project and solution
- Initialize a git repository in your solution.
- Add a remote repository on GitHub
- ✅ Send a link to your repository to your instructors!
Building our Classes
- Create a branch called
classes
- In your Newspaper project, add classes outlined below.
- Make sure to test your classes!
- Commit after each class is complete - you should have 3 commits!
- When all three classes have been built, merge your
classes
branch into yourmain
branch. - ✅Push your main branch to GitHub, and send a note to your instructors that you have finished the classes!
Reporter
A reporter has a Name, a Speciality (like Politics, Sports, or Arts) and Articles.
Article
An Article has a Title, Content, a Reporter and an Issue.
Issue
An Issue has a Date, and Articles.
Connecting a Database
- Diagram an ERD for our three classes (use your notebook, or a diagramming tool)
- How does each class relate to each other?
- Where should Primary and Foreign keys be assigned?
- ✅ send a snapshot of your ERD to your instructors!
- Checkout a new branch called
migrations
- Install the following packages:
- Npgsql.EntityFrameworkCore.PostgreSQL
- Microsoft.EntityFrameworkCore.Tools
- EFCore.NamingConventions
- Add a NewspaperContext class
- It will be helpful to review the Intro to ORM lesson for this!
- Add a migration to create your database.
- Run your migration!
- Commit your work, and merge your
migrations
branch into yourmain
branch. - ✅Push your main branch to GitHub, and send a note to your instructors that you have finished the database setup!
Update Classes
- Create a branch called
statistics
- In your Newspaper project, update your classes to include the methods below.
- When all three methods have been built, merge your
statistics
branch into yourmain
branch. - ✅Push your main branch to GitHub, and send a note to your instructors that you have finished the statistics!
Add the following methods to your Issue class:
- ArticleCount() - returns the number of articles in the issue
- ReporterCount() - returns the number of reporters who wrote articles for the issue (unique!)
- ReporterNames() - returns a list of reporter names represented in the issue (unique!)
🌶️ SQL Queries
Open pgAdmin and write queries for the following:
- Return all issues and their articles
- Return the average number of articles per issue
- Return the average number of articles per issue for a specific reporter (assume you do not know the id of the reporter)
✅Send a slack message to your instructors with each of the three queries above.