473,394 Members | 1,748 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

How can I structure my tables well to cope with this data ?

290 100+
I am struggling with how I should store this data.

I get an xlm update every day which contains about 20,000 rows of data.
There are some new rows, maybe 150 a week, and some of the existing rows data changes.

Approximately 97 % of all the data is the same each day with just 3% changing.

I am using Mysql database tables.
So I was thinking that the best way to store the data would be:

Base_Data_Table - 20,000 rows (static)
Structure:
id, title, desc, data1, data2, ... data18

Current_Data_Table - 20,000 rows ( replaced daily)
Structure:
id, title, desc, data1, data2, ... data18

Transaction_Data_Table - 60 rows per day ( grows daily )
Structure:
date, id, record, new_data

--- record is the record that is changed
--- data is the new data fro that record

Although the above is nice and efficient for data storage, it is going to be
a nightmare to extract the data.

Everyday I need to be able to display the current data
( no problem with the Current Data table) but I also want to be able to calculate:

For every row ( could be done dynamically when needed)
a 2-day average for today
a 2-day average for 7 days ago
a 2-day average for 30 days ago

and grab the last 120 days data points for two records ( data8 and data9)
so that I can chart them.

The easiest way to extract the data would be to just write a new table
for each day, but that would mean duplicating 97% of data - big waste of disc space.

I think that there must be a good compormise - but I am not sure what to do.

Does anyone have any suggestions on how to organize the data.

Thanks.
Jan 5 '10 #1
6 1920
dlite922
1,584 Expert 1GB
20,000 is nothing for MySQL to update, even daily. I don't understand why you have 3 tables and over complicating it.

Just have another TimeStamp field in your table that gets updated when the row is inserted/updated.

Data_Table
id, title, data1,...data18,last_modified_date

Now, let's understand your reporting needs.

What do you mean by a "2-day average for today"? Do you mean, get the number of records that have changed in the last 1 day, 7 days, and 30 days?

The 120 day query is easy. Just query for last_modified_data < 120 days ago and Select data8, and data9.





Dan
Jan 6 '10 #2
jeddiki
290 100+
Thanks for your reply.

I just looked at the size of my daily table.

A daily file takes up 2.4 Mb

That means a year is 876 Mb - isn't that quite a lot ?

I must admit that it would make the reporting and charting
much easier if I only have the one table.

It just seems odd that 95% of that data is redundant..
But maybe it doesn't matter ?

My server has over 200Gb and I've only used 17Gb.

BUT - doesn't a big file take a lot longer to search through?

Or maybe its quicker to search one large table rather than do several searches on smaller tables ??

Any experience with this ?


Thanks
Jan 6 '10 #3
Frinavale
9,735 Expert Mod 8TB
I've moved this question to the MySql forum since it's more of a database question than a PhP question. I think you'll get more help with your questions from the experts there.

Happy coding,

-Frinny
Jan 6 '10 #4
jeddiki
290 100+
Thanks,

Would really appreciate any input from experienced database
coders.
Jan 6 '10 #5
RedSon
5,000 Expert 4TB
Bigger files do not necessarily take longer to search through for a database, no. A database creates indexes, indexes are designed to be small and easy to use to lookup stuff.

I would expect mysql to easily and quickly perform it's tasks on files that are in the 10GB range as well so don't worry about that.

You should try to limit redundant data. Are any of the suggestions dlite made valuable to you?
Jan 7 '10 #6
MMcCarthy
14,534 Expert Mod 8TB
OK my understanding of what you are asking is this. You have a "Flat" file of data (By this I mean you haven't organised your data into relational tables as per a standard database. This article will give you more information on data structures and normalisation of data.

Now I understand you want to keep a transaction log of all updates to the data in your table. Exactly what do you need to store in that log.
  1. Do you need to keep a complete history of all changes or just the last change made to the data.
  2. Do you need to record all changes to a record (i.e. all the new data values) or just record the fact that a change was made and the date of that change.
Jan 7 '10 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Rob Tweed | last post by:
I have a customer who is having problems when their Windows 2000/IIS/PHP-based system begins to experience a level of loading that isn't, in my view, unreasonably high. I'm wondering what others...
6
by: Andreas Lauffer | last post by:
I changed from Access97 to AccessXP and I have immense performance problems. Details: - Access XP MDB with Jet 4.0 ( no ADP-Project ) - Linked Tables to SQL-Server 2000 over ODBC I used...
0
by: Randall Sell | last post by:
Hello all, I am migrating a Paradox application to SQL Server. My problem is that the existing Paradox table structure is limited. Correcting it will mean a re-write of the application (Delphi...
2
by: William Roberts | last post by:
I am desiging an invoicing program that will do recurring billing as well as charging for any additional service at a given time. All charges will be service oriented. I am particularly concerned...
1
by: deko | last post by:
DoCmd.CopyObject copies data, but I only need structure. I'm trying to clone several tables in my Access 2003 mdb. The goal is to link to a series of Excel spreadsheets and then run various...
5
by: Alfonso Morra | last post by:
Hi, I am writing a messaging library which will allow me to send a generic message structure with custom "payloads". In many cases, a message must store a non-linear data structure (i.e....
7
by: Jimakos Bilakis | last post by:
Hi guys! I'm using the C++ Builder 6 Enterprise Edition where I create some tables in Paradox and with the help of a structure i pass my data from the form (Edit boxes) to the Paradox table with...
0
by: Christoph Haas | last post by:
Hi, list... I have written an application in Perl some time ago (I was young and needed the money) that parses multiple large text files containing nested data structures and allows the user to...
7
by: SteveT | last post by:
Can someone point me in the right direction? Somewhere I read that you reference a strongly typed dataset as if it were a class structure. For example, <SomeTests> <TestsGroups> <Group>...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.