Triggers and function in mysql using skyreserve flight booking system : Part 2

Business Scenario

Welcome back,Developers!

In the previous part of this lab, we used Triggers to automate database operations whenever data changed. In this part, we'll learn how to create and use MySQL Functions to perform reusable calculations, return values, and simplify SQL queries in the SkyReserve Flight Booking System.

Pre-Lab Preparation

Git Pull

git pull origin branchName

Topic :

1) Basic SQL Queries

2) Stored Programs in MySQL

3) CREATE TABLE and INSERT statements

4) Primary Key and Foreign Key concepts

Task 1: Function Example

Create Function

1

1

Execute Function

2

1

Run the code

3

1

Task 2: Additional Practice Trigger

BEFORE DELETE Trigger

1

1

Prevent deletion of confirmed bookings.

Task 2: Additional Practice Function

Function to Calculate Flight Duration in Hours

1

1

Execute Function

2

1

Execute Function

3

1

 

Great job!
You have successfully created and implemented MySQL Functions to perform reusable calculations and return values efficiently.

Checkpoint

Next-Lab Preparation

  • JDBC basic concepts - steps to establish database connection

  • Types of statement

  • Processing the database response - resultset

Git Pull

git push origin branchName