CS357: Database Systems Implementation
Solution to Homework Assignment 1



1.  Write a JDBC program to create and populate the GRADEPOINTS table, as defined in Exercise 4.21 of the text.  Note that integers are the only numeric values that can be stored  in a SimpleDB database.  Therefore you should  multiply the points by 10 and store those integers in the GRADEPOINTS table.

See my code for CreateGradepointTable.java.

2.  Write a JDBC program to request a student's name, and to print out the GPA of that student.  Use the definition of GPA from Exercise 4.21(a) of the text.  You can assume that there will be at most one such student having the specified name.  If there is no student with that name, print "No such student".  If that student has taken no courses, say so. Note that SimpleDB's version of SQL cannot do arithmetic calculations, so you will need to do any arithmetic in Java.  Also, don't forget to divide the gradepoints by 10, because of how you stored them in GRADEPOINTS.   (HINT: Use two queries.  First determine if the student exists; then retrieve the course data.)

See my code for CalculateGPA.java.