#native_company# #native_desc#
#native_cta#

PHPLib and Multiple Databases

By Peter Moulding
on November 7, 2000

You have a web site with pages accessing a database. You want to use PHPLIB,
but do not want to change your existing database to suit. Here is the
answer to your dreams. PHPLIB and multiple databases.
This set up requires an extension to PHPLIB and explains how to create the
extension. You may find this article helps you extend PHPLIB in other ways.
Read this article to the end and then think about situations where PHPLIB performs
98% of what you want.
The PHPLIB extension in this article was submitted to the PHPLIB developers.
Therefore, it may appear in a future PHPLIB release. The rest of the code goes in your
pages and will help you organize your database management.

Database Management

You can put every table in one giant database. However, one day it will bite
you. Database management will minimize future pain. What happens when
your database grows too big for one server? What happens when a server
cannot cope with the IO workload or does not have enough memory for all
accesses? Splitting your existing database is hard. Starting with separate
databases is easier and good database management helps.
If you run a book shop, you might have a list of authors, a list of books
with prices, a list of current stock and a list of orders. As your
business grows, the list of orders grows and each order creates a lot of
disk activity. Chances are you will one day put the orders direct in to an
accounting system.
Start off now with the orders in a separate database. As stock quantities
are updated by the orders, put the stock quantities in the same database.
The list of authors and the list of books have static information that is
read often, but rarely updated. In fact, the only update to an author record
might be once each 5 years, when the author writes a new book (or dies).
The data might suit a server with a completely different configuration to
the orders database.

1
|
2
|
3
|
4
|
5
|
6