The Neo4j username on the cpsc server is “neo4j“, and the password is the same password we’ve used for Redis this semester.
-
Neo4j password on cpsc
-
Quiz #7 posted!
Quiz #7 has been posted to Canvas! You’ll probably want to do this before the chaos of finals week, but I’ll actually accept it all the way until the end of finals week itself.
Good luck!
-
Neo4j Star Wars additions posted
Here are the git bundles from Tuesday, with a Neo4j-equipped way of traversing Mongo objects by relationship:
-
Final homework posted!!
The final homework assignment, which will pull everything you’ve done this semester together with a pretty bow, has been posted. It is due by11am on Tuesday, Dec. 10th. Let me be crystal clear about one thing, far in advance: absolutely no changes can be made to your website after 11am on D-Day. (In case you’re wondering, yes I can tell whether you’ve violated this rule.)
I’m really excited to see the stuff that everybody has to strut!
-
Advent of Code
For the codingbatters and leetcoders in the crowd — and anyone else interested in further sharpening their coding skills while having good-natured, fun competition at the same time — I encourage you to join this year’s Advent of Code competition!
This is a worldwide event that occurs every year from Dec 1st to Dec 25th — a total of 25 increasingly challenging coding problems that the studliest coders in the world compete for prizes to complete. I’ve participated several times, and it has never failed to be fun, clever, skill-building, and a bonding experience (with others I know who are participating, and with people all over the world I’ve never met)!
Ian has set up a local leaderboard for UMW, and I encourage you to read his email and sign up for an account.
Also, here is an important rule change for the leetcode/codingbat XP: for the last two weeks of the semester (last week of classes, plus finals week) you can choose one of the following two options:
- Continue doing your leetcode points, for +2XP per week, just as before.
- Join Advent of Code, and earn up to +2XP per day. You can get +1XP for getting a day’s “silver star,” and another +1XP for getting a day’s “gold star.”
To participate in this option, you’ll need to join Ian’s leaderboard (as described in his email; lmk if you don’t get it) and send me your Python (or any other language) solutions to the one or two daily problems via email, with subject line “CPSC/DATA 350 – Advent of Code Day n turnin” (where “n” is replaced with the December date). Send me these no later than midnight of the following day.
Good luck!
-
Extension clarification
I guess I thought that the assignment was due tonight, which is why I gave the extension ’til tomorrow night…but now that I learn it was already due tomorrow night, I guess I’m now saying it’s due Saturday night, the 23rd.
Sorry for the confusion!
-
Last-minute stay of execution
A couple of students are dealing with some pretty gnarly bugs that aren’t their fault, and I’m troubleshooting. I’m going to extend the homework #8 deadline until tomorrow, Nov 22, at midnight.
-
Quiz #6 (of 7) posted!
Quiz #6 has been posted to Canvas, and is due midnight Monday Dec 2nd. Please note that it is absolutely closed-Python, and timed at 55 minutes.
Quiz #7 will be released over Thanksgiving break sometime, and will be due the last day of the semester (Friday, Dec 6th). There will be only 7 quizzes, not 8 as the syllabus stated, and of course I will recompense everyone for the missing points.
-
The “no such package pymongo” problem
Do be very sure that in your virtual environment, you have run:
$ pip install flask
at some point. If you have not, then typing “flask run” will run the system-wide flask (in /bin) which uses the system-wide Python installation (without pymongo installed), not your venv at all.
-
Final Galaxy Explorer example(s) posted
Here’s the completed Galaxy Explorer example. Note that the first class chose Redis lists (Riley’s choice) to store each user’s favs, whereas the second class chose Mongo (Dylan’s choice). Both are fine alternatives, and if you’d like to see the code for either one, feel free to snoop on either version:
-
Seeing the correct answers after taking a quiz
I was astonished just now to learn that apparently, my Canvas settings were set so that students cannot see the correct answers after the quiz! :-O That seems like the dumbest thing in the world — you give an answer to some multiple choice question, and then discover you were wrong, but not what the right answer is. (?!)
Anyways, I never in a million years intended to hide the correct answers from students after they have completed the quiz, and I think I have now configured Canvas properly so you can see them. When you get a chance, you might take a peek at one or two of your old quizzes and verify that you can see the correct answers for any items you may have missed!
-
Programming contest props
Congratulations to Bethanie Hackett, Sully Smith, and Matt Vierow for their outstanding showings at the ACM regional programming contest at CNU this weekend! Sully’s team chose to compete at the daunting Division I level, and got four of those uber-hard problems correct! Bethanie’s and Matt’s team, on the other hand, chose to enter the Division II level, and placed first in the entire division at the CNU site!
Way to go, guys — you’re the pride of UMW!
P.S. If anyone is interested in representing UMW in the ACM contest in future years, mention your interest to Ian (ifinlay _AT_ umw _DOT_ edu)!
-
Steps to create a new Mongo database and collection
There aren’t any. Really.
Like many things in NoSQL, you just “use it as if it exists, and then it magically does exist.” Try typing some variant of this into the Python shell:
>>> import pymongo >>> mc = pymongo.MongoClient("mongodb://localhost:27017") >>> db = mc['randomName1'] >>> db.randomName2.insert_one({'someKey':'someValue'})
You will discover if you then log in to the mongosh that there is in fact a database now called randomName1, and in it is a collection called randomName2, which has one document, with an _id and a "someKey":"someValue" key-value pair.
So you never had to prepare any of the above Python code to work by issuing a command to create a new database, or a new collection. Scary, but kinda neat!
-
The Galaxy Explorer example (so far):
-
Assignment #8 posted!
Assignment #8 has been posted, and is due a week from tomorrow. Feel free to think creatively about how you might use Mongo to augment your database tour. You don’t have to religiously follow what I’ve done!
-
Office hour switch
My car needs an oil change. For today only (Nov 14) I’ll have office hours 2:30-3:30pm instead of the usual 11:30am-12:30pm. Sorry for any inconvenience!
-
Quiz #5 posted!
Quiz #5 has been posted to Canvas, and is due Friday at midnight. It is open-notes, closed-Python, open-class-cheat-sheets, timed at 45 minutes, and must be completely entirely on your own, with no help from others (even others not currently at UMW). Good luck!
-
Back to our regularly scheduled program
As of this week, I’ll be returning to the O.G. office hours I established at the start of the semester.
-
Assignment #7 on the board
Assignment #7 (and its rubric) are in the books and on the scoreboard. Hey let’s give a big hand to Sushi, VeryCuteIRL and Demarcus Cousins as they devour their pints of Strawberry Cheesecake ice cream — yummm!!
-
No class on Thursday (11/7)
Sorry to have to cancel class right after the Election Day cancellation, but it can’t be helped. Work on your Mongo Star Wars activity, and read up on aggregation pipelines in preparation for next week!
-
No office hours tonight (Tue Nov 5)
I’ll be on email, though, so please do send questions! Depending on the timing, I might also be able to hop on Zoom.
-
Gah! Forgot about office hours tonight
I simply forgot all about office hours tonight (Mon the 4th) — sorry, guys! I can meet on Zoom between now and 9 if you’d like. Just drop me a line.
-
Practicing with Mongo
If you’d like to actually use the Mongo command line (mongosh) to work on last Thursday’s activity, log on to cpsc and then type:
$ mongoimport --db yourusername_sw \ --collection characters \ --file /srv/cpsc350/starwars_pre_mongoActivity.json \ --jsonArray
where yourusername is your user name. Then, you can do:
$ mongosh test> use yourusername_sw switched to db yourusername_sw yourusername_sw> show collections characters
and you are now at a shell that allows you to use db.characters plus all the toppings.
-
Assignment #6 graded
Great job on your first “real” websites, everybody! Wow, there were some eye-popping ones, some snazzily-functional ones, and some of both! Here’s the rubric I loosely used.
Also, in a striking coincidence, would you believe I was actually working on a pint of Americone Dream® as I was grading this. :-O What are the chances? Way to go Bonsai, cheese pizza, WinifredSanderson and all the others who joined me there!
-
MongoDB cheat sheet
Here’s the electronic version of today’s cheat sheet.
-
issue solved
Okay, I believe the Redis installation has now been configured correctly and won’t lose any more data. Still follow the advice I gave in the previous post, though, and put your bulk import work in a file rather than entering it interactively.
-
Warning: Redis possibly acting flaky
Ian and I are on the trail of a possible misconfiguration of the Redis installation on cpsc. While we diagnose that, let me give you this piece of advice (which is sensible anyway, regardless of this problem): if you’re going to be entering data in bulk (say, by typing lots of Pokémon stats, or lots of fishing spots, or lots of crochet patterns) do so in a Python file, rather than entering them interactively. In other words, write a .py file with lots of insertions, like this:
r = redis.Redis(db=43, password="YouKnowWhat", decode_responses=True) r.hset("hitPoints","charmander","45") r.hset("hitPoints","pikachu","35") r.hset("hitPoints","ditto","55") r.hset("hitPoints","squirtle","25") . . . and on and on and on . . .
Then, if something goes south on the database, and all the Redis data is lost, you just say “no sweat; I’ll just re-run my Python program and populate my Redis instance with its initial contents again.” If, by contrast, you had actually typed all those Pokémon stats in at the redis CLI, you’d be grumpy if they disappeared and you had to type them all over again.
Stay tuned for more info on the mysterious data loss bug.
-
Final hobbies app versions posted
And finally, the finishing touches on our hobbies example, which allows for multiple non-conflicting users by means of the session object:
-
Instructions for setting up separate dev/prod installations
Here are the instructions for getting a second Flask instance up and running on your other port, for use in development.
-
Redis password on cpsc
A Redis installation has — get this — a single password, shared among all users for all logical instances. This seems comically insecure, but hey I just work here.
Ian and I have turned on this minuscule authentication mechanism on the cpsc server. In order to access Redis from the command line, you’ll have to execute the auth command:
$ redis-cli 127.0.0.1:6379> auth TheClass'sSecretPassword OK
before doing anything else. In Python, you’ll have to connect to Redis like this:
import redis r = redis.Redis(db=N, password="TheClass'sSecretPassword", decode_responses=True)
where N is your Redis instance number.
Finally, the true value of TheClass'sSecretPassword has been posted in a Canvas announcement.
-
Ignore my parting comment
At the end of class Thursday, I told the 3:30pm class that I had mistakenly put a couple questions on quiz #4 that we hadn’t covered in class. Since no one has taken the quiz yet, though, I just now safely removed these two questions. So now the entire quiz has fair-game questions and you should try to (and be able to) answer all of them.
Sorry for any confusion!
-
Assignment #7 posted!
I went ahead and posted assignment #7 so you can take a look at it and get your creative juices flowing. However, don’t actually do anything to your flask instance that’s running your assignment #6 for me to grade, until Tuesday’s lecture when I explain how to use Docker to maintain separate versions of your app (one for development and one for production) running on two different ports.
Also, do pay attention to the red text in the assignment. You do not have to make your Redis stuff work exactly the same way mine does, and in fact I’d discourage you from doing so. Be faithful to your project topic, and think about how a couple of Redis data structures could be used to cleanly and elegantly store meaningful data about that topic.
-
You and your hobbies
Here’s the git bundles for our hobbies example so far:
-
“Open notes”
To be clear, “open notes” (on the quiz) includes cheat sheets I’ve posted, the in-class activities we’ve done, and anything else posted to this website.
-
Quiz #4 posted!
Quiz #4 has been posted to Canvas, and is due next Wednesday at midnight. It is open-notes, closed-Python, closed-Redis, timed at 60 minutes, and must be completely entirely on your own, with no help from others (even others not currently at UMW).
Hint: reviewing Tuesday’s Redis example, as well as Thursday’s XP-bearing activity, would be excellent preparation for this quiz.
Good luck!
-
Tuesday’s example, and solutions
The example Python/Redis program we did in Tuesday’s lecture is now posted. The output was:
D 0 1 5 4 2 0 1, 4, 2, 3 SLIME GO mary wash
-
Redis cheat sheet posted
Here’s the first version of our Redis cheat sheet.
-
Assignment #5 graded
The Filbert assignment has been posted to the scoreboard, and with that, I am (at least temporarily) caught up with grading! :-O
And speaking of the scoreboard, a big shout out for Russell Goplethane, buzzlightyear, Demarcus Cousins and everyone else working out their issues in Chocolate Therapy!
-
Assignment #3 grading: special case
Several students (mis-)interpreted the assignment in the same way, which leads me to believe my directions weren’t clear on a certain point. If you were one of these students whose program messed up on this specific issue, you have a chance to update and resubmit it to me and I’ll regrade it.
The specific issue is: only allowing the user to buy tickets for a flight that has already been scheduled. To be clear, the desired behavior is: customers can buy tickets for any day’s flight (as long that day is in the future).
Example: the user chooses to buy tickets on Frontier 63 for Valentine’s Day 2025, in preparation for a romantic getaway. Your program should absolutely sell those tickets. To do so, it must be smart enough to figure out whether this customer is the first customer to purchase tickets for that particular day’s flight, and if so, insert a new row in the “scheduled_flights” (or whatever you called it) table to accommodate the purchase. (Future customers who also want 2/14/25’s Frontier 63 will not need an extra row inserted, since there will already be a row from this first customer.)
If this was your issue, please update your program with new git commit(s) to make it work this way, and send it to me as an email attachment with subject line “CPSC/DATA 350 Assignment #3 REsubmit” by midnight, Oct. 25th.
-
Assignment #3 (finally!) graded
Assignment #3 has finally arrived at the scoreboard, and pulled into the gate. Here’s the rubric, which I stuck fairly closely to but not religiously. Again, I only checked a subset of things.
Let’s hear it for daveeCroket, ColmTheGOAT, smallcadenza and our other Everything But the‘s!
-
Final git bundles for B&J website
The final versions of the git bundles for our Ben & Jerry’s website example are now available:
-
Assignment #6 posted!
Assignment #6 has been posted, and is due a week from tomorrow! Get those creative juices flowing, and give yourself plenty of time to succeed on this complex undertaking!
-
url_for()
Some questions have arisen about the url_for() function. Basically all this does is cobble together a string of text which will be the legitimate URL of some page on your website.
To call it, you pass it two things:
- A string with the function name that you want Flask to call when this URL is clicked on (very confusingly, you don’t give it the “route” that you put in the decorator right above that function name, but rather the function name itself), and
- The key-value pairs (if any) that you want it to include as HTTP parameters in that URL, one per argument to url_for().
Example: let’s say I have this code in my routes.py:
@myapp.route("/my_route_names_are_awesome") def this_is_a_cool_func(): age = int(request.args['age']) team = request.args['team'] ... stuff ...
Then it might make sense to have this code snippet in some template (or some Python function) somewhere:
... url_for('this_is_a_cool_func', age=42, team="NY Mets") ...
If you did call that, you would get this return value:
"/my_route_names_are_awesome?age=42&team=NY+Mets"
(Note carefully that you pass 'this_is_a_cool_func' to url_for(), not 'my_route_names_are_awesome', which to me is super confusing.)
That’s really all url_for does: it formats that URL for you. You could write your own Python string function to do it if you prefer.
-
git bundles updated
The git bundles for our Ben & Jerry’s website have now been updated with Thursday’s contents:
-
codingbat ā leetcode
Happily, several students are telling me that they have reached the end of all the codingbat problems! Yay, I consider this an awesome accomplishment! It’s kind of like finishing all of Netflix, but better.
Can you still practice your Python for XP after you’ve reached this point? Yes! For students that finish all of the codingbat.com practice problems but still wish to earn an additional +2XP each week, level up to leetcode. Create a FREE account by clicking ‘Register’ at the top right corner of the page (Note: There are paid subscriptions available on this website, but these won’t be needed to complete the problems). You will need to verify your email which will be a bit annoying, but it will eventually trust that it is you and you will be able to proceed.
After creating an account, you should be able to complete practice problems. Scroll down the page until you see a long list of problems each with a number and a title. These are the problems available on this website. When you select a problem for the first time, you may be prompted with a window asking if you would like to work in the ‘ToolBar’ or ‘Code Editor’ window format. To get started with the website, you should choose ‘ToolBar’ as you can change this later and it makes things simpler for now.
First, set the website’s language to the correct version of “Python.” After clicking on a problem, there should be a language drop down option at the top left of the ‘Code’ window on the right half of your screen. Click on this drop down and select ‘Python3‘ from the available languages. (Note that another language option is ‘Python’ (meaning the older ‘Python 2.0’) but do not choose this option!) The website should store some type of cookie allowing you to stay in ‘Python3’ across all the problems after you change it this one time, but if not you can just refer back to these steps.
This website handles code submissions differently than codingbat.com as ‘running’ your code does not ‘grade’ your code as was the case on codingbat.com. If you select to ‘Run’ your code at the top of the screen, your code will run on the test cases that were given on the description page. Passing these test cases does not mean that you have solved the problem as there are still several hidden test cases that the website will test your code on. To check if you have found a solution to the given problem, click the green cloud button that says ‘Submit’. This will give you an evaluation on whether your code has passed or failed the task of the given problem. You will be able to resubmit another solution if your initial solution did not pass.
PLEASE NOTE: The difficulty of these practice problems can vary from easy to extremely difficult and they encompass a much vaster range of difficulty than the codingbat.com website provided. Feel free to filter the results based on the difficulty to find problems that fit with your Python skill level. You do not have to complete the problems in order. I would urge you so stay away from problems that talk about ‘time complexity’ if you are unsure of what that is (For those curious, this topic is taught in CPSC 340.)
To claim these leetcode +2XP (in place of codingbat.com +2XP), spend 30 minutes working on problems, in Python, on this website and send me an email on Friday of the given week with subject line “CPSC/DATA 350 leetcode XP”. In the body of the email, you should type “I spent 30 minutes this week working problems, in Python, on leetcode.com,” followed by the Honor Pledge and your full name as a signature.
(Thanks to Sully for scoping this out and writing most of the above instructions.)
Happy coding!
-
Quiz #3 posted!
Quiz #3 has been posted to Canvas, and is due by midnight, Oct. 16th. It is open-all-the-usual-stuff, closed-other-humans, and is timed at 30 minutes. Good luck!
-
New homework posted!
As mentioned in class, we’re a little behind where I’d like to be at this point, material-wise, so we’re skipping assignment #4. (I gave everybody full points for it.) Instead, we’re ready for assignment #5, due next Friday! Lean heavily on any internet cheat sheets you like for this, in order to look up HTML tags and attributes, for instance.
-
Class examples posted
Here are bundled git repos from today’s class:
How to use these: first, download the one you want (to download to the cpsc server, the command is “wget http://stephendavies.org/cpsc350/YOURSECTIONTIME.git“) and then type:
$ git clone YOURSECTIONTIME.git aNewDirectoryName
to unpack it.
-
“the current cheat sheet”
The most up-to-date version of my “Flask cheat sheet” has now been posted.
-
Assignment #2 graded
Assignment #2 is finally in the books — sorry for it taking so long! Here’s the rubric I used, for those who are interested. Note that this was a “spot check” grading process (although it sure didn’t feel like it!) meaning that just because you didn’t lose points for something doesn’t mean it’s 100% correct. (I only checked a subset of things.)
Lots of good (and bad) airplane jokes; my personal favorite was:
Two airplanes are flying from Denver to Cleveland. One says to the other, “How’s the weather up there?” The other one says, “Aaahhhh, a talking airplane!”
Great job this semester, people! Congrats especially to WinifredSanderson, DoingMyBest, Chef Boyardee and the many others who have reached the Peanuts! Popcorn! level!
-
“the current date”
You should consider any attempt to book airline tickets for a flight “before the actual current date” as an attempt to book airline tickets “in the past” and therefore reject it. Do not use any specific, hardcoded date mentioned in the assignment (or anywhere else) as “the current date.”
How do you find out what “the actual current date” is in Python? Honestly can’t remember. Google “get current date in Python” and I’m sure it’ll tell you.
-
Homework #3 clarifications and extension
Lots of email questions today and yesterday when I was recovering from my Covid shot and offline, so let me try to answer some of them, and also give you guys a couple more days on this. (Homework #3 is now due midnight Tuesday, Oct 8th.)
- I’m getting several questions of the form, “hey Stephen, for case XYZ, am I supposed to use the ‘flight_type’ table or the ‘scheduled_flight’ table? The answer to all such questions is: “I don’t really know, since your database schema is different from everyone else’s and I don’t have yours memorized.” The basic rule is: the information needed to present the user experience described in the homework needs to be supported somewhere by your schema. If there’s actually no place to put said information, then you’ll need a schema change. In most cases, I think it’s instead just a matter of reasoning things out.
Example: when the user says they want to purchase tickets, you need to figure out whether there are enough tickets remaining on that flight or not. This will require that you know how many total seats the airplane carries (which may come from one table) and also how many people have already purchased tickets for that flight (which may come from another). It’s totally kosher and legit to use more than one table in this way to deal with a complex situation like ticket purchasing. (I get the feeling some students think it’s a mistake if they end up having to do that. It’s not.)
The only time you’d need a schema change is if you scratch your head and say something like “umm…I don’t actually have a place to store the current number of passengers on this day’s flight” or “umm…I don’t actually store the number of tickets sold for an individual day’s American 36, but only for American-36-flights-in-general.” That means your schema is slightly borked and needs to be fixed. If you have your code from homework #2 in a text (.sql) file, it should be easy enough to make changes and re-run it to produce an altered schema. If you need another way, the ALTER TABLE statement is how to do this (which you can Google or ask me questions about.) - A few people are misinterpreting the “data part” of the assignment somewhat. Let me clarify. Your goal in homework #3 is to write a working Python program that will work with whatever information the database currently contains. All of the example flights, airlines, etc that I gave in the assignment description are merely examples. For instance, just because on the assignment my first prompt has Air Blue, American, Frontier, etc as the airlines does not mean that your program should show those specific airlines. If they’re in your database, it should. If they’re not, it shouldn’t.
- If there’s any information missing in your database that you need to support this program, please feel free to make up facts and insert them. This may be the case for the stuff that was in homework #2: I might well have not provided all the facts every table needs to be complete. In this case, just add whatever rows/values you need to in order to make it work.
Example: let’s you have a ‘flight type’ row in your database for Frontier 999, and that flight type specifies a Boeing 666 aircraft type, but there is no Boeing 666 entry in your ‘aircraft type’ table. In this case, you don’t know how many seats are possible to sell on a Frontier 999, since you don’t know how many seats a Boeing 666 aircraft possesses. Solution: make it up. Give the Boeing 666 a total of 9 seats, or 572 seats, or 13 seats, or whatever number you like. The purpose of this assignment is just for your program to operate properly, not to match any specific set of data.
- I’m getting several questions of the form, “hey Stephen, for case XYZ, am I supposed to use the ‘flight_type’ table or the ‘scheduled_flight’ table? The answer to all such questions is: “I don’t really know, since your database schema is different from everyone else’s and I don’t have yours memorized.” The basic rule is: the information needed to present the user experience described in the homework needs to be supported somewhere by your schema. If there’s actually no place to put said information, then you’ll need a schema change. In most cases, I think it’s instead just a matter of reasoning things out.
-
UGH quiz question 2
Because question 2 of quiz 2 involved something I had forgotten to talk about in class, I tried to tell Canvas to give everyone the point for that item regardless of what they answered. However, for at least one student, that extra point did not go through. It definitely looks like a Canvas bug to me.
At any rate, if you look at your quiz score in Canvas, including the point for question 2, and your total does not match what’s on the scoreboard for you, be sure to tell me so I can give you that point. I apologize on behalf of Canvas International for that being messed up.
(Btw, if you haven’t already discovered this, you can see all the XP you’ve gotten broken out by item by using the third tab (“My XP”) on the scoreboard page.)
-
Happy to regrade formatting-related issues
If you missed points on this (or any) quiz because your answer was conceptually correct but not formatted like any of my answer choices (like if you put "K9 | 12" with spaces instead of "K9|12" on question 9) please do speak up! I’m happy to give you the points back in these cases!
-
shinko.py and colby.py posted
From today’s class, the 12:30 version and the 3:30 version of the Ben & Jerry’s interactive ordering program (and the database itself, too).
-
Zoom link
Just a reminder that the link for today’s Zoom session is in the announcement I posted in Canvas at the very beginning of the semester.
-
Assignment #3 posted!
Assignment #3 (console interfaces) has been posted, and is due on Sunday.
Imagine that: a programming assignment! :-O
-
All-virtual office hours
If you hadn’t already guessed, office hours will be on Zoom only this week. Just drop me an email if you’d like to hook up!
-
Quiz #2 clarification
A couple students asked a question about Item 9 on the quiz: why is the answer 5, not 4? The tables in question were PETS:
+----------------------+----------+----------+ | owner | dog | numYears | +----------------------+----------+----------+ | Laura Ingalls Wilder | Jack | 5 | | Veronica Mars | Backup | 3 | | Robert Barone | Chamsky | 9 | | Laura Ingalls Wilder | Bandit | 2 | | Fourth Doctor | K9 | 4 | | Sarah Jane Smith | K9 | 8 | | Raj Koothrappali | Cinnamon | 5 | | Emily Elizabeth | Clifford | 6 | +----------------------+----------+----------+
and CHARACTERS:
+-----------------------------+----------------------+-------+ | show | character | debut | +-----------------------------+----------------------+-------+ | Little House on the Prairie | Laura Ingalls Wilder | 1974 | | Clifford the Big Red Dog | Emily Elizabeth | 2000 | | Doctor Who | Fourth Doctor | 1974 | | Doctor Who | Sarah Jane Smith | 1973 | | The Mandalorian | Greef Karga | 2019 | +-----------------------------+----------------------+-------+
The query in question was this:
select count(*) from pets join characters on owner=character;
The students asked, “why doesn’t this give you 4 rows, since table rows must be unique and therefore Laura Ingalls Wilder can’t appear twice?”
But realize that this query isn’t a “select owner” or “select distinct(owner)“; rather, it’s a “select *“. So therefore, you’re counting the entire number of rows returned by the join, not the number of distinct owner names (or any other attribute).
If you get rid of the count(*) and just use * to see the whole table of results, you get:
+----------------------+----------+----------+-----------------------------+----------------------+-------+ | owner | dog | numYears | show | character | debut | +----------------------+----------+----------+-----------------------------+----------------------+-------+ | Laura Ingalls Wilder | Jack | 5 | Little House on the Prairie | Laura Ingalls Wilder | 1974 | | Laura Ingalls Wilder | Bandit | 2 | Little House on the Prairie | Laura Ingalls Wilder | 1974 | | Fourth Doctor | K9 | 4 | Doctor Who | Fourth Doctor | 1974 | | Sarah Jane Smith | K9 | 8 | Doctor Who | Sarah Jane Smith | 1973 | | Emily Elizabeth | Clifford | 6 | Clifford the Big Red Dog | Emily Elizabeth | 2000 | +----------------------+----------+----------+-----------------------------+----------------------+-------+
As you can see: 5 rows, with no duplicate rows.
-
It’s the little things in life
I just finished grading quiz #2, and believe it or not, every single student who took it managed to type and sign the Honor Pledge correctly!
That puts me in such a good mood that I just awarded all quiz #2 takers with a free XP. Keep up the attention to detail!
Also — a quick shout-out to OldGoldBones, A 1969 Triumph TR6, and all the others who just made the jump to PiƱa Colada!
-
Turning in physical things next week
I’m planning on avoiding campus entirely next week, so nothing you put in my “350” manila folder (or anywhere else) will actually make it into my hands before the week following. This is okay, and all such items will be considered on-time as long as it’s in my folder by Monday morning Oct. 7th.
(Oct. 7th — wow, hard to believe it’s been a whole year.)
-
IMPORTANT: please read
The bevy of Covid cases sweeping through CPSC is scaring me enough that I want to take some evasive action. For this reason, class will be online this coming week (Oct 1 and 3). The Zoom link is in the Canvas announcement I made before the beginning of the semester. If you have trouble finding it, please let me know ASAP.
Class online will be just as important as class in person, so please do attend both sessions. Also, my Zoom practice is to mandate that your cameras must be on during the entirety of lecture. In all other respects, treat it as just a normal class, together with some possible breakout activities.
See you online Tuesday at 12:30pm or 3:30pm!
-
If you’re not on campus
You can send me a scan of your Halloween SQL queries today, and I will count it as “on time.” Then, give me the hardcopy on Tuesday.
-
Stephen’s Halloween solutions
Here are my solutions (and the SQLite database) to Tuesday’s Halloween-themed activity. Do not look at these until your team has turned in your answers to my “350” manila folder!
-
More SQL practice
For Maddy, Bill, and others who have requested more SQL practice, here are some other practice queries that you can run on the Ben & Jerry’s database, and their solutions.
-
Halloween XP activity
Please turn in your team’s legible Halloween-themed XP activity solutions to the “350” manilla folder hanging outside my office by midnight tonight.
-
Class canceled today
I’ve just had the seventh email from a student saying they won’t be in class today because they’re sick. This poses two problems: (1) I was going to start something important and new today, and all those students are going to be lost in the sauce, and (2) it sounds like there’s an outbreak going around and so maybe we’d all be safer staying away.
I’ll post something a little later with some more SQL practice, since several students have also said they’re struggling with that and need some more reps. Stay tuned. And stay safe!
-
Stephen’s B&J query solutions
Here are my answers to the Ben & Jerry’s sample queries we did in class last Thursday and today. Studying these would be well worthwhile!
-
NULLs are okay if there’s missing information
Is it okay to have NULL values in your airline database? Yes! There are plenty of places where I incompletely specified things, and for any cell of any table that the answer was not specified for, a NULL is the right thing!
-
Quiz #2 posted!
Quiz #2 has been posted to Canvas, and is due Saturday at midnight.
Happy querying!
-
Office hours zooming
My Zoom is taking up more CPU cycles than I’d like, so I’m going to shut it off when not in use.
If you’d like to Zoom during office hours, please just send me an email, and I’ll be happy to open up!
-
Assignment #2 posted!
Assignment #2 (SQLite) has been posted, and is due in a week. Don’t delay getting SQLite downloaded (or refreshing yourself on the process of accessing the cpsc server) and on scrutinizing your graded assignment #1!
-
SQLite cheat sheet posted!
For your pleasure!
-
Massive office hours overhaul
For various reasons, I’m going to be radically switching my office hours around between now and Thanksgiving to be in the evening. The new office hours, starting this week, are in James Farmer Hall 044, or on Zoom, at the following times:
- Mondays 7-9pm
- Tuesdays 7-8pm
- Wednesdays 7-9pm
or by appointment.
As always I’m willing to try and accommodate those who need to meet at another time, subject to joint negotiation.
-
Assignment #1 graded
Assignment #1 has been graded, and grades have been posted on the scoreboard. Here’s the rubric I used if you’re interested in how your score breaks down.
Also: if you’d ever like a breakdown of your XP so far (so you can see how many points you got on a given assignment) check out the “My XP” tab (second tab) on the scoreboard page.
And props to cheese pizza and Bonsai, who actually don’t seem dazed or confused at all!
-
LOL breaking news
This just in.
-
Thursday afternoon, 9/12
It is with great reluctance and a heavy heart that I announce the cancellation of Thursday’s lecture. However, you and up to two partners of your choice can still earn +5XP by legibly completing this activity together and putting your solutions in my manila envelope by Thursday night at midnight.
If you already know of partners you want to work with, and have a way to contact them outside of lecture time, go for it. Otherwise, just show up to the normal room at class time and join up with somebody there!
-
Missing from Canvas?
At least one student in the class — who has been enrolled the entire semester, is on the Banner roster, etc — was mysteriously not in the Canvas course (and hence couldn’t take the quiz). No idea why this occurred, but you might just double-check that the same isn’t true for you.
This has been a public service announcement.
-
Office hours virtual today
Hit me up at the usual link.
-
Running very slightly late…
…we do have class today — wait for me!
-
About those XP cards…
I don’t think I ever managed to tell the second class exactly what the sitch is regarding XP cards.
So: those cards that I hand you as a reward for in-class exercises should be treated as cash. They are each good for the number of XP it says on the card. They cannot be traded to other students, sold, re-used from previous Stephen classes, or forged.
At two points in the semester — fall break and final exam — you will have the opportunity to turn in to me your physical XP cards (which you’ll staple and write your names on) and I’ll post those points on the electronic scoreboard along with everything else.
Bottom line: until fall break, all you have to do with your XP cards is manage not to lose them!
-
Office hours virtual next Monday
FYI, Monday’s office hours will be virtual (over Zoom). You can find the link in the opening semester Canvas announcement.
-
Runway length == takeoff length
You should assume that the number of feet it takes a particular aircraft to take off is the same number of feet that it takes it to land. (Not actually sure whether this is true, or which length would be longer if not. But we’re in Stephenworld, so that’s the rule we’ll use.)
-
Quiz #1 posted!
Quiz #1 has been posted to Canvas, and is due by midnight, Thursday Sep 12th. You’ll know everything you need to know by the end of class on Thursday the 5th, however, so feel free to take it any time after that.
The quiz is open-book, open-notes, closed-other-humans, closed-other-Websites, closed-ChatGPT-and-other-AIs, and timed at 40 minutes.
-
Assignment #1 posted!
Assignment #1, involving conceptual schemas, has been posted. Weirdly, I made it due before Assignment #0 is due (and scooched the assignment #0 deadline forward a couple days).
Yes, I agree that ordering is weird. Just worked out that way.
Start early and ask questions!!
-
codingbat.com practice
You can earn up to +2XP per week by spending 30 minutes (per week) completing codingbat.com problems. All you need to do to claim these points each week is send me an email on Friday of the given week with subject line “CPSC/DATA 350 codingbat XP“. In the body of the email, you should type “I spent 30 minutes this week working Python exercises on codingbat.com,” followed by the Honor Pledge and your full name as a signature.
Happy coding!
-
Assignment #0 posted!
Your first graded assignment of the semester — shaking out your Python cobwebs — has been posted, and is due Monday, Sep 9th at midnight. Send questions!
-
Scoreboard sign-up!
Okay everybody, it’s time to earn your very first XP (experience point) of the semester, which is not only admirable in itself but is also required in order to earn any other XP at all!
All you need to do is head over to the Scoreboard (see link at top of page) and add yourself as a new student. Be sure to choose a screen name that is super secret, that you have never used before, and that you will not reveal to anyone.
-
Welcome!
Greetings, Earthlings, and welcome to the fall 2024 version of CPSC/DATA 350: Applications of Databases with Stephen! This site is gonna be hip-hoppin’ with all kinds of great stuff real soon, so stay tuned!