Reggie is a system to handle course registration for a small school. The developers are using a database to maintain information about students and classes. The first version of the database is simple (see Figure 13.1). Figure 13.1. School Registration Database ”First Version
A Course is a class that could be offered . For now, we'll use simple names ("Econ101" for "Introduction to Economics"). Later, this will expand to include a full title, description, and other information about the course. An Offering is a version of a class, taught on some schedule. DaysTimes is a comma-separated string of days and times ("M10,T11,F10"). Again, there will be more information added in development. A Schedule is a particular set of offerings that a student has chosen . There are rules about how schedules can be formed :
Rather than being enforced by the database, these rules are enforced by code that checks schedules.
In the code below, there are three classes corresponding to the tables. They start out small and perhaps are a little too focused on the data, but they're much bigger with database code added. For an introduction to database programming in Java, see the JDBC Database Access trail of the Java Tutorial ( java.sun.com/docs/books/tutorial/jdbc ) or the JDBC Short Course ( developer.java.sun.com/developer/onlineTraining/Database/JDBCShortCourse ). The code uses the JDBC-ODBC driver to talk to a text-file database. |