Skip to content

ESMAaN/SqlIsolationLevelsSimulator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

SqlIsolationLevelsSimulator

Interactive simulator for testing and visualizing SQL Server isolation level behaviors under concurrent transactions.

🚀 Features

  • Simulates concurrent database transactions
  • Demonstrates:
    • Dirty Reads
    • Non-repeatable Reads
    • Phantom Reads
    • Deadlocks
  • Visualizes the impact of different isolation levels
  • Calculates execution time and logs deadlock status

🔐 Supported Isolation Levels

  • Read Uncommitted
  • Read Committed
  • Repeatable Read
  • Serializable

🗃️ Required Database

This project uses the AdventureWorks2022 sample database to simulate real-world concurrent transactions.

💡 Please download and restore the .bak file in your SQL Server instance before running the simulation.

📥 Download AdventureWorks2022.bak
(Official link from Microsoft SQL Server Samples)

🔄 Restore in SQL Server:

  1. Open SQL Server Management Studio (SSMS)
  2. Right-click DatabasesRestore Database
  3. Select the .bak file and restore it as AdventureWorks2022

🛠️ Technologies Used

  • C# (.NET Framework) – UI and transaction simulation logic
  • SQL Server – For executing concurrent transactions
  • ADO.NET – Database access and command execution
  • Windows Forms – User interface
  • Multithreading – Simulating parallel operations

▶️ Getting Started

🧱 Prerequisites

  • Visual Studio 2019 or newer
  • SQL Server (Express or LocalDB)
  • AdventureWorks2022 sample database

⚙️ Setup

  1. Clone the repository:
git clone https://github.com/your-username/SqlIsolationLevelsSimulator.git
  1. Open SqlIsolationLevelsSimulator.sln in Visual Studio

  2. Make sure SQL Server is running and the AdventureWorks2022 database is restored

  3. Update App.config if needed:

<connectionStrings>
  <add name="DefaultConnection"
       connectionString="Data Source=localhost;Initial Catalog=AdventureWorks2022;Integrated Security=True" />
</connectionStrings>
  1. Run the app with F5

📊 Example Output

  • Isolation Level: Repeatable Read
  • Transaction A: Update operation
  • Transaction B: Select → Delay → Select again
  • ❌ Deadlock: No
  • ⏱ Execution Time: 426 ms

👤 Author

Esma Şen

About

Interactive simulator for testing and visualizing SQL Server isolation level behaviors under concurrent transactions.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages