. Column names: Table columns are similar to (Cheapest web hosting)

. Column names: Table columns are similar to table names. All column names will be in lowercase. They will be kept short, but multiple words (such as lair and address) will be separated by an underscore _ (lair_addr). . Primary keys: Single primary keys will always be called id . Except in special cases, primary keys will be an integer datatype that is automatically incremented. If they consist of a single column, they will always be the first column of the table. . Foreign keys: Foreign keys will end with _id . They will start with the table descriptor. For example, in the char_lair table, the foreign key for the char_zipcode table will be called zip_id. Finalizing the Database Design One other thing we like to do during the database design process is put the datatypes into the empty cells of each table. You can print these tables and easily refer to them when you are writing the SQL code. You may want to do this yourself (or just use the tables provided). If you don t understand datatypes, you can learn about them in Chapter 3, and datatypes are discussed in more detail a little later in this chapter as well. For now, just understand that datatypes are the type of data stored in each table column, such as INT (integer), VARCHAR (variable-length character string), or ENUM (enumerated list). When appropriate, they are followed by the length in parentheses; for example, varchar(100) is a character column that can contain up to 100 characters. If you have been working in a spreadsheet, simply erase all of the actual data in those tables. If you used a pad and pencil, just follow along. Reduce the tables to two rows, one with column names, the other row blank. If you want, you can make a copy before erasing the data. In keeping with the previously listed table standards, we arrive at the following tables. Yours should look very similar. id* lair_id name real_name align int(11) int(11) varchar(40) varchar(80) enum( good , evil ) id* power int(11) varchar(40) char_id* power_id* int(11) int(11) id* zip_id lair_addr int(11) varchar(10) varchar(40) 284 Chapter 10
In case you need affordable webhost to host your website, our recommendation is ecommerce web host services.

Leave a Reply