Wednesday, August 22, 2007

Step 1: The Data Layer

The first step in using the Framework of Reusable Components is to get control of the data layer. All data presented to the report designs and reusable components of the Framework need to be in the form of a generic schema. The generic schema is a set of arbitrary names for different types of data. Here is the generic schema used by the Framework:

Text fields: Cat1, Cat2, Cat3,...
Date fields: Date1, Date2, Date3,...
Number fields: Val1, Val2, Val3,...

The data source used to collect the data will return it in terms of the generic schema, namely Cat1, Date1, Val1. Here is an example SQL statement that aliases the database field names in terms of the generic schema:

select CUSTOMERS.COUNTRY as "Cat1", CUSTOMERS.CITY as "Cat2", ORDERS.ORDERDATE as "Date1", ORDERDETAILS.QUANTITYORDERED as "Val1", ORDERDETAILS.PRICE as "Val2"
from
CUSTOMERS, ORDERS, ORDERDETAILS
where
CUSTOMERS.CUSTOMERNUMBER = ORDERS.CUSTOMERNUMBER
and
ORDERS.ORDERNUMBER = ORDERDETAILS.ORDERNUMBER

Since all the reusable components in the Framework are built off this generic schema, any data source that conforms to this generic schema can be used. This means our presentation layer will be able to be reused many times over by swapping in any data source that conforms to this generic schema.

No comments: