Designing the Databases
Once you have figured out how to organize the data, your next big decision is to determine the number of databases you should use. We settled on four databases in the Sales application; they are customers, products, orders, and categories.
- Customers
The customer database contains the information about the customers. Each customer record contains five items:
- Customer ID
A unique customer code assigned at corporate headquarters. If a new customer is created on the handheld, it is assigned a temporary negative customer ID. Corporate headquarters is responsible for assigning a permanent ID after a HotSync.
- Name
A string.
- Address
A string.
- City
A string.
- Phone
A string.
The order in the database is the order in which they are displayed in the list. New customers are added at the beginning. There are at least two possible ways to reasonably organize the customer database—alphabetically or by visit order (the first name is the first customer the salesperson visits, the second name is the second visit, and so on).
- Products
The product database contains information about each of the toys that can be ordered by the customer. Each product record contains:
- Product ID
An integer. This is assigned by corporate headquarters.
- Price
A number. This is a cent amount that we can store as an integer rather than as a floating point number.
- Name
A string.
- Category number
A number. The value is from 0 to 15 and is stored as an index into the category database.
Instead of storing the category number ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access