Getting Started with DBMS-SQL-Labs
📋 Table of Contents
Introduction
Welcome to DBMS-SQL-Labs! This repository contains a comprehensive collection of hands-on SQL laboratories designed to teach database concepts from basic queries to advanced database management techniques. Whether you're a beginner learning SQL for the first time or an experienced developer looking to sharpen your database skills, these labs provide structured, practical experience.
Prerequisites
Required Knowledge
Basic understanding of computer programming concepts
Familiarity with command-line interfaces
Basic understanding of data structures
Software Requirements
1. Database Management System
You'll need at least one of the following:
MySQL/MariaDB (Recommended for most labs)
# Ubuntu/Debian
sudo apt-get update
sudo apt-get install mysql-server
# macOS (using Homebrew)
brew install mysql
# Windows
# Download installer from MySQL website
PostgreSQL (Alternative option)
2. Programming Languages (for integration labs)
Python (Labs 13-15)
Python 3.7 or higher
Install MySQL connector:
pip install mysql-connector-python
pip install pymysql
Java (Lab 12)
JDK 11 or higher
MySQL Connector/J library
Maven or Gradle (recommended)
Node.js (Labs 7-8)
Node.js 14 or higher
Install MySQL package:
3. Additional Tools
Jupyter Notebooks (For interactive labs)
pip install jupyter
pip install ipython-sql
pip install pymysql
MongoDB (Lab 20)
Neo4j (Lab 21)
Database GUI Tools (Optional but recommended)
Installation & Setup
Step 1: Clone the Repository
git clone https://github.com/TeachingOW/DBMS-SQL-Labs.git
cd DBMS-SQL-Labs
Step 2: Set Up MySQL
Start MySQL service:
# Linux
sudo systemctl start mysql
# macOS
brew services start mysql
# Windows
# Use MySQL Workbench or Services panel
Secure your installation (recommended):
sudo mysql_secure_installation
Log into MySQL:
Create a database for practice:
CREATE DATABASE practice_db;
USE practice_db;
Step 3: Test Your Setup
Run a simple query to verify everything works:
SELECT 'Hello, SQL!' AS greeting;
If you see the output, you're ready to start!
Quick Start Guide
For Complete Beginners
Start with these labs in order:
Lab 1 : Database Creation & Basic Queries
Learn to create databases and tables
Master SELECT statements
Understand basic data types
labs/foundations/inclass-exercise.html : Workers Database
Practice CREATE TABLE and INSERT
Apply what you learned in Lab 1
Lab 2 : Advanced Queries & Joins
Multi-table queries
JOIN operations
Complex WHERE clauses
For Intermediate Users
If you already know basic SQL:
Lab 7 : CASE Expressions
Lab 8 : Window Functions
Lab 9 : Views
For Advanced Users
Jump to these advanced topics:
Lab 16 : Triggers & Stored Procedures
Lab 17 : Transaction Management
Lab 20 : MongoDB (NoSQL)
Lab 21 : Neo4j (Graph Database)
Lab Navigation
Lab Structure
Each lab follows this structure:
Learning Objectives : What you'll learn
Prerequisites : Required knowledge
Introduction : Concept overview
Exercises : Hands-on practice
Solutions : Example solutions (where applicable)
Additional Resources : Further reading
Lab Categories
📘 Foundational Labs (Weeks 1-4)
Basic SQL operations
Table creation and data manipulation
Simple queries and filtering
📗 Intermediate Labs (Weeks 5-8)
Complex queries and joins
Aggregate functions
Set operations
Window functions
📙 Advanced SQL (Weeks 9-12)
Stored procedures and triggers
Transaction management
Optimization techniques
Database design
📕 Programming Integration (Weeks 13-14)
Python database connectivity
Java database integration
Web application development
📓 Modern Databases (Weeks 15-16)
NoSQL databases
Graph databases
JSON/XML handling
Troubleshooting
Common Issues
1. "Access denied for user"
Problem : Can't connect to MySQL Solution :
# Reset MySQL root password
sudo mysql
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'newpassword';
FLUSH PRIVILEGES;
2. "Can't connect to local MySQL server"
Problem : MySQL service not running Solution :
# Start MySQL service
sudo systemctl start mysql # Linux
brew services start mysql # macOS
3. "Unknown database"
Problem : Database doesn't exist Solution :
-- Create the database first
CREATE DATABASE your_database_name;
USE your_database_name;
4. "Table doesn't exist"
Problem : Trying to query a table that hasn't been created Solution :
Make sure you've run the CREATE TABLE statement
Check you're in the correct database: SELECT DATABASE();
List all tables: SHOW TABLES;
5. Jupyter Notebook can't connect to MySQL
Problem : Jupyter can't find MySQL connection Solution :
# Install required packages
!pip install pymysql ipython-sql
# Load SQL extension
%load_ext sql
# Connect to MySQL
%sql mysql+pymysql://username:password@localhost/database_name
Getting Help
Check the Main README for overview
Review specific lab instructions carefully
Search for error messages online
Post issues on the GitHub repository
Additional Resources
Learning Platforms
Documentation
Video Tutorials
Books
"SQL in 10 Minutes" by Ben Forta
"Learning SQL" by Alan Beaulieu
"Database System Concepts" by Silberschatz, Korth, and Sudarshan
Practice Datasets
The data/ directory contains several datasets for practice:
IMDB Movie Data : Movie ratings and information
Employee Data : HR database with hierarchies
Drivers Database : Complete relational database example
Student Grades : Academic performance data
Next Steps
Once you've completed the setup:
✅ Start with Lab 1: Basic Queries
✅ Complete the labs/foundations/inclass-exercise.html
✅ Progress through labs sequentially
✅ Practice with the provided datasets
✅ Try the challenge exercises
✅ Build your own projects using learned concepts
Happy Learning! 🚀
Need Help?
Open an issue on GitHub
Check the troubleshooting section above
Review the main README for additional guidance