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.