473,651 Members | 3,004 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 recommenndation s?


Jul 17 '05 #1
3 2260
On Wed, 26 Nov 2003 14:48:58 +0000, Kevin Thorpe <ke***@pricetra k.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***@pricetra k.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 recommenndation s?


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***@pricetra k.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
3745
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? Here is an example of just such a usage: <dl class="faq"> <di>
4
1813
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 compile time, definitions of these functions, unlike other definitions, cannot be separately compiled and must be placed in header files. This creates a problem if the compiler does not actually inline a
8
7933
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 created a temporary database with a tables space. Verified that DECLARE GLOBAL TEMPORARY TABLE TEMP (A INTEGER); INSERT INTO SESSION.TEMP VALUES(10); SELECT A FROM SESSION.TEMP; works from a query tool.
2
14912
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 in the format that I need it in order to create the reports that we use. So far this has proven to be successful for the reports that I am doing and the data that I am pulling into it. I just have one challenge that may require a lot of work and I...
4
1439
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 one dataset. If we use the XSD.Exe, the datatable definitions are repeated in every dataset they appear in; causing our data definition layer to bloat. Let us say there is a database table called Account which appears in two dataset definitions...
0
929
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 one dataset. If we use the XSD.Exe, the datatable definitions are repeated in every dataset they appear in; causing our data definition layer to bloat. Let us say there is a database table called Account which appears in two dataset...
5
2106
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). what I would like to do is to create a dropdown box that would enable the user to select all 12 keys, then based on that choice, have the whole table re-calculate, basically transposing all the data up or down. how would I go about doing this.
10
4312
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 named "definitions" which has the column name and definition fields. In order to help me all along my forthcoming developments, I would like to use these definitions from table "definitions" into "Positions". Of course i can manually copy each...
5
1889
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 (let's call it oldTable, and I need to copy everything EXCEPT the data). - Then I need to delete oldTable, and rename newTable 'oldTable'
1
1312
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 column and a bunch more columns plus another NUM column. Table 1 was pulled in from excel. I need to update the NUM from Table 1 to NUM in table 2, but the formating on the ID fields are different, although the same numbers. Example: Table 1...
0
8277
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8803
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8700
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8465
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6158
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5612
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4144
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2701
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1588
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.