I need to split a table into two as the current monolithic structure is
incredibly wasteful but don't know how to do such a possibly complicated
thing. I remember an analyser available years ago for MS Access database
that did this but none found for SQLite.

My bloated table (Shoppinghistory) consists of the fields below, all of
which are text except for 'record' which is an autoincrement field.

Creating tables is no problem (Grin).

Old table               New item table          New history table
(ShoppingHistory)       (ItemData)              (ItemHistory)
item                    Itemname                ItemDataId      (Points to 
Record in ItemData)
category                Category
brand                   Brandname
manufacturer            Manufacturer
boughtfrom              Packaging
boughton                                        Boughton
quantity                                        Quantity
units                   Units
weight                  Weight
aisle                                           Aisle
price                                           Price
discount                                        Discount
total                                           Total
note                    Note
picture                 Picture
barcode                 Barcode
deleted                 Deleted
record                  Record                  Record

For each item in the original table (Shoppinghistory) that matches the new
(ItemData) table on the "ItemName,Category,BrandName,Manufacturer" fields,
the "boughton,quantity,aisle,price,discount,total data needs to be copied to
the (ItemHistory) table with the (ItemDataId) column in the (ItemHistory)
table containing the record number of the (ItemData) record it matched.

That way, when I query the (ItemData) table to see how many items were
bought for that record and when, it will bring up matching records from the
(ItemHistory) table.

Is there any simple way t do this or am I stuck with a monolithic table?



--
View this message in context: 
http://sqlite.1065341.n5.nabble.com/Splitting-a-monolithic-table-into-two-related-ones-tp70776.html
Sent from the SQLite mailing list archive at Nabble.com.
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to