Practice Problem 4: 2-Table Course Schedule Input/Display, due Thursday, 10/12
Objective: To add a second, related table to the DataSet from Lab 3
Here are the details and rules:
- Write a program to allow the user to enter and view their couse schedule like
this program (If link doesn't seem to work, right-click on it and select "Save Target As", then
execute the program after saving it.)
- No database access is necessary for this program.
- Use a DataSet to store the data, and that DataSet should be created in code that you write.
- In addition to the DataTable from Lab 3 that stores course info, you should add another DataTable to
the DataSet: one which stores course IDs and student IDs - indicating which students are taking which
courses. (Imagine there's a student table with student names and info that's not included here.)
- The two DataTables need to have a relationship established between them using a DataRelation object
in the DataSet, with the ForeignKeyConstraint enforced.
- If the user tries to add a record to this new DataTable with a course ID that doesn't exist in the
list of courses above it, your program should generate an error message and allow the user to fix the
problem (becuase the ForeignKeyConstraint would be violated).
- Also, if the user tries to add the same combination of course ID and student ID twice (two identical
records), this should generate an error message without crashing the program (create a UniqueConstraint
to monitor this.)
- When turning in your homework, zip up your entire solution and e-mail the zip file to
cpersiko@ccsf.edu
Return to main CS 112D page