[SOLVED] Splitting an SQLite table into two.

Just starting out? Need help? Post your questions and find answers here.
User avatar
Fangbeast
PureBasic Protozoa
PureBasic Protozoa
Posts: 4795
Joined: Fri Apr 25, 2003 3:08 pm
Location: Not Sydney!!! (Bad water, no goats)

[SOLVED] Splitting an SQLite table into two.

Post by Fangbeast »

I need to split a table into two to cut down on database sizes but don't know how. The original table is monolithic and contains a lot of duplications so a split is in order.

The 'Item' table will contain a list of distinct items along with their associated data.

The 'history' table will contain a list of how often those items were purchased and the 'ItemId' column will contain the record number of the parent item in the 'Item' table.

I've split the tables but can't get the ItemId record right. Working with more than one table like this is not something I normally do. Anyone know how to frame an SQLite query to do this?

Code: Select all


Original table     New item table   History table

item                  item                  ItemId
category            category
brand                brand
manufacturer     manufacturer
boughtfrom                               boughtfrom
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
So, if 'Item' from the 'Item' table is 'Spam' and the record number is 84 and has been bought 4 times, the History table should have 4 records with the ItemId being 84.

**UPDATE** Solved by email from the Nabble SQLite support forum.
Last edited by Fangbeast on Fri Aug 30, 2013 1:45 pm, edited 1 time in total.
Amateur Radio/VK3HAF, (D-STAR/DMR and more), Arduino, ESP32, Coding, Crochet
bohne_68
New User
New User
Posts: 8
Joined: Mon Aug 26, 2013 10:42 am
Location: Stuttgart
Contact:

Re: Splitting an SQLite table into two.

Post by bohne_68 »

Hallo,

I don't thing that that the file size (table size) is the problem.

Do you tried to reduce the number of received record's? Usually you see only 50 lines in a table/grid :D.
This depends on your workflow, queries etc.

Or you have to improve/cleanup your database using "external" tools.

regards
Thomas
---
PB 5.40 X64
Many clouds cover the sun
Post Reply