A Database Management System can solve all the kinds of problems we just defined. A Database Management System (DBMS) is a product that provides a well-defined interface to read and write data to external files. Employing a DBMS yields many benefits.
The happiest benefit may be that we don't have to write low-level code. We don't have to parse text and we don't have to worry about outputting data to a file. All we have to do is learn a few commands, and then we can concentrate on the application code and let the DBMS manage the records.
A DBMS is carefully optimized to process commands very quickly. Unless we were willing to code our application in assembler (byte-by-byte machine code), it would be impossible for us to match the speed of a DBMS. While this may not be evident with the processing of simple commands, such as displaying all the objects in a particular portion of a table, it becomes apparent as the queries and the databases become more complex.
Another advantage of a DBMS is that we can streamline the data we get. For instance, instead of transferring all the questions and then counting how many were written by Joe Shmoe, we can have the DBMS transfer back only the number we are looking for. This saves us time because the DBMS is more efficient and also because fewer data must be transferred. The bandwidth problem is obviously critical when the DBMS and the program accessing it are on different machines, but it also occurs when the database and program accessing it are on the same machine.
S CALABILITY AND I NDEX
Scalability is the ability to handle increasingly large files and increasingly large number of users. These are critical concerns on the web. A DBMS scales better than a flat file technique: Doubling the size of a flat file may double the processing time of a request, but a DBMS processing time may increase by only a few percent.
DBMS scaling depends on the use of the index. An index is one way a DBMC organizes records. Indices are internal to the DBMS and they reduce retrieval times by orders of magnitude. However, each index also increases the update time, sometimes substantially.
There are many types of indices, and sophisticated database programmers can specify them for optimization of their applications. The details of optimization are beyond the scope of this book. Instead, we rely on the indexing performed automatically and invisibly by the DBMS itself.
The DBMS allows us to port our source over to other systems that have the same DBMS. We do not have to learn how to read/write files in UNIX, NT, or Sun whenever we wish to reuse our code on another project on another platform. Instead, we install the correct form of the DBMS, copy our code over, and we are set. Theoretically. In practice, of course, small differences between implementations require us to tweak the code.
Further, we can reuse the database without needing to invent tools to extract the data. Not only can we reuse the data in other programs we write, but we can also look at the table manually, via the console. A search through a flat file for all the players whose last name is Smith would be a lot more difficult, time-consuming , and error-prone than to type in
Select * from Players where last_name = "Smith";
and get a near-instantaneous response (slightly longer if there is an enormous number of names ).