Files
airline-agency/database/backups/airline_agency (4).sql
T
2026-08-16 08:05:37 +03:30

340 lines
12 KiB
SQL

-- phpMyAdmin SQL Dump
-- version 5.2.3
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1:3306
-- Generation Time: Aug 15, 2026 at 12:25 PM
-- Server version: 8.4.7
-- PHP Version: 8.3.28
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Database: `airline_agency`
--
-- --------------------------------------------------------
--
-- Table structure for table `airlines`
--
DROP TABLE IF EXISTS `airlines`;
CREATE TABLE IF NOT EXISTS `airlines` (
`id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
`name` varchar(64) COLLATE utf8mb4_persian_ci NOT NULL,
`country` varchar(64) COLLATE utf8mb4_persian_ci NOT NULL,
`phone` varchar(11) COLLATE utf8mb4_persian_ci NOT NULL,
`status` tinyint NOT NULL DEFAULT '1',
`created_at` timestamp NOT NULL,
`updated_at` timestamp NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_persian_ci;
-- --------------------------------------------------------
--
-- Table structure for table `airports`
--
DROP TABLE IF EXISTS `airports`;
CREATE TABLE IF NOT EXISTS `airports` (
`id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
`name` varchar(100) COLLATE utf8mb4_persian_ci NOT NULL,
`city` varchar(64) COLLATE utf8mb4_persian_ci NOT NULL,
`country` varchar(100) COLLATE utf8mb4_persian_ci NOT NULL,
`status` tinyint NOT NULL DEFAULT '0' COMMENT '0:active | 1:inactive',
`created_at` timestamp NOT NULL,
`updated_at` timestamp NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_persian_ci;
-- --------------------------------------------------------
--
-- Table structure for table `booking`
--
DROP TABLE IF EXISTS `booking`;
CREATE TABLE IF NOT EXISTS `booking` (
`id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
`user_id` bigint UNSIGNED NOT NULL,
`flight_id` bigint UNSIGNED DEFAULT NULL,
`tour_departure_id` bigint UNSIGNED DEFAULT NULL,
`total_price` int UNSIGNED NOT NULL,
`status` tinyint NOT NULL DEFAULT '0' COMMENT '0:open | 1:Full',
`created_at` timestamp NOT NULL,
`updated_at` timestamp NOT NULL,
`booking_type` varchar(20) COLLATE utf8mb4_persian_ci NOT NULL,
PRIMARY KEY (`id`),
KEY `booking_fk1` (`user_id`),
KEY `booking_fk2` (`tour_departure_id`),
KEY `booking_fk3` (`flight_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_persian_ci;
-- --------------------------------------------------------
--
-- Table structure for table `booking_passengers`
--
DROP TABLE IF EXISTS `booking_passengers`;
CREATE TABLE IF NOT EXISTS `booking_passengers` (
`id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
`booking_id` bigint UNSIGNED NOT NULL,
`passenger_id` bigint UNSIGNED NOT NULL,
`passenger_type` tinyint(1) NOT NULL DEFAULT '0' COMMENT '0:adult | 1:child ',
`seat_number` varchar(10) COLLATE utf8mb4_persian_ci NOT NULL,
`ticket_number` varchar(30) COLLATE utf8mb4_persian_ci NOT NULL,
`price` int UNSIGNED NOT NULL,
`status` tinyint(1) NOT NULL DEFAULT '0' COMMENT '0:reserved | 1:issued | 2:cancelled',
`created_at` timestamp NOT NULL,
`updated_at` timestamp NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_persian_ci;
-- --------------------------------------------------------
--
-- Table structure for table `cities`
--
DROP TABLE IF EXISTS `cities`;
CREATE TABLE IF NOT EXISTS `cities` (
`id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
`county_id` bigint UNSIGNED NOT NULL,
`name` varchar(64) COLLATE utf8mb4_persian_ci NOT NULL,
`status` tinyint NOT NULL DEFAULT '0',
`created_at` timestamp NOT NULL,
`updated_at` timestamp NOT NULL,
`deleted_at` timestamp NULL DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `cities_fk1` (`county_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_persian_ci;
-- --------------------------------------------------------
--
-- Table structure for table `countries`
--
DROP TABLE IF EXISTS `countries`;
CREATE TABLE IF NOT EXISTS `countries` (
`id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
`name` varchar(64) COLLATE utf8mb4_persian_ci NOT NULL,
`status` tinyint UNSIGNED NOT NULL,
`created_at` timestamp NOT NULL,
`updated_at` timestamp NOT NULL,
`deleted_at` timestamp NULL DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_persian_ci;
-- --------------------------------------------------------
--
-- Table structure for table `files`
--
DROP TABLE IF EXISTS `files`;
CREATE TABLE IF NOT EXISTS `files` (
`id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
`name` varchar(255) COLLATE utf8mb4_persian_ci NOT NULL,
`extension` varchar(10) COLLATE utf8mb4_persian_ci NOT NULL,
`size` bigint UNSIGNED NOT NULL,
`original_name` varchar(255) COLLATE utf8mb4_persian_ci NOT NULL,
`path` varchar(255) COLLATE utf8mb4_persian_ci NOT NULL,
`created_at` timestamp NOT NULL,
`updated_at` timestamp NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_persian_ci;
-- --------------------------------------------------------
--
-- Table structure for table `flights`
--
DROP TABLE IF EXISTS `flights`;
CREATE TABLE IF NOT EXISTS `flights` (
`id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
`airline_id` bigint UNSIGNED NOT NULL,
`origin_airport_id` bigint UNSIGNED NOT NULL,
`destination_airport_id` bigint UNSIGNED NOT NULL,
`flight_number` varchar(20) COLLATE utf8mb4_persian_ci NOT NULL,
`departure_time` datetime NOT NULL,
`price` int UNSIGNED NOT NULL,
`capacity` int UNSIGNED NOT NULL,
`status` tinyint NOT NULL DEFAULT '0' COMMENT '0:available| 1:full|\r\n2:cancelled| 3:draft| 4:Delayed ',
`created_at` timestamp NOT NULL,
`updated_at` timestamp NOT NULL,
PRIMARY KEY (`id`),
KEY `flights_fk1` (`airline_id`),
KEY `flights_fk2` (`origin_airport_id`),
KEY `flights_fk3` (`destination_airport_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_persian_ci;
-- --------------------------------------------------------
--
-- Table structure for table `passengers`
--
DROP TABLE IF EXISTS `passengers`;
CREATE TABLE IF NOT EXISTS `passengers` (
`id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
`user_id` bigint UNSIGNED NOT NULL,
`first_name` varchar(64) COLLATE utf8mb4_persian_ci NOT NULL,
`last_name` varchar(100) COLLATE utf8mb4_persian_ci NOT NULL,
`national_code` varchar(10) COLLATE utf8mb4_persian_ci NOT NULL,
`passport_number` varchar(20) COLLATE utf8mb4_persian_ci NOT NULL,
`gender` tinyint UNSIGNED NOT NULL,
`birth_date` date DEFAULT NULL,
`mobile` varchar(11) COLLATE utf8mb4_persian_ci NOT NULL,
`email` varchar(150) COLLATE utf8mb4_persian_ci NOT NULL,
`nationality` varchar(64) COLLATE utf8mb4_persian_ci NOT NULL,
`created_at` timestamp NOT NULL,
`updated_at` timestamp NOT NULL,
`deleted_at` timestamp NULL DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `passengers_fk1` (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_persian_ci;
-- --------------------------------------------------------
--
-- Table structure for table `tours`
--
DROP TABLE IF EXISTS `tours`;
CREATE TABLE IF NOT EXISTS `tours` (
`id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
`title` varchar(100) COLLATE utf8mb4_persian_ci NOT NULL,
`summary` varchar(150) COLLATE utf8mb4_persian_ci NOT NULL,
`description` text COLLATE utf8mb4_persian_ci NOT NULL,
`origin_city_id` bigint UNSIGNED NOT NULL,
`destination_city_id` bigint UNSIGNED NOT NULL,
`file_id` bigint UNSIGNED NOT NULL,
`tour_type` varchar(64) COLLATE utf8mb4_persian_ci NOT NULL,
`created_at` timestamp NOT NULL,
`updated_at` timestamp NOT NULL,
PRIMARY KEY (`id`),
KEY `tours_fk1` (`file_id`),
KEY `tours_fk2` (`origin_city_id`),
KEY `tours_fk3` (`destination_city_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_persian_ci;
-- --------------------------------------------------------
--
-- Table structure for table `tour_departures`
--
DROP TABLE IF EXISTS `tour_departures`;
CREATE TABLE IF NOT EXISTS `tour_departures` (
`id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
`tour_id` bigint UNSIGNED NOT NULL,
`start_date` date NOT NULL,
`end_date` date NOT NULL,
`price` bigint UNSIGNED NOT NULL,
`capacity` int UNSIGNED NOT NULL,
`status` tinyint NOT NULL DEFAULT '0' COMMENT '0:active | 1:sold out | 2:canceled',
`created_at` timestamp NOT NULL,
`updated_at` timestamp NOT NULL,
PRIMARY KEY (`id`),
KEY `tour_departures_fk1` (`tour_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_persian_ci;
-- --------------------------------------------------------
--
-- Table structure for table `users`
--
DROP TABLE IF EXISTS `users`;
CREATE TABLE IF NOT EXISTS `users` (
`id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
`first_name` varchar(64) COLLATE utf8mb4_persian_ci NOT NULL,
`last_name` varchar(64) COLLATE utf8mb4_persian_ci NOT NULL,
`file_id` bigint UNSIGNED NOT NULL,
`national_code` varchar(10) COLLATE utf8mb4_persian_ci NOT NULL,
`gender` tinyint UNSIGNED NOT NULL DEFAULT '0' COMMENT 'unknown:0 | male:1 | female:2',
`marital_status` tinyint UNSIGNED NOT NULL DEFAULT '0' COMMENT '0:single | 1:married | divorced:2',
`spouse_name` varchar(255) COLLATE utf8mb4_persian_ci DEFAULT NULL,
`mobile` varchar(11) COLLATE utf8mb4_persian_ci NOT NULL,
`email` varchar(150) COLLATE utf8mb4_persian_ci NOT NULL,
`username` varchar(100) COLLATE utf8mb4_persian_ci NOT NULL,
`password` varchar(255) COLLATE utf8mb4_persian_ci NOT NULL,
`user_province` varchar(100) COLLATE utf8mb4_persian_ci DEFAULT NULL,
`user_city` int DEFAULT NULL,
`created_at` timestamp NOT NULL,
`updated_at` timestamp NOT NULL,
`deleted_at` timestamp NULL DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `users_fk1` (`file_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_persian_ci;
--
-- Constraints for dumped tables
--
--
-- Constraints for table `booking`
--
ALTER TABLE `booking`
ADD CONSTRAINT `booking_fk1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
ADD CONSTRAINT `booking_fk2` FOREIGN KEY (`tour_departure_id`) REFERENCES `tour_departures` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
ADD CONSTRAINT `booking_fk3` FOREIGN KEY (`flight_id`) REFERENCES `flights` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT;
--
-- Constraints for table `cities`
--
ALTER TABLE `cities`
ADD CONSTRAINT `cities_fk1` FOREIGN KEY (`county_id`) REFERENCES `countries` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT;
--
-- Constraints for table `flights`
--
ALTER TABLE `flights`
ADD CONSTRAINT `flights_fk1` FOREIGN KEY (`airline_id`) REFERENCES `airlines` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
ADD CONSTRAINT `flights_fk2` FOREIGN KEY (`origin_airport_id`) REFERENCES `airports` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
ADD CONSTRAINT `flights_fk3` FOREIGN KEY (`destination_airport_id`) REFERENCES `airports` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT;
--
-- Constraints for table `passengers`
--
ALTER TABLE `passengers`
ADD CONSTRAINT `passengers_fk1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT;
--
-- Constraints for table `tours`
--
ALTER TABLE `tours`
ADD CONSTRAINT `tours_fk1` FOREIGN KEY (`file_id`) REFERENCES `flights` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
ADD CONSTRAINT `tours_fk2` FOREIGN KEY (`origin_city_id`) REFERENCES `cities` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
ADD CONSTRAINT `tours_fk3` FOREIGN KEY (`destination_city_id`) REFERENCES `cities` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT;
--
-- Constraints for table `tour_departures`
--
ALTER TABLE `tour_departures`
ADD CONSTRAINT `tour_departures_fk1` FOREIGN KEY (`tour_id`) REFERENCES `tours` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT;
--
-- Constraints for table `users`
--
ALTER TABLE `users`
ADD CONSTRAINT `users_fk1` FOREIGN KEY (`file_id`) REFERENCES `files` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT;
COMMIT;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;