If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > General > Database Concepts & Design > Tables that change

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-10-04, 10:31
King_Aero King_Aero is offline
Registered User
 
Join Date: Feb 2004
Posts: 6
Tables that change

Hello,

I'm designing a database that needs to store floating point data values from data acquisition boards. It sounds pretty easy accept for this one problem with the way our system is designed. From the data values we can get, we only actually log a subset. That subset of data is written to a file and change on the fly. I.e. a new data value may be added or taken away from that subset. When that happens a new header which describes the data is also written out.

File looks like this:

Time Data1 Data2 Data3
Feb1 1.00 2.00 3.00
Feb1 1.01 2.02 3.03
Time Data1 Data2 Data3 Data4 <---- New value being logged
Feb1 1.00 2.00 3.00 4.00

My question is what is the best way to design a database that has tables whose fields may change? It wouldn't be very often but the flexibility needs to be there. I thought perhaps every time I see a new header I could create a new table but as I've read elsewhere on the boards generating reports would be a nightmare. If I have one table and I add a column everytime a logged data value is added then I have gaps in the table.

Any suggestions would be greatly appreciated.

Thanks.
Reply With Quote
  #2 (permalink)  
Old 02-10-04, 11:06
andrewst andrewst is offline
Moderator.
 
Join Date: Sep 2002
Location: UK
Posts: 5,171
Re: Tables that change

How about having a table like this:

create table data
( time date
, field_name varchar2(10)
, value number
);

Then the above data would look like:

PHP Code:
Time  Field_name  Value
----  ----------  -----
Feb1  Data1        1.00
Feb1  Data2        2.00
Feb1  Data3        3.00
Feb1  Data1        1.01
Feb1  Data2        2.02
Feb1  Data3        3.03
Feb1  Data1        1.00
Feb1  Data2        2.00
Feb1  Data3        3.00
Feb1  Data4        4.00 
(I'm ignoring the fact that the data as shown appears to have no key - perhaps the Time column really has a time component that differentiates the rows?)
__________________
Tony Andrews
http://tinyurl.com/tonyandrews
Reply With Quote
  #3 (permalink)  
Old 02-10-04, 11:34
King_Aero King_Aero is offline
Registered User
 
Join Date: Feb 2004
Posts: 6
Yeah... I think that works. Thats great! Thanks for the suggestion.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On