Archive for September, 2007

char_id* power_id* 1 1 1 2 1 3 (Web host)

Sunday, September 16th, 2007

char_id* power_id* 1 1 1 2 1 3 2 4 3 1 3 5 3 6 As you can see, you have much less repeated data than you did before. The powers have been separated out, and a link table has been created to link each power to each appropriate character. It may seem a bit nitpicky, but you still have some duplicate data that you can take care of in the character table. It is quite possible for more than one character to be in the same lair, as is the case with Clean Freak and Soap Stud. Create a lair table, and link it to the character table with keys. Also add a new column to the character table for alignment. See the two tables that follow. id* lair_id name real name align 1 1 Clean Freak John Smith Good 2 1 Soap Stud Efram Jones Good 3 2 The Dustmite Dustin Hare Evil id* lair address city st zip 1 123 Poplar Avenue Townsburg OH 45293 2 452 Elm Street #3D Burgtown OH 45201 We waited to add the alignment column to illustrate a point. If you are in the middle of the normalization process, and discover that there is some other data you need to add, it isn t difficult to do so. You could even add a completely new table if you needed to. That is one of the great things about relational database design. The city and state fields are not only duplicates, but they are redundant data with the ZIP code (which is in itself a representation of the city/state). City and state are also not directly related to the lairs (because other lairs could exist in the same city). For these reasons, you will put city and state in a separate table. Because the ZIP code is numeric, and a direct representation of city/state, you will make the zip column a primary key. This is pass three, shown in the three tables that follow. 281 Building Databases
Looking for affordable and reliable webhost to host and run your business application? Then look no more and go to servlet web hosting services.

Because in (Web site traffic) this pass you have multiple rows

Saturday, September 15th, 2007

Because in this pass you have multiple rows with the same character and the multiple rows are a result of the existence of multiple powers, you ll combine the ID column with the power column to create the primary key. When more than one column makes up the primary key, it is called a composite primary key. We ll mark the primary key columns with an asterisk (*) to highlight them for you. Your table should look like the one that follows. Call this table one because it s your first pass at normalizing. (Yes, you are in the middle of a normalization process. We told you it wasn t difficult.) id* name real name power* lair address city st zip 1 Clean Freak John Smith Strength 123 Poplar Avenue Townsburg OH 45293 1 Clean Freak John Smith X-ray vision 123 Poplar Avenue Townsburg OH 45293 1 Clean Freak John Smith Flight 123 Poplar Avenue Townsburg OH 45293 2 Soap Stud Efram Jones Speed 123 Poplar Avenue Townsburg OH 45293 3 The Dustmite Dustin Hare Strength 452 Elm Street #3D Burgtown OH 45201 3 The Dustmite Dustin Hare Dirtiness 452 Elm Street #3D Burgtown OH 45201 3 The Dustmite Dustin Hare Laser vision 452 Elm Street #3D Burgtown OH 45201 Looking better, but there is still repeated data in there. In fact, the power column is what is causing the duplicate data. Separate out the power column and use a foreign key to relate it to the original table. You will also further normalize the power table so that you get rid of duplicate data. This is pass number two. See the three tables that follow. id* name real name lair address city st zip 1 Clean Freak John Smith 123 Poplar Avenue Townsburg OH 45293 2 Soap Stud Efram Jones 123 Poplar Avenue Townsburg OH 45293 3 The Dustmite Dustin Hare 452 Elm Street #3D Burgtown OH 45201 id* power 1 Strength 2 X-ray vision 3 Flight 4 Speed 5 Dirtiness 6 Laser vision 280 Chapter 10
You want to have a cheap webhost for your apache application, then check apache web hosting services.

Web design - Designing Your Database It s time to design your

Friday, September 14th, 2007

Designing Your Database It s time to design your application. This will be a relatively simple application, but it will help you learn important concepts such as normalization and expose you to various SQL commands. Typically, this is where you would go through a Try It Out section and learn How It Works. When first designing a database, however, you do not need your computer. All you need is a pad of paper and a pencil. So, go get a pad of paper and a pencil. We ll wait. OK, let s draw some tables. The application you are going to design is a comic book character database. You will store a little bit of information about various characters, such as their alter ego, their real names, the powers they possess, and the location of their lair. (Yes, that s right. We said lair. ) Creating the First Table Before you open MySQL and start mucking around with tables, you need to figure out how you are going to store all of the data. For simplicity, create one big table with all of the relevant data. You can draw it out on your piece of paper, or if you just can t stay away from your computer, use your favorite spreadsheet program. Copy the information you see in the table that follows. name real name power 1 power 2 power 3 lair address city st zip Clean John Strength X-ray Flight 123 Poplar Townsburg OH 45293 Freak Smith vision Avenue Soap Efram Speed 123 Poplar Townsburg OH 45293 Stud Jones Avenue The Dustin Strength Dirtiness Laser 452 Elm Burgtown OH 45201 Dustmite Huff vision Street #3D Call this table zero, because you re not even at the first step yet, and that data is just ugly (from a relational database standpoint). The first thing you should notice is that there are multiple power columns. What would you do if you had to add a character with more than three powers? You would have to create a new column, and that s not good. Instead, you should combine all the powers into one column, and then separate each power into its own separate row. The other columns are duplicated in these additional rows (so, Clean Freak would have three rows instead of one, each row including a different power in the power column, but the name, address, and so on would remain identical among the three listings). This concept is called atomicity. Each value (cell) is atomic, or has only one item of data. You also should create a unique primary key for each character. Yes, you could use the character s name, but remember that a primary key should never be something that could change, and it must be unique. To handle this requirement you ll create an ID column. 279 Building Databases
Please visit our professional web hosting services to find out about cheap and reliable webhost service that will surely answer all your demands.

My web site - There are three types of relationships: one-to-one (1:1),

Thursday, September 13th, 2007

There are three types of relationships: one-to-one (1:1), one-to-many (1:M), and many-to-many (M:N). The previous example is a one-to-many relationship. To figure out what type of relationship the tables have, ask yourself how many superheroes you can have in a league. The answer is more than one, or many. How many leagues can a superhero belong to? The answer is one. That is a one-to-many relationship. (Of course, in some universes, a superhero might belong to more than one league. But for this example, our superheroes exhibit league loyalty.) One-to-many is the most common database relationship. 1:1 relationships don t happen often, and a many-to-many relationship is actually two one-to-many relationships joined together with a linking table. We explore that further later in the chapter. Although they are more rare, here s an example of a one-to-one (1:1) relationship just so you know. Say you have a link between a company and its main office address. Only one company can have that exact address. In many applications, however, the main office address is included in the company table, so no relationship is needed. That s one of the great things about relational database design. If it works for your needs, then there is no wrong way to do it. Referential Integrity The concept of referential integrity may be a little lofty for a beginner book like this, but we think it is important to touch on this briefly. If your application has referential integrity, then when a record in a table refers to a record in another table (as the previous example did), the latter table will contain the corresponding record. If the record it references is deleted, you have lost referential integrity. In many cases, this is not disastrous. You might have an article written by an author whose name no longer exists in the author table. You still want to keep the article, so losing the referential integrity between authors and articles is okay. However, if you have an order in your database that can t be related to a customer because the customer was deleted, then you might be hard-pressed to figure out where to send the product and who to charge for it. Ways exist to enforce referential integrity in a MySQL database, but these concepts and procedures are beyond the scope of this book. If you are interested in obtaining more information about referential integrity and foreign keys, visit www.mysql.com/doc/en/InnoDB_foreign_key_constraints.html. Normalization Database normalization is one of those big fancy terms that database administrators like to throw around, along with Boyce-Codd Normal Form, trivial functional dependency, and Heisenberg compensator. They aren t really important terms to know to be able to design a good database, but we ll touch on normalization here. For our purposes, we will simply define normalization as the process of modifying your database table structure so that dependencies make sense, and there is no redundant data. In a moment, you are going to go through this process. The best way to learn is to do! 278 Chapter 10
Note: In case you are looking for affordable and reliable webhost to host and run your j2ee application check Vision J2ee Web Hosting services.

Web hosting compare - At first glance, it may seem silly to

Wednesday, September 12th, 2007

At first glance, it may seem silly to create a table with one data column and an ID. Why not just put the league name in the superhero table? Imagine that you had a database of 10,000 superheroes, and 250 of them were in the Dynamic Dudes league. Now imagine that the Superhero Consortium decided to do a reorganization and Dynamic Dudes was changed to the Incredible Team. If the league name were in the superhero table, you would have to edit 250 records to change the value. With the leagues in a separate, related table, you have to change the name in only one place. That relationship is the key to a relational database. And speaking of keys . . . Keys A key is a column where each item of data appears only once in that column. Therefore, the key uniquely identifies each row within the table, because no two rows can have the same key. Each table is allowed to have one special key that serves as a primary unique identifier for the table, called a primary key. Most of the time, the primary key is a single column, but it is not uncommon to use more than one column to make up a primary key. The important distinction is that for each row, the primary key must be unique. Because of that characteristic, you can use the key to identify a specific row of data. The primary key must contain the following characteristics: . It cannot be empty (null). . It will never change in value. Therefore, a primary key cannot contain information that might change, such as part of a last name (for example, smith807). . It must be unique. In other words, no two rows can contain the same primary key. The League_ID column in the superhero table is also a key. It matches the primary key of the league table, but it is in a different, or foreign, table. For this reason, it is called a foreign key. Although it is not a requirement, many programmers will give the foreign key a name that identifies what table it refers to ( League ) and some identifier that marks it as a key ( _ID ). This, along with the fact that keys are usually numeric, makes it fairly clear which column is the foreign key, if one exists in the table at all. Keys do not have to be purely numeric. Other common values used as primary keys include Social Security numbers (which contain dashes) and e-mail addresses. Any value is valid as a primary key as long as it is guaranteed to be unique for each individual record in the table and will not change over time. Relationships In order to be related, the two tables need a column they can use to tie them together. The superhero and league tables are related to each other by the League_ID column in the superhero table and the ID field in the league table. There is no explicit link created in the database; rather, you create the relationship by linking them with a SQL statement: SELECT * FROM superhero s, league l WHERE s.League_ID = l.ID In plain English, this statement tells the MySQL server to select all records from the superhero table (call it s ) and the league table (call it l ), and link the two tables by the superhero League_ID column and the league ID column. 277 Building Databases
Searching for affordable and proven webhost to host and run your servlet applications? Go to Linux Web Hosting services and you will find it.

So you have a great idea for a (Windows 2003 server web)

Tuesday, September 11th, 2007

So you have a great idea for a Web site and a plan. What do you suppose is the first step in creating a successful Web application using PHP, Apache, and MySQL? We ll give you a clue: Look at the title of this chapter. You need to build the database this site will be based on. Don t worry one of the great things about relational database design is that you don t have to create every table your site will use. You can start with a few, and build on it. As long as you follow the basic principles of good database design, your database should be quite scalable (that is, expandable to any size). Sound like a daunting task? Don t worry. You see, we know a secret that has been kept hidden like the magician s code: Efficient database design is easy. No, really, we promise! You see, most of us computer geeks like to seem invaluable and very intelligent, and it sounds quite impressive to most interviewers to see on a resume Designed a comprehensive Web site utilizing an RDBMS backend. When you are done with this chapter, you will be able to put that on your resume as well! What Is a Relational Database? Let s first cover a few basics of database design. The relational database is a concept first conceived by E. F. Codd of IBM, in 1970. It is a collection of data organized in tables that can be used to create, retrieve, delete, and update that data in many different ways. This can be done without having to reorganize the tables themselves, especially if the data is organized efficiently. Take a look at the first table that follows. You can see that it contains a very simple collection of data consisting of superheroes aliases and real names, and their superhero ID. Nothing too amazing, of course, but notice how it relates to the league table that follows it. Each superhero user has a League_ID that corresponds to an ID in the league table. Through this link, or relationship, you can see that Average Man is a member of the Dynamic Dudes League because the ID in the league table matches his League_ID in the superhero table. ID League_ID Alias Real Name 1 2 Average Man Bill Smith 2 2 The Flea Tom Jacobs 3 1 Albino Dude George White 4 3 Amazing Woman Mary Jones ID League 1 Extraordinary People 2 Dynamic Dudes 3 Stupendous Seven 4 Justice Network 276 Chapter 10
From our experience, we are can tell you that you can find a reliable and cheap webhost service at Java Web Hosting services.

10 Building Databases In (Affordable web design) previous chapters, you created

Monday, September 10th, 2007

10 Building Databases In previous chapters, you created a very nice movie review Web site, but now the hand-holding is over, my friend. It s time for us to push you out of the nest. In this chapter, you will have the opportunity to create your own databases and your own Web site. We show you how to put together a comic book appreciation Web site, but you can take the concepts we teach you and branch off to create that online auction or antique car site you have always dreamed about. We think the comic book appreciation Web site is cooler, but whatever. You do your thing. This chapter covers the basics of creating your own database. Topics discussed include: . Planning the design of your database . Database normalization . Creating your database . Creating and modifying tables in your database . Building Web pages to access your data with PHP Getting Started You have a great idea for a site, right? Excellent. Open up your PHP editor and start coding! Believe it or not, many people approach the creation of a Web site in just this way. You may be tempted to do this yourself. It is not impossible to create a good site in this manner, but you are seriously handicapping your chances for greatness. Before you begin, you need a plan. We re not going to tell you how to plan out an entire Web site, complete with charts and maps and business models. That s not what this book is about. We are going to assume that you or somebody in your company has already done that by reading other great books on business models, attending seminars, reading great articles on the Web, and perhaps even hiring a business consultant who will help you with everything but building the site (because that s what we re going to teach you how to do).
Searching for affordable and proven webhost to host and run your servlet applications? Go to Linux Web Hosting services and you will find it.

