My Intro to Databases course moved on from XML to JSON, which I have to admit was less motivating for me. JSON has an interesting format, but I don’t really know what I would use it for. In any case, we didn’t spend much time on it. I zipped through that section and onto a more hefty topic: relational algebra.
I had a somewhat satisfying moment when my husband, an electrical engineer, offered to help me with a homework problem I was stuck on. (He is my go-to guy for helping me learn or relearn the more complex math and logic problems I encounter in my computer science courses.) I started to explain the homework problem, when he stopped me: “Wait, what is relational algebra?” I explained the general idea and the allowed operations, and he admitted, “Huh, I have never done that before.” As he wandered back to his own work, I turned back to my desk with even more resolve. A technical concept I could master that he doesn’t already know? I’ll do it!
Although I am still stuck on that homework problem, I am happy to say that it’s one of the optional, challenge-level problems. (And I’ve already finished 2 of the 4 challenge problems!) In fact, the only other really tough part of this section has been using the syntax in the online relational algebra interpreter. I have learned two important lessons:
- Count parentheses carefully
- Build from the inside out
It’s really easy to add or leave out an opening or closing parenthesis, which spells disaster when you try to run the interpreter. But that can be helped by starting with the most basic query and building on that. This is a concept that we used in our intro to computer science classes: Make sure the program runs and gives you the expected output for each piece of your program; don’t write the whole thing and then try to debug it. It works pretty well for database queries, too.
Of course, this all reminds me of when I was managing a small nonprofit organization’s database. I didn’t have to write the SQL queries myself, but I did have to be sure I set up the queries in our database program correctly! Doing relational algebra is almost exactly like setting up those queries, except that I could also rely on things like sorting to help manage the output. It makes me a little more forgiving of the database programs I have worked with. Sometimes I wanted them to be more intuitive about my queries — it was so frustrating to get empty query results because the program couldn’t read my mind! — but it’s perfectly clear now why they have to be so precise.
I guess I will have to sleep on the issues I have with the last two challenge problems:
- How to find a maximum or minimum value
- I almost understand how to solve this, but I don’t have it working quite right yet.
- How to select based on the results of a previous query
- I’m not sure I’m even looking at this problem correctly. Basically, I have the results of a projection on one set of data, and I want to be able to use those results to select data from another set. That doesn’t seem possible, so I’m trying to sneak up on the problem from a different angle. We’ll see how that goes!