Data stream systems became recently the focus of intense research activity. Sensor measurements, financial data, network packets and log files can all be seen as data streams. The ability to query data streams is of increasing importance and has been identified as a crucial element for modern organizations and agencies. This article identifies an interesting class of applications where stream sessions may be organized into a hierarchical fashion—i.e. sessions may consist of subsessions. For example, log streams from call centers belong to different call sessions and call sessions consist of services subsessions. We may want to monitor statistics and perform accounting at any level on this hierarchy, relative to any other (higher) level (e.g. monitoring the average service session per
call vs the average service session for the entire system). We argue that data streams of this kind have rich procedural semantics—i.e. behaviour—and therefore a semantically rich model should be used: a session may be defined by opening and closing conditions, may have data and methods and may consist of subsessions. We propose a simple conceptual model based on the notion of ‘session’—similar to a class in an object‐oriented environment having lifetime semantics. Queries on top of this schema can be formulated via HSA (hierarchical stream aggregate) expressions. We give an algorithm describing how stream data ‘flow down’ session hierarchies and discuss potential evaluation and optimization techniques for HSAs. We finally present NESTREAM, a prototype implementation incorporating many of these concepts. Copyright © 2007 John Wiley & Sons, Ltd.