Part III: Comic Book Fan Site Chapter 10: (Best web design)

Monday, September 10th, 2007

Part III: Comic Book Fan Site Chapter 10: Building Databases Chapter 11: Sending E-mail Chapter 12: User Logins, Profiles, and Personalization Chapter 13: Content Management Chapter 14: Mailing Lists Chapter 15: Online Stores Chapter 16: Discussion Forums Chapter 17: Learning About Users with Logs Chapter 18: Troubleshooting
You need excellent and relaible webhost company to host your web applications? Then pay a visit to Inexpensive Web Hosting services.

Parse Errors A parse error (Florida web design) is another main

Sunday, September 9th, 2007

Parse Errors A parse error is another main error type. Parse errors occur when you forget a semicolon, when curly braces are mismatched, when square brackets aren t used properly, and so on. These parse errors usually don t have to do with a condition statement; they are mainly syntax errors that will cause the script to halt execution. Parse errors are worse than fatal errors because they won t even let the script run at all; they merely give you the error information. Summary You have read through a lot of useful information in this chapter. Learning from your own mistakes and errors will help you to be quicker at noticing small, trivial mistakes that are causing problems in your code. The single best action a programmer can learn is how to troubleshoot. Once you have that figured out, nothing can hold you back from creating seamless applications that will impress you and your clients. Exercises Here are three short snippets of code to sift through. Try to spot the errors and figure out how to fix them. The answers are provided in Appendix A. Once you are finished, based on what you have learned, create a little error-catching script to catch the errors. 1. 2. 3. 272 Chapter 9
Visit our web design programs services for an affordable and reliable webhost to suit all your needs.

Not Meeting Conditions Error (Web host) trapping cannot catch all

Saturday, September 8th, 2007

Not Meeting Conditions Error trapping cannot catch all problems in your code. It will catch only problems related to PHP itself. Any problems you are having with conditions in your code will not be caught by simple error trapping. You ll have to do this manually by using several different methods of troubleshooting in your code. For example, say you are submitting a form and you are wondering why the condition isn t true when you are checking for submission. Suppose you have an input such as this: You are checking to see whether the submit button has been pressed to then see whether or not you should process the form information. You are probably doing a check similar to this: if ($_POST[ submit ] == submit ) { //form has been submitted } else { //form has not been submitted } See if you can figure out what is wrong with the code causing you not to get the if statement. Here s a hint: The value of the submit button is Submit , not submit . To troubleshoot to see if your condition is working or not, you can simply put a line in your if statement such as this: echo In the if statement ; If you get into the if statement, the echoed line is output to the browser. If you don t change the lowercase submit to an uppercase Submit, you don t see that echo in the browser, so you can then further investigate why you aren t getting into the if statement. Once you realize the error, you can change the case and test it again, and voil , the line has been echoed. You will find that you need to use this technique to establish where in your code actions are happening. Not only do you want to do this with if statements, but you will probably be using it to test for loops, while loops, foreach loops, do while loops, and many others at other times when you are running conditions, or are expecting results and you can t figure out why something isn t working. Another common problem is when variables aren t being output. Most of the time, the variables are just fine, but the programmer can t figure out why they aren t being output. Again, the conditions aren t being met, and if a condition isn t met and the expected variables are in the condition, they obviously aren t going to be output. Many programmers run into this problem and have a hard time figuring it out. They tend to lay blame on the variables before checking to see whether or not their conditions have been met. Sometimes the variables are the reason for the condition not being met, as shown in the previous paragraph. The programmer uses the wrong value to check the if statement and the condition fails. The best thing for you to do in this situation is to troubleshoot. Throw an echo here and an echo there to see where your problems are. Don t give up at the first sign of defeat: You should exhaust all of your own programming resources before you go looking for help elsewhere. 271 Handling and Avoiding Errors
We highly recommend you visit web and email hosting services if you need stable and cheap web hosting platform for your web applications.