In the actual array for an e-commerce application there are 9 fields which we define:
- type This is a product subset of a product category.
- desc A short description of the product.
- price The current product price.
- maker A three letter code to identify the maker of the product.
- pid The product ID or inventory number.
- state The state or country where the product is shipped from.
- special A three letter code to determine how a product is taxed, how shipping costs are computed, and what detail message to pop up.
- itemwt The shipping weight of an item.
- itemtax The tax rate for an item.
Not all fields are used in the current version of MyStore software. They are, however, defined so current databases will be compatible
with future versions of the software.
Notice that the array size and the data type and size within a field have not been specified.
This is a nice feature of JavaScript array databases. The array size is determined by the highest
record number used while the field type is a character string of any length.
Binary information such as an image file cannot be stored in a JavaScript array. However,
the name of the image or the file name for the image can be stored. Since information in the
array is always accessed from an html web page, an image can be written to the page by using
the file name to form a link or reference to the image.
Another nice feature of the JavaScript array is its small footprint. It takes
about 100 Bytes to populate a record. The document within which the array resides
is normally about 1Kbyte; so, a JavaScript database of 100 items will create a
document of only about 11K.
This small size is important for two reasons: 1) It is always prudent to keep files as
small as possible from a storage and searchability standpoint. 2) The
small size allows the entire database to be transferred over the internet in a short amount of time.
Now comes an important difference between client side e-commerce software and server
side software. In the server side scenario, when a customer wants to view information on
a particular product, a query goes out to the server machine from the customers client machine.
Based on the request, the server machine generates an html page from specified
information in the server's database. The page is then sent to the client machine
for viewing by the customer. Each time the customer selects a new product, the process is repeated.
In the client side scenario, when a customer wants information on a particular product, a
request is made to the server for the entire JavaScript database for that product category.
Upon receipt of the database, the customer's computer generates a page for viewing.
Whenever the customer wants to view another product in the same category, the
information is extracted from the now resident database. Another internet
transaction is not required. This means an almost instantaneous response to the customer's
request and a tremendous reduction of server resources and internet congestion.