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

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.