Overview Schedule Announcements Resources Assignments Home

CSC 121: Computer Science I, Spring 2005

Lab 12

Laboratory 12 - The Company Database

Goals:
Develop an appreciation for database management systems (Access, Oracle, DB2, etc.). Gain experience working with text files, strings, and elements of data management.
Getting started:
The Steps of the Lab:
  1. Open the company project.
    Examine

    This project falls far short of implementing a database management system and will continue to have many deficiencies after you complete this lab. But there are several things you will accomplish that will help make the project a better one from a data management point-of-view.

    If you are not already familiar with the Company database project, you might create an instance of CompanyDB and invoke its methods:

    • addDepartment() - displays the GUI form used to add a department to the database.
    • queryDeptManagers() - executes the query that lists departments and their managers.
    • querySalary(String relop, double sal) - retrieves the name and salary of employees satisfying the condition. For example, querySalary(">=", 30000) lists all employees making a salary of $30000 or more.
    • shutDown() has the responsibility of writing the current state of the database to disk files. At this point it only writes the department table

    Each method above calls a method in another class. addDepartment() calls a method in Deptform, queryDeptManagers() and querySalary(String relop, double sal) call methods in the Query class, and shutDown() calls a method in the Department class.

    Before proceeding through the next steps, become familiar with the methods and fields in each of the classes of the project by looking at their code in the class editor.

    Write

    A Deptform object can be used to add a new department to the database. The Submit button action checks for a blank department name and a blank department number, but not for a department number that is the same as the one currently entered.

    Write a method named find in the DepartmentTable class that has mgrssn as a parameter and returns true or false according to whether there is or is not already a department with that mgrssn.

    Modify the Submit button action, using the find method above to determine whether to add the department represented in the form. If find returns true, do not add the new department (it is already there), otherwise add the department. If the department is not to be added, modify the label at the bottom of the Deptform accordingly.

    Imitate

    Using the save method in the DepartmentTable class as a template, write a save method for the EmployeeTable class. Add a call to this method to the shutDown method in CompanyDB.

    Do

    Write a new query that lists all fields for each employee in a given department. The signature of the method would look like: public void employeeDept(String departmentName). (Hint: First find the dno of the department with the given name, then look at each employee in the employee table to see if that employee's dno is the same. If so, print that employee.)

    Modify

    Add statements to the constructor for CompanyDB so that the forms to add a department and to add an employee are automatically displayed when an instance of CompanyDB is created.

Overview Schedule Announcements Resources Assignments Home

Valid HTML 4.01!Valid CSS!DePauw University , Computer Science Department , Spring 2005
Maintained by Brian Howard ( bhoward@depauw.edu ). Last updated