The Benefits Enrollment application uses three databases. In order for you to understand the example application, this section describes the schemas for these databases. 4.6.1 The Employee DatabaseThe Star Enterprise human resources department maintains information about employees, company departments, and department positions in EmployeeDatabase. The information is stored in three tables. The Employees table within the database holds employee identifying information. Code Example 4.21 shows the SQL CREATE statement defining this table: Code Example 4.21 The Employees Table SchemaCREATE TABLE Employees ( empl_id INT, empl_first_name VARCHAR(32), empl_last_name VARCHAR(32), empl_addr_street VARCHAR(32), empl_addr_city VARCHAR(32), empl_addr_zip VARCHAR(10), empl_addr_state VARCHAR(2), empl_dept_id VARCHAR(10), empl_start_date DATE, empl_position VARCHAR(5), empl_birth_date DATE, PRIMARY_KEY (empl_id) ) The Employees table contains the following columns:
EmployeeDatabase includes two other tables that pertain to the Benefits Enrollment application. The Positions table keeps, in the pos_desc column, a description of each job position within the company. The primary key of this table is the pos_id column, which contains the position identifier. Code Example 4.22 shows the schema for this table: Code Example 4.22 The Positions Table Schemacreate table Positions ( pos_id VARCHAR(5), pos_desc VARCHAR(32), PRIMARY_KEY (pos_id) ) The third relevant table in EmployeeDatabase is the Departments table, which keeps information about each department within the company. Code Example 4.23 shows the schema for this table: Code Example 4.23 The Departments Table Schemacreate table Departments ( dept_id VARCHAR(10), dept_desc VARCHAR(32), dept_mgr INT, PRIMARY_KEY (dept_id) ) The Departments table contains the following columns:
4.6.2 The Benefits DatabaseThe BenefitsDatabase schema defines one table, Selections, pertaining to the Benefits Enrollment application. Code Example 4.24 shows the schema defining the Selections table: Code Example 4.24 The Selections Table Schemacreate table Selections ( sel_empl INT, sel_coverage INT, sel_medical_plan VARCHAR(10), sel_dental_plan VARCHAR(10), sel_smoker CHAR(1), PRIMARY_KEY (sel_empl) ) The Selections table contains the following columns:
4.6.3 The Payroll DatabaseThe PayrollDatabase schema defines one table relevant to the Benefits Enrollment application the Paychecks table. Code Example 4.25 shows its definition: Code Example 4.25 The Paychecks Table Schemacreate table Paychecks ( pay_empl INT, pay_salary FLOAT, pay_ded_benefits FLOAT, PRIMARY_KEY (pay_empl) ) This table maintains two columns: the employee's payroll amount, or salary (pay_salary), and the benefits deduction amount (pay_ded_benefits). The table's primary key is the employee identifier number, which is held in the pay_empl column. |