473,385 Members | 1,908 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,385 software developers and data experts.

Question about SQL table definitions

I think I know the answer to this, but suggestions welcomed.

I have to store lots of information. An electricity reading every half
hour for hundreds of meters for several years.

The ways I thought of storing this in SQL were:
1. One table row per day with 48 fields for the readings.
144M table, 3M index
saves space and having a long skinny table
however, getting the min/max reading in a day is a pain. I
think I'll have to store it which goes against the grain
2. One table row per reading.
376M table, 231M index
big time long skinny table with more control information than
content, huge waste of disk space. However it is first normal
form so queries are easier.
3. Two tables, one to hold control information and one for the readings.
added complications because of the join and creation of an
internal link field.

A quick trial proved 1 to be cumbersome but space saving. I'm currently
using option 2.

any suggestions or recommenndations?


Jul 17 '05 #1
3 2251
On Wed, 26 Nov 2003 14:48:58 +0000, Kevin Thorpe <ke***@pricetrak.com>
wrote:
I think I know the answer to this, but suggestions welcomed.

I have to store lots of information. An electricity reading every half
hour for hundreds of meters for several years.

The ways I thought of storing this in SQL were:
1. One table row per day with 48 fields for the readings.
144M table, 3M index
saves space and having a long skinny table
however, getting the min/max reading in a day is a pain. I
think I'll have to store it which goes against the grain
Ouch!
2. One table row per reading.
376M table, 231M index
big time long skinny table with more control information than
content, huge waste of disk space. However it is first normal
form so queries are easier.
3. Two tables, one to hold control information and one for the readings.
added complications because of the join and creation of an
internal link field.


It really ought to be option 3 (which is in 3NF), as you're
duplicating your control info with option 2. Indexing the date and
control id should help performance.

Depending on what kinds of reports you want to run, you may be able to
archive off old data with option 3 thereby keeping the database to a
manageable size. We do that with some of our customer's history
records whenever they notice the system becoming slow.

If most queries will concern, say, the previous week's readings you
could create a separate database for those and have a scheduled job
move the records into an archive database each day/week.

Are your controls grouped (say, geographically, by purpose, etc)? Will
you want to combine the readings of several controls?

--
David ( @priz.co.uk )
The Internet Prisoner Database: http://www.priz.co.uk/ipdb/
The Tarbrax Chronicle: http://www.tarbraxchronicle.com/
Jul 17 '05 #2
On Wed, 26 Nov 2003 14:48:58 +0000, Kevin Thorpe <ke***@pricetrak.com> wrote:
I think I know the answer to this, but suggestions welcomed.

I have to store lots of information. An electricity reading every half
hour for hundreds of meters for several years.

The ways I thought of storing this in SQL were:
1. One table row per day with 48 fields for the readings.
144M table, 3M index
saves space and having a long skinny table
however, getting the min/max reading in a day is a pain. I
think I'll have to store it which goes against the grain
2. One table row per reading.
376M table, 231M index
big time long skinny table with more control information than
content, huge waste of disk space. However it is first normal
form so queries are easier.
3. Two tables, one to hold control information and one for the readings.
added complications because of the join and creation of an
internal link field.

A quick trial proved 1 to be cumbersome but space saving. I'm currently
using option 2.

any suggestions or recommenndations?


What database are you implementing this on? If it were Oracle, it would look
like a prime candidate for an Index-Organised table, which would cut down your
storage requirements. I don't think MySQL has an equivalent. I vaguely recall
the SQL Server equivalent being a 'clustered index' or something like that.

--
Andy Hassall (an**@andyh.co.uk) icq(5747695) (http://www.andyh.co.uk)
Space: disk usage analysis tool (http://www.andyhsoftware.co.uk/space)
Jul 17 '05 #3
David Mackenzie wrote:
On Wed, 26 Nov 2003 14:48:58 +0000, Kevin Thorpe <ke***@pricetrak.com>
wrote:

I think I know the answer to this, but suggestions welcomed.

I have to store lots of information. An electricity reading every half
hour for hundreds of meters for several years.

The ways I thought of storing this in SQL were:
1. One table row per day with 48 fields for the readings.
144M table, 3M index
saves space and having a long skinny table
however, getting the min/max reading in a day is a pain. I
think I'll have to store it which goes against the grain

Ouch!

2. One table row per reading.
376M table, 231M index
big time long skinny table with more control information than
content, huge waste of disk space. However it is first normal
form so queries are easier.
3. Two tables, one to hold control information and one for the readings.
added complications because of the join and creation of an
internal link field.

It really ought to be option 3 (which is in 3NF), as you're
duplicating your control info with option 2. Indexing the date and
control id should help performance.


That's what I thought. I started off using option 2 because my control
information was fairly small (meter number, date, reading number) but
I've now had to add extra dimensions to it (some readings are estimated
or modelled) so a migration to two tables seems required.
Depending on what kinds of reports you want to run, you may be able to
archive off old data with option 3 thereby keeping the database to a
manageable size. We do that with some of our customer's history
records whenever they notice the system becoming slow.
I try not to archive information. Disk space is cheap and properly
indexed speed shouldn't be an issue. I've found empirically that the
databases I've used fill up only at the rate hardware speeds up.
If most queries will concern, say, the previous week's readings you
could create a separate database for those and have a scheduled job
move the records into an archive database each day/week.

Are your controls grouped (say, geographically, by purpose, etc)? Will
you want to combine the readings of several controls?


The control fields are orthogonal so indexing is important. Lots of
EXPLAIN queries I think.

Jul 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Dave H | last post by:
Hello, I have a query regarding definition lists. Is it good practice semantically to use the dt and dd elements to mark up questions and answers in a frequently asked questions list, or FAQ? ...
4
by: Tony Johansson | last post by:
Hello experts! I'm reading a book about C++ and there is something about inline that the book says that is unclear for me. The book says the following "Because inline functions are expanded at...
8
by: Thomasb | last post by:
With a background in MS SQL Server programming I'm used to temporary tables. Have just started to work with DB2 ver 7 on z/OS and stumbled into the concept of GLOBAL TEMPORARY TABLE. I have...
2
by: Daniel | last post by:
I use an Access database to basically take data exports, import them, manipulate the data, and then turn them into exportable reports. I do this using numerous macros, and queries to get the data...
4
by: S Chapman | last post by:
Is there any tool that generates Typed DataTables rather than Typed Datasets? The trouble we are having is we have quite a few tables in our database and a single table can be a part of more than...
0
by: S Chapman | last post by:
Is there any tool that generates Typed DataTables rather than Typed Datasets? The trouble we are having is we have quite a few tables in our database and a single table can be a part of more than...
5
by: outstretchedarm | last post by:
I'm extremely new to javascript and to programming in general. I am trying to create an interactive table. I have already created the table with constants, in the key of C (it is for music). ...
10
by: Forest14 | last post by:
Hello! Happy Christmas/holidays to you all I have this huge table named "Positions" with more than 160 fields of which the fields are named with non obvious abbreviations. I have another table...
5
by: mark_aok | last post by:
Hi all, I have a situation where I have a split database. At the back end, I need to - create a new table (I will call it newTable) with the exact fields, and relationships as another table...
1
by: ceconix | last post by:
Hello all, I am still learning about SQL, and have a question. I have two tables. I want to update table 2 with data from table 1. Table 1 has two columns. ID and NUM. In Table 2, I have an ID...
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:
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
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.