Grace Hopper Center

CSC 221 Weekly Assignments: Week 15

CSC 221


Overview

This week we will continue with our chat project, with a focus on the database "tier" of our three-tier application stack, and using Django's ORM for the logic tier. .

NOTE: Jeff will be available for students interested in reviewing for a retake of the PCEP this Saturday, December 13 from 9 am to 12 noon.

Thursday, December 12th

Classwork

It's that time again, NVCC Course Evaluations! Please visit https://nova.direct.iota360.cc, enter your VCCS email and your NVCC student number and complete your evaluations. NVCC will provide me with regular updates as to your participation rates, so I will nag relentlessly until you get this done :-)

Our goal for the next few classes between now and winter break is to turn our chat project into a complete three-tier application that uses Curses, sqlite, and Django's ORM. Today, we'll introduce Django's ORM.

I've written you some starter code here. We'll talk through this code together in class.

There is a lot to keep track of, so here are some reminders:

  • First, we'll download this code and place it in your repo alongside your existing messaging code
  • You'll need to create a virtual environment, activate it, and then run pip install -r requirements.txt. This didn't work for some of us, so for you can just say pip install django instead.
  • You'll define your model(s) in the file db/models.py. For more details about that file, see the official documentation
  • To apply your model changes to the database, you'll run these two commands:
    • python3 manage.py makemigrations db
    • python3 manage.py migrate
  • If you want to use the Django Admin interface, you'll need to create a superuser (python3 manage.py createsuperuser) and add your model to db/admin.py.
  • Use the existing main.py as a template for your code. You can copy your existing chat code there

Next week, we'll complete the application by adding a nice Curses frontend.

Homework

Your homework is to review the theory. We went through this fast today, and Dr. Chuck does a great job of explaining. Watch Dr Chuck's videos in Lesson 8 and take notes in your repo for credit. As always, we reserve the right to have a quiz on the Django orm next class!

Tuesday, December 10th

Classwork

Today's class is going to be a whirlwind. Hang on to your seats =)

We'll begin class with a short quiz on the material presented in your homework lectures.

After the quiz Chris will talk about databases. Chris gets very passionate about databases, so he might talk too long =). As part of this discussion, We'll do a quick demo using the SQLite command shell to practice the SQL commands from your videos. (Chris will also make a plug here for DE Databases , which you should all take next year).

We'll quickly introduce the SQL Murder Mystery, which is a great place to practice with SQL syntax.

After a quick overview of databases, we'll pivot to talking about three-tier web applications, and how ORMs are useful for developing them.

Homework

For your 90 minutes of homework time, work on solving the SQL Murder Mystery. Keep notes about your progress in a Markdown file in your class repo. Remember to put your queries in code blocks, like this:

``` sql
SELECT name 
FROM sqlite_master
WHERE type = 'table'
```