A SQL Server database project that models a city bike rental system end-to-end (users, memberships, stations, bikes, rentals, payments, maintenance, and alerts).
I built this to practice relational data modeling and to go beyond “just tables” by implementing query patterns, schema versioning, and performance testing + indexing using T-SQL.
- Microsoft SQL Server (T-SQL)
- SQL Server Management Studio (SSMS)
The database covers the full lifecycle of a bike rental platform:
- Memberships (pricing + duration)
- Users
- Stations (city + capacity)
- Bikes (model + status + station)
- Rentals (time interval + cost)
- Payments
- Feedback (rating + comment)
- Maintenance teams & logs
- Alerts (system/battery/repair + resolved state)
schema.sql– full database schema (tables + constraints)seed/– dataset inserts split by entity (one topic per file)DML_examples/– UPDATE / DELETE scenariosqueries/– organized query collection by conceptprocedures/– stored procedures (schema versioning + migrations)testing_framework/– performance testing framework (test runs, timings, data generators)indexing_optimization/– indexing experiments + execution plan queries + reporting view
- Relational schema design with normalized entities
- Primary keys, foreign keys, candidate keys, and default constraints
- Consistent relationship modeling across the domain (e.g., user→rentals, bike→station, bike→maintenance logs)
- Entity-based seeding scripts to quickly populate the database for demos and testing
- Repeatable data setup using structured SQL files
Included realistic update/delete use-cases:
- Updating bike models and statuses based on conditions
- Assigning trial memberships
- Cleaning old logs or resolved alerts based on filters and state
A curated set of queries demonstrating key SQL patterns used in real systems:
- Set operations:
UNION,UNION ALL,INTERSECT,EXCEPT - Joins:
INNER,LEFT,RIGHT,FULL(including multi-table joins) - Subqueries: nested
IN,EXISTS, and subqueries in theFROMclause - Aggregations:
GROUP BY,HAVING+COUNT,SUM,AVG,MIN,MAX - Quantifiers:
ANY/ALL+ equivalent rewrites with aggregates andIN/NOT IN
These were implemented as a “query portfolio” to validate correctness and to practice writing clear, optimized SQL.
Implemented a lightweight database schema versioning mechanism:
- A
Versiontable tracks the current schema version ProceduresTabledefines forward/backward migration stepsgoToVersionStatemoves the database to any target version by executing the correct migration/rollback procedures
Supported migration operations include:
- Modify column type (and reverse)
- Add/remove a column
- Add/remove a DEFAULT constraint
- Add/remove primary key
- Add/remove candidate key
- Add/remove foreign key
- Create/drop a table
Built a small framework for measuring database performance:
- Data generation procedures for controlled scaling (row count)
- Test runner procedure to record performance metadata
- Tracking of test runs and timing results (tables/views)
This helps evaluate how query performance changes with larger datasets.
Explored performance improvements using:
- Non-clustered indexes (with
INCLUDEcolumns) - Execution-plan oriented queries for before/after analysis
- A reporting view (
BikeMaintenanceDetails) joining Bike + MaintenanceLog + MaintenanceTeam
- Open
schema.sqlin SSMS - Execute the script to create all database objects
Run the seed scripts in order (recommended):
seed/01_seed_membership.sqlseed/02_seed_users.sqlseed/03_seed_stations.sqlseed/04_seed_bikes.sqlseed/05_seed_rentals.sqlseed/06_seed_payments.sqlseed/07_seed_feedback.sqlseed/08_seed_maintenance_teams.sqlseed/09_seed_maintenance_logs.sqlseed/10_seed_alerts.sql
- Run any file inside
queries/to explore SQL patterns - Run
procedures/99_demo_run.sqlto test schema versioning - Run
testing_framework/99_demo_run.sqlto generate data and execute performance tests - Run scripts in
indexing_optimization/to evaluate indexes + views
- The project is designed to be reproducible from scripts alone (schema + seed + features).
- It can be extended with additional stored procedures, views, and reporting queries.