124 Part I . Getting Started ); CREATE TABLE cardtype ( card_id int NOT NULL PRIMARY KEY, card_type varchar(20) ); CREATE TABLE locale ( zip varchar(10) NOT NULL PRIMARY KEY, city varchar(50), state char(2) ); CREATE TABLE manufacturer ( id int NOT NULL PRIMARY KEY, name varchar(50), address varchar(50), zip varchar(10), area_code char(3), telephone_number char(7), contact_name varchar(50) ); CREATE TABLE product ( id int NOT NULL PRIMARY KEY, name varchar(50), price decimal(9,2), quantity integer, manu_id int ); CREATE TABLE producttype ( id int NOT NULL PRIMARY KEY, category varchar(50) ); The varchar column type is chosen because it uses space more efficiently than the char type. The charcolumn type pads the column with extra spaces to fill the length of the column; the varchartype adds only one extra byte to store the length of the column. For example, if char the column type for the city column, the database would always use 50 bytes, regardless of whether the city was named Ames or Stevens Point. The char type is fine for area-code and telephone-number columns (which are always the same length for U.S. phone numbers). The decimal column type is chosen for the product table s price column because the precision can be specified before and after the decimal point. In the example, I use the (9,2) definition that calls for up to 9 digits before the decimal and 2 digits after the decimal. Therefore I can list prices of up to 999,999,999.99 for products in the database. Cross- Reference For a summary of MySQL s column types, see Appendix A. Physical Design and Implementation Once you have a normalized design, turning that design into the actual database and tables on the server is easy.
Note: In case you are looking for affordable and reliable webhost to host and run your j2ee application check Vision web and email hosting services