I’ve spent the last week developing a new interface for our Web site at work to allow us to insert, modify and remove various course descriptions. The bulk of the time has been spent simply inserting over 500 different course descriptions to get the database populated initially.
However, along the way, I kept running into different items that threw me for a loop, causing me to have to go back and rethink the way I had written the script.
When I initally set up the database, I was under the impression that the three-character code indicating the course subject and the three-digit number indicating the course number (for instance, MTH 101) would be unique together. Therefore, I set up the database to use the subject and the course number as a unique index.
About halfway through, I discovered that there are a few instances where the same course number is used within the same subject to actually describe two different courses. For instance, MTH 101 could be Introduction to Algebra or Introduction to Calculus (it’s not, but I’m just using that to continue the example used above). When the schedules are made up, a section number is appended to the subject and course number to differentiate that particular class offering from any others made in the past. Unfortunately, for the course descriptions, those section numbers do not apply, so I couldn’t use them to differentiate in the database.
Instead, I had to alter the database design to use subject, course number and the course name as a unique index.
Unfortunately, this development is also forcing me to rethink the way I display individual course descriptions. I am currently using the subject code (for instance, MTH) and the course number (which can actually be a one-digit, two-digit or three-digit number) as the dynamic name of the page that displays the individual course description. For instance, http://www.example.com/course-descriptions/MTH101 would show you the course description for MTH 101.
Because it’s possible that there will be more than one course description using MTH101, I have to reconsider how I display them. I am probably going to end up just looping through all of the instances that match the criteria, and displaying them all on the same page. That’s not the ideal solution, but, as far as I’m concerned, neither is any other solution I’ve come up with so far.
The next problem I encountered was when I discovered that, officially, not all of the course numbers are three digits. In fact, some of them are only one digit. That was a fairly easy problem to get around. However, in order to make things a little easier on myself when writing the various regexes I needed, I added a 0 to the beginning of any one-digit numbers. It’s not that big of a deal, and it can probably be changed easily if that causes a problem.
It just sort of took me by surprise, because I’m used to schools using three-digit codes no matter what; even if it did mean padding with zeroes.
One more problem I encountered was the fact that some courses can actually be taken for varying amounts of credits, apparently. Many of the entries in the list of course descriptions actually have values like “1-3 credits”, etc.
Again, when I initially set up the database, I set the credit entry as a tinyint data type. Unfortunately, because of those variables, I had to change it to allow for that sort of thing. That type of variable data will make it much more difficult to do arithmetic with the credit values if there is ever a call for that (though, at this time, there is no call for it, but I could certainly see that coming up in the future).
Finally, I also found out at the very end (three from the bottom, actually; and since I was adding the courses five at a time, that meant it was the last set), that some courses do not have any credit values associated with them.
Just when I thought I was finished, I had to go back and readjust my code to allow for a blank credit value and to not display the word “credits” if the value was blank.
I guess it just goes to show that it really pays to do your homework when developing something like this. I tried to read the list of course descriptions as thoroughly as possible, but I just didn’t think to check for those types of things. I did check to make sure that all of the subject codes were exactly three characters (as I’ve seen some schools where the subject codes can range anywhere from two to four characters), and I even programmed the script not to care whether those characters were numbers or letters (as there are a handful of schools that use numbers in those subject codes for some reason).
Let that be a lesson to you when developing a complicated script with a large amount of data. Any time you think of adding a feature or a restriction within your database or your code, examine your data to ensure that nothing will break that.
Anyway, now that I’ve spent all week copying and pasting course descriptions, I am extremely glad that the weekend has come. I’ve been seeing course descriptions in my sleep for the past few days.