dbTalk Databases Forums  

Looking for elegant solution to sensor / reading / alert databasedesign.

comp.databases.theory comp.databases.theory


Discuss Looking for elegant solution to sensor / reading / alert databasedesign. in the comp.databases.theory forum.



Reply
 
Thread Tools Display Modes
  #11  
Old   
Nilone
 
Posts: n/a

Default Re: Looking for elegant solution to sensor / reading / alert database design. - 12-09-2010 , 06:00 PM






On Dec 10, 1:57*am, Nilone <rea... (AT) gmail (DOT) com> wrote:
Quote:
CREATE VIEW SensorLimitsExceeded AS
SELECT a.Sensor, a.Time, a.Reading, a.Time - b.Time AS AlertDuration
* FROM SensorReadings cur, SensorReadings prv, SensorLimits lim
*WHERE cur.Sensor = prv.Sensor
* *AND cur.Reading NOT BETWEEN lim.LowerLimit AND lim.UpperLimit
* *AND prv.Time = (SELECT Max(hst.Time) FROM SensorReadings hst,
SensorLimits lmh
*WHERE hst.Sensor = cur.Sensor AND hst.Sensor = lmh.Sensor
* *AND hst.Time < cur.Time
* *AND hst.Reading BETWEEN lmh.LowerLimit AND lmh.UpperLimit)
Oops, replace a and b with cur and prv, respectively.

Reply With Quote
Reply




Thread Tools
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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.