SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 465 | Next

Yingshu Li, My T. Thai, and Weili Wu

"Wireless Sensor Networks and Applications"


TinyDB includes a facility for simple triggers. Currently, triggers can be
executed only in response to some local sensor readings that satisfy the conditions
specified in the WHERE clause of the query. Whenever a query result
satisfies the WHERE clause of a query, the trigger action is executed. As
an example of what triggers can be used for, consider an application where
the user wants to sound an alarm whenever the temperature monitored by a
sensor goes above some threshold. This can be accomplished via the simple
trigger query:
295
Jinbao Li, Zhipeng Cai, and Jianzhong Li
SELECT temp
FROM sensors
WHERE temp > thresh
TRIGGER ACTION SetSnd(512)
EPOCH DURATION 512
The SetSnd command sounds the alarm, and the value 512 specifies a
sound duration of 512ms.
The following example is the query on the unlimited virtual relation shown
in Table 1. The results are shown in Table 2.
Select nodeID, light
FROM sensors
WHERE light > 200
Node ID Light
1 598
1 235
2 237
2 263
3 256
3 266
...... ......
Table 2. Query result.
Query Language in Cougar
Cougar also provides a SQL-like query language. In most sensor network applications,
it is important to detect the environment periodically. Thus, the
query language in Cougar supports continuous periodical query. The grammar
of query language in Cougar is as follows.
SELECT select-list
FROM [Sensordata S]
[WHERE predicate]
[GROUP BY attributes]
[HAVING predicate]
DURATION time-interval
EVERY time-span
296
Chapter 12 Data Management in Sensor Networks
where, DURATION specifies the lifetime of the query.


Pages:
453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477