Prerequisites
Before creating a SQL lab, you’ll need:- For SQLite: A SQLite database file (.sqliteformat) nameddb.sqlite
- For MySQL 8: A plaintext SQL file (.sqlformat) namedsetup.sql
- The file should be compressed into a ZIP archive
How to create SQLite lab?
Follow the steps below for setting up SQLite based lab:1. Create Your Database File
First, create your SQLite database with the tables and data you want students to work with. You can either: Option A: Use an existing SQLite database You can use popular sample databases like:- chinook.db- Music store database
- northwind.db- Business database
- sakila.db- DVD rental database
.db extension that contain realistic data for learning purposes.
Option B: Convert a plaintext SQL file to SQLite
If you have a .sql file with CREATE TABLE and INSERT statements, you can convert it to an SQLite database:
- Using command line:
- Using SQLite command line:
- Using Python (if you prefer):
2. Prepare Your Database File
- Save your database as db.sqlite
- Create a ZIP archive containing only the db.sqlitefile
- The ZIP file should be named something descriptive like student_database.zip
How to create MySQL 8 lab?
Follow the steps below for setting up MySQL 8 lab:1. Create Your SQL Setup File
For MySQL 8 labs, you need to create a plaintext SQL file that contains all the necessary setup commands:2. Prepare Your SQL File
- Save your SQL setup file as setup.sql
- Create a ZIP archive containing only the setup.sqlfile
- The ZIP file should be named something descriptive like mysql_student_database.zip
Creating the SQL Lab on Fermion
If you have not enabled Coding labs, please go to “Manage features” >
“Coding Labs” and enable that first from your instructor dashboard
- Navigate to your instructor dashboard
- Go to the “Coding Labs” section
- Click on “I/O labs” and create an SQL lab as IO lab
- Edit this lab
 
- Inside the lab setup interface, scroll down and pick “SQL Lab”.
- Fermion currently supports SQLite and MySQL 8 as backend adapters for running SQL queries.
- Expand this and upload the ZIP file you just created:
- For SQLite: Upload student_database.zipcontainingdb.sqlite
- For MySQL 8: Upload mysql_student_database.zipcontainingsetup.sql
 
- For SQLite: Upload 
 
- You can also add default starting code for students if required.
Setting up test cases
For SQL labs, you can define a single test case where you write an expected output the query should produce.SQLite Test Cases
SQLite is able to produce output in 14 different formats, however Fermion outputs the SQL query output inlist mode.
This is how list mode output works:
script.sql that has the solution query, and run the following command locally on your system:
MySQL 8 Test Cases
For MySQL 8, the output format is similar to the standard MySQL command line output. To get the expected output for your query, you can run it locally against your MySQL database: Save your lab and try it as a user to see.
Save your lab and try it as a user to see.
Fermion runs every query in a completely isolated environment. Therefore,
you can setup labs that can have INSERT or DELETE operations as well,
alongside SELECT operations
