## 4 Proposed System Overview and Use of Open Link Data Integration for Polystore Databases
### Workflow Web-Based Query Management System with Top-Down Approach
#### 4.3.3 Query Processor  
The suggested web application has an integrated query processor for mapping queries, transforming data, and migrating it from the remote data store to the local database. SQL is used to communicate between the query processor and the web application and the underlying database management system. The user interaction with the system generates \begin{table}
\begin{tabular}{c c c c c c c} \hline \hline
**Entities** & **Nights** & **Fields** & **Filters** & **Exposures** & **CCD** & **Host Galaxy** & **Procimages** \\ \hline Nights & - & - & - & 1:N & - & - & - \\ \hline Fields & - & - & - & 1:N & - & 1:N & - \\ \hline Filters & - & - & - & 1:N & - & - & - \\ \hline Exposures & 1:N & 1:N & 1:N & - & 1:N & - & 1:N \\ \hline CCD & - & - & - & 1:N & - & - & - \\ \hline Host & & & & & & & \\ Galaxy & - & 1:N & - & - & - & - & - \\ \hline Procimages & - & - & - & 1:N & - & - & - \\ \hline \hline \end{tabular}
\end{table} 
Table 4: Matrix of the entities of the database. SQL query statements that are handled by the Local RDBMS. The SQL query is then joined to the Processed Images (ProCImages) database, which contains the images' unique serial numbers. The query processor then compares the SQL query to the unique serial numbers of the images in the IRSA cloud, which are converted to URLs for the images. Finally, the SQL query is converted to server requests to obtain images from the multiple directory of IRSA data cloud, and matched images with the same unique serial number are presented in the web application's visualizer. Additionally, the query system enables users to link and combine objects in order to build a multi-object search. A query is created each time a user selects an object when querying. By combining those searches and linking many items, the basic query becomes more complicated and this process is depicted in Algorithm 1. ```
\(i\leftarrow\) objects ; // Nights, Fields, CCDS,... \(j\leftarrow\) attributes ; // nid, fid, ccdid, obj,... \(k\leftarrow\) attributes properties ; // nid=443,444..., fid=436, 836..., ccdid=0 16,... \(n\leftarrow\) number of objects for(\(i=1\); \(i<=n\); \(i++\)) do if(\(k\) e \(j_{i}\)) then \(R\)\([\)\(]\leftarrow\) GeneratedImagesList \(satisfied\)\(\leftarrow\) TRUE else \(i++\) ; // append with related object  end if  end for\(R\)\([\)\leftarrow\) GeneratedImagesList \(r\)\(=\) 1 for each\(r\) in \(R\)\([\)\(]\)do Select in \(R\)\([\)\(]\)\(\leftarrow\) SQL query is converted to server requests to obtain images from the IRSA cloud  end for
```  
**Algorithm 1**Query Workflow across the multiple data sources. Some sample queries that can be achieved are as follows:  
* Query 1: Find the information of image from a Fields where user select example records from object list (e.g., fields, nights, exposures, procimages, ccd, etc.) SQL for Query 1: select distinct on (A.\"DBFIELD\") A. * from \"_FIELDS\" A\(\backslash\) Image SQL for Query 1: select A.*,B. * from \"_Exposures\" A, \"_PROCIMAGES\" B, (select distinct on (A.\"DBFIELD\") A. * from \"_FIELDS\" A) C where A.\"DBFIELD\" = C.\"DBFIELD\" and A.\"DBRID\"= B.\"DBRID\" order by B.\"DBPID\" offset 0 limit 10
* Query 2: Find the information of image from a certain place field and exposures. SQL for Query 2: select distinct on (A.\"DBEXPD\") A. * from \"_exposures\" A, (select distinct on (A.\"DBFIELD\") A. * from \"_FIELDS\" A) B where A.\"DBFIELD\"= B.\"DBFIELD\" Image SQL for Query 2: select A.*,B. * from \"_PROCIMAGES\" B, (select distinct on (A.\"DBRID\") A. * from \"_exposures\" A,(select distinct on (A.\"DBRFIELD\") A. * from \"_FIELDS\" A) B where A.\"DBRFIELD\"=B.\"DBRFIELD\" ) A where A.\"DBREVID\"= B.\"DBREVID\" order by B.\"DBRID\" offset 0 limit 10;
* Query 3: Find the information of image where field, night exposure is exactly the same in the tables. SQL for Query 3: select distinct on (A.\"DBMID\") A. * from \"_NIGHTS\" A, (select distinct on (A.\"DBREVID\") A. * from \"_EXPOSURES\" A, (select distinct on (A.\"DBRFIELD\") A.