|
Helping ordinary people create extraordinary websites! |
Using JDBC to Create Database ObjectsBy James W. Cooper2003-05-24
What is a Database? A database is a series of tables of information in some sort of file structure that allows you to access these tables, select columns from them, sort them, and select rows based on various criteria. Databases usually have indexes associated with many of the columns in these tables, so that we can access them as rapidly as possible. Databases are used more than any other kind of structure in computing. You'll find databases as central elements of employee records and payroll systems, in travel-scheduling systems, and all through product manufacturing and marketing. In the case of employee records, you could imagine a table of employee names and addresses and of salaries, tax withholding, and benefits. Let's consider how these might be organized. You can imagine one table of employee names, addresses and phone numbers. Other information that you might want to store would include salary, salary range, last raise, next raise, employee performance ranking, and so forth. Should this all be in one table? Almost certainly not. Salary ranges for various employee types are probably invariant between employees; thus you would store only the employee type in the employee table and the salary ranges in another table, which is pointed to by the type number. Consider the following:
The data in the SalaryType column refers to the second table. We could imagine many categories for such tables for things such as state of residence and tax values for each state, health plan withholding, and so forth. Each table will have a primary key column like the ones at the left of each table above and several more columns of data. Building tables in databases has evolved to both an art and a science. The structure of these tables is refered to by their normal form. Tables are said to be in first, second, or third normal form, abbreviated as 1NF, 2NF or 3NF. 1st. Each cell in a table should have only one value (never an array of values). (1NF) 2nd. 1NF and every non-key column is fully dependent on the key column. This means there is a 1-to-1 relationship between the primary key and the remaining cells in that row. (2NF) 3rd. 2NF and all non-key columns are mutually independent. This means that there are no data columns containing values that can be calculated from other columns' data. (3NF) Today nearly all databases are constructed so that all tables are in Third Normal Form (3NF). This means that there are usually a fairly large number of tables, each with relatively few columns of information. Tutorial Pages: » What is a Database? » Getting Data out of Databases » Kinds of Databases » ODBC » What Is JDBC? » Installing and Using JDBC » Types of JDBC Drivers » Two-Tier and Three-Tier Models » Writing JDBC Code to Access Databases » Registering Your Database with ODBC » Connecting to a Database » Accessing the Database » The ResultSet » ResultSetMetaData » DatabaseMetaData » Getting Information on Tables » Executing SQL Queries, Printing out ResultSets, A Simple JDBC Program » Building Higher Level JDBC Objects » Building a Database Object, A Visual Database Program » Executing a Query » The Query Result Dialog » Example Files » Summary First published by IBM DeveloperWorks |
|