Chapter 8 Exercise
Purpose:
- Understand SQL Select Statements
- Understand one-to-many (or many-to-many) relationships
- Learn about the Java Date and Calendar classes
- Know how to use JTable
To Do:
- Create two new tables
- student has four fields: ID (autoincrement), firstname,
lastname,
birthday (date)
- courses has six fields: courseID, studentID (foreign key),
courseNo
(varchar), courseDay (varchar) courseTime (int), courseHours (real)
- You may create a third table if you prefer a many-to-many
relationship.
- Display the course information in a JTable
- After you’ve entered
some students and courses, write a
program to do the following queries:
- Display all students who have a course at a
particular time (e.g., all
students with a class at 8)
- Display all students taking a particular course (e.g., all
students taking MACS262)
- Display the sum of credit hours for a particular student.
SELECT SUM(creditHours) … rest of the syntax you know.
- Any other queries you can think of?
Possible input screen:

Possible query screen (created by a student):

Hints:
- See DatePlay for an example of working with dates
- See PetTable or ResultTableModel for an example of using JTable
Submit:
- Submit a zip file containing your program and a sql script to
create your tables.