Based on the information I have provided below, can you give me your opinion on whether its a good idea to denormalize separate tables into one table which holds different types of transactions?.. What are the pro's/con's?.. Has anyone attempted this before?.. Banking systems use a CIF (Customer Information File) [master] where customers may have different types of accounts, CD's, mortgages, etc. and use transaction codes[types] but do they store them in one table?.. The app is single-user with max of 10TPHour. There's no high TPM's in this app, it's not a bank, it's a...
Pawnshop Application:
I have separate tables for Loan, Purchase, Inventory & Sales transactions. Rows from each of these tables are joined to their corresponding customer in the following manner:
customer.pk_id SERIAL = loan.fk_id INTEGER;
= purchase.fk_id INTEGER;
= inventory.fk_id INTEGER;
= sale.fk_id INTEGER;
Since there are so many common properties within the four tables, which revolves around the same merchandise being: pawned, bought, transferred to inventory and sold, I experimented by consolidating the four tables into one table called "transaction" and added the following column:
transaction.trx_type char(1) {L=Loan, P=Purchase, I=Inventory, S=Sale}
Scenario:
A customer initially pawns merchandise, makes a couple of interest payments, then decides he wants to sell the merchandise to the pawnshop, who then places merchandise in Inventory and eventually sells it to another customer.
I designed a generic transaction table where for example:
transaction.main_amount DECIMAL(7,2)
in a loan transaction holds the pawn amount, in a purchase holds the purchase price, in inventory and sale holds sale price.
This is clearly a denormalized design, but has made programming a lot easier and improved performance. Any type of transaction can now be performed from within one quantum-style screen, without the need to change to different tables. The key is that the same merchandise navigates through different types of transactions over time.
As the merchandise morphs into different transaction types, I'm storing its history of all previous transactions performed with it, from the time it first made its appearance at the pawnshop through the sale of it to another customer, which could again make its way back into the pawnshop. When merchandise is pawned, it is micro-tagged with an invisible id number (the original ticket number). Example of multiple transactions: Customer A pawns it, makes couple of interest payments, decides he wants to sell it to pawnshop, pawnshop buys it, puts it in inventory, sells it to Customer B, who after a couple of months needs money and pawns it at same pawnshop and ... each transaction gets recorded with a unique serial transaction number and several fields are re-utilized depending on what type of transaction is taking place.
So, several columns are used for multiple purposes, depending on transaction type. Money columns could be credit, debit or suspense depending on tran type.
If anyone has developed a similar type app, I would be interested in hearing from you. Perhaps I could obtain some valuable input into doing this the best way possible, Thank You!
I WOULD LIKE TO HEAR FROM ANYONE WHO HAS ENCOUNTERED A SIMILAR SITUATION WHERE THEY HAVE CONSOLIDATED SEPARATE TABLES INTO ONE TABLE.