Specifications
The first way means adding a Review column to the Books table. This way, there is a field for
the Review to be added for each book. If many books are in the database, and the reviewer
doesn’t plan to review them all, many rows won’t have a value in this attribute. This is called
having a null value.
Having many null values in your database is a bad idea. It wastes storage space and causes
problems when working out totals and other functions on numerical columns. When a user sees
a null in a table, they don’t know if it’s because this attribute is irrelevant, whether there’s a
mistake in the database, or whether the data just hasn’t been entered yet.
You can generally avoid problems with many nulls by using an alternate design. In this case,
we can use the second design proposed in Figure 7.7. Here, only books with a review are listed
in the
Book_Reviews table, along with their review.
Note that this design is based on the idea of having a single in-house reviewer. We could just
as easily let customers author reviews. If we wanted to do this, we could add the CustomerID
to the
Book_Reviews table.
Summary of Table Types
You will usually find that your database design ends up consisting of two kinds of table:
• Simple tables that describe a real-world object. These might also contain keys to other
simple objects where there is a one-to-one or one-to-many relationship. For example, one
customer might have many orders, but an order is placed by a single customer. Thus, we
put a reference to the customer in the order.
• Linking tables that describe a many-to-many relationship between two real objects such
as the relationship between Orders and Books. These tables are often associated with
some kind of real-world transaction.
Web Database Architecture
Now that we’ve discussed the internal architecture of your database, we’ll look at the external
architecture of a Web database system, and discuss the methodology for developing a Web
database system.
Architecture
The basic operation of a Web server is shown in Figure 7.8. This system consists of two
objects: a Web browser and a Web server. A communication link is required between them. A
Web browser makes a request of the server. The server sends back a response. This architecture
suits a server delivering static pages well. The architecture that delivers a database backed Web
site is a little more complex.
Using MySQL
P
ART II
180
10 7842 CH07 3/6/01 3:34 PM Page 180