QueryTheory is a web-based educational app that helps users understand how SQL queries translate into relational algebra and set theory. It provides real-time query execution, mathematical explanations, and an AI-powered chat interface for deeper learning.
- ๐ Query Templates: Practice with 50+ categorized SQL queries.
- ๐งฎ Math Explainer: View relational algebra equivalents in LaTeX.
- ๐ฌ Chat Support: Ask questions about the queryโs mathematical structure.
- ๐งช Run SQL Queries: Execute SQL directly on a built-in dataset.
- ๐ Live Results: See output tables immediately after query execution.
- ๐ Preloaded Dataset: Work with
Fruit-Prices-2022.csvby default. - ๐๏ธ Theory-Driven: Designed around core relational concepts.
- Frontend: Streamlit
- Backend: Python (OpenAI API, DuckDB)
- Data Storage: CSV (local), JSON state
- Configuration: Python scripts, Streamlit secrets
QueryTheory/
โ
โโโ app.py # Main Streamlit application
โโโ app_state.json # Stores query templates & chat history
โโโ Fruit-Prices-2022.csv # Demo dataset for SQL queries
โโโ venv/ # Python virtual environment
โโโ README.md # Project documentation (this file)
Make sure your virtual environment is activated and required dependencies are installed.
source venv/bin/activate
streamlit run app.pyStore your OpenAI API key securely in .streamlit/secrets.toml:
[openai]
api_key = "your_openai_key"- CS students learning database theory
- Bootcamp participants practicing SQL
- Instructors creating theory-backed demos
- Anyone exploring how SQL maps to mathematical logic
To contribute or test features:
git clone https://github.com/ThirDecade2020/QueryTheory.git
cd QueryTheory
source venv/bin/activate
streamlit run app.pyMIT License ยฉ 2025 Jason Ricciardi
