# Resource Indexing and Querying in Large Connected Environments
## 4 Preliminaries & Assumptions
### Queries  
The connected environment produces data that the user queries for various reasons (e.g., monitoring, event detection, forecasting). In this paper, we solely focus on selection/projection queries, defined as follows:  
**Definition 6** (Query).: _A selection/projection query \(q\) is defined as follows:_  
\[q:\sigma_{(E,Range)}^{p}\quad\text{where}: \tag{6}\]  
* \(\sigma\) _is a selection/projection operation_
* \(E=a\cup\bigcup_{i=0}^{n}e_{i}\forall i\in\mathbb{N},\ e_{i}=a\bigoplus v_{i}\) _is the set of selection expressions, where_
* _a is the required attribute_ \(|\forall i\
eq j\in\mathbb{N},e_{i}.a=e_{j}.a\)__
* \(\bigoplus\) _is an operator (e.g.,_ \(<\)_,_ \(>\)_,_ \(\leqslant\)_,_ \(\geqslant\)_,_ \(!\)_,_ \(=\)_)_
* \(v\) _is the attribute's value_
* \(Range=\{D,L\}\) _is the query target, indicating where to select data from within the connected environment ce where_
* \(D=\bigcup_{i=0}^{n}d_{i}\forall i\in\mathbb{N}\) _is a set of devices deployed in a location_
* \(L=\bigcup_{i=0}^{n}loc_{i}\forall i\in\mathbb{N}\) _is a set of zones_
* \(p\in\{One-path,\,\text{Retry},\,Guaranteed,\,Default\}\) _denotes the query type:_
* _If_ \(p=One-path\)_, the query follows a unique path following a specific function (random, highest device capacity, hash) depending on the device deployment when routing. This type of query takes the least amount of time and resources in order to be completed, since it is trying one path (like the one-path queries in Section_ 3_)_
* _If_ \(p=\text{Retry}\)_, the query follows a unique path following a specific function until arriving at a blocked path. Then, the query tries to find another path that may be able to return a response. A different path is searched beginning at the preceding node when a block path is encountered(A blocked path is a path where the query has reached a dead end and when further forwarding or progression is no longer possible.). To save energy, a variety of paths could be tried, but not all of them. These queries are used to send queries that return information, while taking into consideration the missing data._
* _If_ \(p=Guaranteed\)_, the query tries all the possible routes to reach a destination. These types of queries broadcast the message to all known devices, in order to reach the destination at all costs (like the guaranteed queries in Section_ 3_)._
* _If_ \(p=Resource-optimized(Default)\)_, the query tries all the possible routes, when conditions allow, to reach a destination. Here, the query is forwarded to devices having the highest number of entries during the algorithm execution. This means that the query will not be forwarded to devices having capacities less than a minimum threshold. The default query type will be the resource-optimized query, and it is commonly referred to as the default query._  
**Example 6**.: _A query \(q_{1}\) that retrieves temperature data from \(z_{1}\) with a default priority is defined as follows: \(q_{1}:\sigma_{(e=temperature,Range=\{null,z_{1}\})}^{default}\)._  
It is worth mentioning that inside the message sent, the path taken is registered. Retry queries utilize the path to make additional attempts for the previous device. In addition, the complete registered path is used to forward the response back to the user.