Declarative Ajax Web Applications through SQL++ on a Unified Application State

Yupeng Fu, Kian Win Ong, Yannis Papakonstantinou

Introduction

Building modern Ajax-based web applications is a complex task that typically requires developers to navigate a fragmented three-tier architecture. This environment is characterized by a significant "impedance mismatch," where data must be constantly translated between relational databases (SQL), server-side application logic (Java, Python, etc.), and client-side presentation layers (HTML, JSON, and JavaScript).

Beyond language barriers, developers must manually manage distributed data access and state synchronization. Creating smooth, asynchronous user experiences via Ajax often involves tedious, error-prone event-driven programming to calculate "diffs" and incrementally update the DOM without overwriting concurrent user inputs. The FORWARD framework addresses these challenges by unifying the entire stack through a declarative approach.

The FORWARD Framework

FORWARD simplifies web development by introducing two core concepts that abstract away the traditional architectural tiers:

  • Unified Application State (UAS): This acts as a virtual database integrating both persistent data (from SQL databases) and transient data (such as HTTP sessions, URL parameters, and the current state of HTML DOM components).
  • SQL++: An extension of SQL that natively supports JSON-like semi-structured data. By providing a single data model for both the backend and the frontend, SQL++ eliminates the impedance mismatch.

In FORWARD, web pages are defined as declarative SQL++ queries embedded in templates. The framework treats these pages as materialized views. When a user action—written as standard CRUD operations in PL/SQL++—updates the UAS, FORWARD uses database-style incremental view maintenance to automatically compute the necessary changes and render them in the browser via Ajax.

Figure 1: A library application built with FORWARD, demonstrating declarative Ajax updates for adding and saving comments on a map.

Key Insights and Architectural Principles

The framework's effectiveness stems from several key insights:

  • Pages as Materialized Views: By modeling the UI as a rendered database query, FORWARD applies decades of database research on incremental view maintenance to solve the problem of UI state synchronization.
  • Base vs. Derived State: To prevent race conditions during asynchronous updates, FORWARD separates page state into mutable "base values" (user inputs) and read-only "derived values" (visualizations). This ensures that background refreshes do not overwrite what a user is currently typing.
  • Location Transparency: Developers write queries as if all data resides in one place. A distributed query processor automatically partitions and routes sub-queries to the database, server, or browser as needed.

Results and Validation

The viability of FORWARD has been proven through its deployment in various commercial and academic applications, including a cloud-based IDE. In a complex production application for the pharmaceutical industry (BioHeatMap), the framework handled 18 pages and 207 actions.

Validation showed high expressiveness: 72 out of 80 User-Defined Functions (UDFs) were written entirely in SQL++, meaning the language was sufficient for approximately 97% of the application's logic. This demonstrates that a single-language, declarative approach can handle the vast majority of standard web application requirements.

Limitations and Future Work

While FORWARD significantly reduces developer overhead, some areas for improvement remain. Currently, queries must be statically known, and integrating third-party JavaScript libraries (like D3.js) requires building custom wrappers. Future work focuses on supporting more dynamic queries, pushing more computation directly to the browser for lower latency, and implementing static analysis to better manage dependencies between asynchronous actions.

Summary updated

BibTeX
@misc{fu2013declarative,
  author = {Yupeng Fu and Kian Win Ong and Yannis Papakonstantinou},
  title = {{Declarative Ajax Web Applications through SQL++ on a Unified Application State}},
  year = {2013},
  eprint = {1308.0656},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1308.0656},
}
Figure