Problem Set 7 Grading Guidelines

SQL-specific Guidelines

SQL, unlike anything we’ve seen before in CS50, is a query language—it is meant to interact with a database, not to perform any of the tasks that typically characterize a programming language. There’s not as much freedom as there was with previous languages—generally, students’ approaches to specific queries like those in the Movies assignment will look pretty similar. Regardless, there is still room for thoughtful design:

  • Reasonable line length. Code still reads better vertically than horizontally, so no overlong lines.
  • Structured queries. Nested queries hould be readily identifiable. Most approaches fulfill these requirements, but watch out if someone’s placed their entire query in one long line
  • JOINs and Nesting. In general, more complex queries will be completed one of two ways—with JOINs or with nested queries. Either of these are acceptable on a small enough scale; see the Movies guidelines for examples of both. But performance get wretchedly slow when a student executes three (or worse, four) JOINs on a single database, particularly the iMDB database. This can easily be tested by simply running the relevant query and seeing if it takes more than a second or two.
  • Minimal Redundancies. Despite the fact that SQL is not a programming language, the never-write-the-same-code-twice rule still holds; redundancy is still to be avoided
  • Consistency. If a student establishes a pattern for their syntax, it’s imperative to hold them to that pattern—inconsistency is much worse than idiosyncrasy in this case. This will be a general rule from here on out, whenever syntax isn’t standardized (i.e. for HTML)

Problem Guidelines