text: -- phpMyAdmin SQL Dump
  -- version 4.6.6deb5ubuntu0.5
  -- https://www.phpmyadmin.net/
  --
  -- Máy chủ: localhost:3306
  -- Thời gian đã tạo: Th10 11, 2021 lúc 11:27 PM
  -- Phiên bản máy phục vụ: 5.7.35-0ubuntu0.18.04.2
  -- Phiên bản PHP: 7.4.24
  
  SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
  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 */;
  
  --
  -- Cơ sở dữ liệu: `pmd`
  --
  
  -- --------------------------------------------------------
  
  --
  -- Cấu trúc bảng cho bảng `admin`
  --
  
  CREATE TABLE `admin` (
    `id` int(10) UNSIGNED NOT NULL,
    `name` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL,
    `email` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL,
    `password` varchar(150) COLLATE utf8mb4_unicode_ci NOT NULL,
    `admin_token` varchar(150) CHARACTER SET utf8mb4 DEFAULT NULL,
    `created_at` timestamp NULL DEFAULT NULL,
    `updated_at` timestamp NULL DEFAULT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  
  --
  -- Đang đổ dữ liệu cho bảng `admin`
  --
  
  INSERT INTO `admin` (`id`, `name`, `email`, `password`, `admin_token`, `created_at`, `updated_at`) VALUES
  (1, 'Tran Van Duc', 'ductran0207.bkhn@gmail.com', '$2y$10$Jiq1rd74siD5Q3BcrDwz1u8UWWtCVEiDhJRwLeLy/VzXgoo2KFQ7y', 'WKpeGILhlJxjFlBi', NULL, '2021-10-11 11:18:26'),
  (2, 'Phan Mai Duyen', 'phanmaiduyen3@gmail.com', '123', NULL, NULL, NULL);
  
  -- --------------------------------------------------------
  
  --
  -- Cấu trúc bảng cho bảng `bill`
  --
  
  CREATE TABLE `bill` (
    `id` int(10) UNSIGNED NOT NULL,
    `idStudent` int(10) UNSIGNED NOT NULL,
    `idTypepay` int(11) NOT NULL,
    `idAdmin` int(10) UNSIGNED NOT NULL,
    `dateTime` date NOT NULL,
    `money` double NOT NULL,
    `note` text COLLATE utf8mb4_unicode_ci NOT NULL,
    `created_at` timestamp NULL DEFAULT NULL,
    `updated_at` timestamp NULL DEFAULT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  
  --
  -- Đang đổ dữ liệu cho bảng `bill`
  --
  
  -- INSERT INTO `bill` (`id`, `idStudent`, `idTypepay`, `idAdmin`, `dateTime`, `money`, `note`, `created_at`, `updated_at`) VALUES
  -- (1, 1, 1, 2, '2021-10-08', 2000000, 'Học phí 10-2021', '2021-10-08 08:32:36', '2021-10-08 08:32:36'),
  -- (2, 14, 3, 2, '2021-10-08', 23333333, 'Học phí 10-2021', '2021-10-08 08:32:56', '2021-10-08 08:32:56'),
  -- (3, 4, 3, 2, '2021-10-08', 20000000, 'Học phí 10-2021', '2021-10-08 08:33:12', '2021-10-08 08:33:12'),
  -- (4, 12, 3, 2, '2021-11-08', 23333333, 'Học phí 10-2021', '2021-10-08 08:33:34', '2021-10-08 08:33:34'),
  -- (5, 11, 3, 2, '2021-11-08', 23333333, 'Học phí 10-2021', '2021-10-08 08:33:58', '2021-10-08 08:33:58'),
  -- (6, 15, 2, 2, '2021-12-08', 8333333.5, 'Học phí 10-2021', '2021-10-08 08:35:25', '2021-10-08 08:35:25'),
  -- (7, 3, 3, 2, '2021-10-08', 23333333, 'Học phí 10-2021', '2021-10-08 11:06:10', '2021-10-08 11:06:10'),
  -- (8, 6, 2, 2, '2021-10-08', 12000000, 'Học phí 10-2021', '2021-10-08 11:06:41', '2021-10-08 11:06:41'),
  -- (9, 1, 1, 1, '2021-10-11', 2000000, 'Học phí 10-2021', '2021-10-11 11:07:39', '2021-10-11 11:07:39');
  
  -- --------------------------------------------------------
  
  --
  -- Cấu trúc bảng cho bảng `course`
  --
  
  CREATE TABLE `course` (
    `id` int(10) UNSIGNED NOT NULL,
    `name` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL,
    `created_at` timestamp NULL DEFAULT NULL,
    `updated_at` timestamp NULL DEFAULT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  
  --
  -- Đang đổ dữ liệu cho bảng `course`
  --
  
  -- INSERT INTO `course` (`id`, `name`, `created_at`, `updated_at`) VALUES
  -- (1, 'K11', '2021-09-27 08:23:04', '2021-09-27 08:23:04'),
  -- (2, 'K10', '2021-09-27 08:23:13', '2021-09-27 08:23:13'),
  -- (3, 'K9', '2021-09-28 07:43:15', '2021-09-28 07:43:15'),
  -- (4, 'K12', '2021-09-28 07:43:28', '2021-09-28 07:43:28'),
  -- (5, 'K13', '2021-10-07 19:12:31', '2021-10-07 19:12:31'),
  -- (6, 'K14', '2021-10-08 09:44:01', '2021-10-08 09:44:01');
  
  -- --------------------------------------------------------
  
  --
  -- Cấu trúc đóng vai cho view `fullname`
  -- (See below for the actual view)
  --
  CREATE TABLE `fullname` (
  `idStudent` int(10) unsigned
  ,`fullname` varchar(101)
  );
  
  -- --------------------------------------------------------
  
  --
  -- Cấu trúc đóng vai cho view `gender`
  -- (See below for the actual view)
  --
  CREATE TABLE `gender` (
  `id` int(10) unsigned
  ,`gender` varchar(6)
  );
  
  -- --------------------------------------------------------
  
  --
  -- Cấu trúc bảng cho bảng `grade`
  --
  
  CREATE TABLE `grade` (
    `id` int(10) UNSIGNED NOT NULL,
    `name` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL,
    `idMajor` int(10) UNSIGNED NOT NULL,
    `idCourse` int(10) UNSIGNED NOT NULL,
    `created_at` timestamp NULL DEFAULT NULL,
    `updated_at` timestamp NULL DEFAULT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  
  --
  -- Đang đổ dữ liệu cho bảng `grade`
  --
  
  -- INSERT INTO `grade` (`id`, `name`, `idMajor`, `idCourse`, `created_at`, `updated_at`) VALUES
  -- (1, 'BKD01K11', 1, 1, '2021-09-27 08:23:42', '2021-09-27 08:23:42'),
  -- (2, 'BKN01K11', 1, 2, '2021-09-27 08:23:51', '2021-09-27 08:23:51'),
  -- (3, 'BKD01K9', 3, 1, '2021-09-28 07:45:01', '2021-09-28 07:45:10'),
  -- (4, 'BKD02K11', 1, 1, '2021-09-28 07:45:29', '2021-09-28 07:45:29'),
  -- (5, 'BKD03K11', 1, 1, '2021-09-28 07:45:38', '2021-09-28 07:45:38'),
  -- (6, 'BKD04K11', 1, 1, '2021-09-28 07:45:55', '2021-09-28 07:45:55'),
  -- (7, 'BKD05K11', 1, 1, '2021-09-28 08:52:51', '2021-09-28 08:52:51'),
  -- (8, 'BIT01K11', 1, 3, '2021-10-04 19:57:12', '2021-10-04 19:57:12'),
  -- (9, 'BIT02', 3, 1, '2021-10-07 10:06:24', '2021-10-07 10:06:24'),
  -- (10, 'BKD01K10', 1, 2, '2021-10-07 19:19:07', '2021-10-07 19:19:07'),
  -- (11, 'BKN01K10', 2, 2, '2021-10-07 19:19:27', '2021-10-07 19:19:27'),
  -- (12, 'BIT01K10', 3, 2, '2021-10-07 19:19:54', '2021-10-07 19:19:54'),
  -- (13, 'BKD02K9', 1, 3, '2021-10-08 08:43:25', '2021-10-08 08:43:25'),
  -- (14, 'BKN010K11', 2, 1, '2021-10-11 11:11:16', '2021-10-11 11:11:16'),
  -- (15, 'Demo', 1, 5, NULL, NULL);
  
  -- --------------------------------------------------------
  
  --
  -- Cấu trúc đóng vai cho view `list_tuition`
  -- (See below for the actual view)
  --
  CREATE TABLE `list_tuition` (
  `id_grade` int(10) unsigned
  ,`namegGade` varchar(50)
  ,`id_course` int(10) unsigned
  ,`nameCouse` varchar(50)
  ,`tuitionNorm` double
  );
  
  -- --------------------------------------------------------
  
  --
  -- Cấu trúc bảng cho bảng `major`
  --
  
  CREATE TABLE `major` (
    `id` int(10) UNSIGNED NOT NULL,
    `name` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL,
    `dayAdmission` date NOT NULL,
    `created_at` timestamp NULL DEFAULT NULL,
    `updated_at` timestamp NULL DEFAULT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  
  --
  -- Đang đổ dữ liệu cho bảng `major`
  --
  
  -- INSERT INTO `major` (`id`, `name`, `dayAdmission`, `created_at`, `updated_at`) VALUES
  -- (1, 'Lập trình máy tính', '2019-08-15', '2021-09-27 08:22:47', '2021-09-27 08:22:47'),
  -- (2, 'Quản trị mạng', '2018-08-15', '2021-09-28 07:21:08', '2021-09-28 07:21:08'),
  -- (3, 'Quản trị kinh doanh', '2017-08-15', '2021-09-28 07:41:04', '2021-09-28 07:41:04'),
  -- (4, 'Thiết kế đồ họa', '2020-08-28', '2021-09-28 07:42:11', '2021-09-28 07:42:11');
  
  -- --------------------------------------------------------
  
  --
  -- Cấu trúc bảng cho bảng `migrations`
  --
  
  CREATE TABLE `migrations` (
    `id` int(10) UNSIGNED NOT NULL,
    `migration` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
    `batch` int(11) NOT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  
  --
  -- Đang đổ dữ liệu cho bảng `migrations`
  --
  
  INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES
  (1, '2021_06_27_175850_admin', 1),
  (2, '2021_06_27_180006_scholarship', 1),
  (3, '2021_06_27_180126_course', 1),
  (4, '2021_06_27_180144_major', 1),
  (5, '2021_06_27_180240_typepay', 1),
  (6, '2021_06_27_180338_tuition', 1),
  (7, '2021_06_27_180400_grade', 1),
  (8, '2021_06_27_180408_student', 1),
  (9, '2021_06_27_180433_bill', 1);
  
  -- --------------------------------------------------------
  
  --
  -- Cấu trúc bảng cho bảng `scholarship`
  --
  
  CREATE TABLE `scholarship` (
    `id` int(10) UNSIGNED NOT NULL,
    `money` double NOT NULL,
    `created_at` timestamp NULL DEFAULT NULL,
    `updated_at` timestamp NULL DEFAULT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  
  --
  -- Đang đổ dữ liệu cho bảng `scholarship`
  --
  
  -- INSERT INTO `scholarship` (`id`, `money`, `created_at`, `updated_at`) VALUES
  -- (1, 10000000, '2021-09-27 08:23:20', '2021-09-27 08:23:20'),
  -- (2, 6000000, '2021-09-28 07:44:09', '2021-09-28 07:44:09'),
  -- (3, 15000000, '2021-10-04 19:55:56', '2021-10-04 19:55:56'),
  -- (4, 20000000, '2021-10-04 19:56:08', '2021-10-04 19:56:08'),
  -- (5, 8000000, '2021-10-04 19:56:29', '2021-10-04 19:56:29');
  
  -- --------------------------------------------------------
  
  --
  -- Cấu trúc bảng cho bảng `student`
  --
  
  CREATE TABLE `student` (
    `id` int(10) UNSIGNED NOT NULL,
    `firstname` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL,
    `lastname` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL,
    `gender` tinyint(1) NOT NULL,
    `email` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL,
    `phone` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL,
    `password` varchar(150) COLLATE utf8mb4_unicode_ci NOT NULL,
    `address` varchar(150) COLLATE utf8mb4_unicode_ci NOT NULL,
    `dob` date NOT NULL,
    `idGrade` int(10) UNSIGNED NOT NULL,
    `idScholarship` int(10) UNSIGNED NOT NULL,
    `idTypePay` int(10) UNSIGNED NOT NULL,
    `created_at` timestamp NULL DEFAULT NULL,
    `updated_at` timestamp NULL DEFAULT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  
  --
  -- Đang đổ dữ liệu cho bảng `student`
  --
  
  -- INSERT INTO `student` (`id`, `firstname`, `lastname`, `gender`, `email`, `phone`, `password`, `address`, `dob`, `idGrade`, `idScholarship`, `idTypePay`, `created_at`, `updated_at`) VALUES
  -- (1, 'Tran Van', 'Duc', 1, 'ductran0207.bkhn@gmail.com', '0968845131', '$2y$10$Z8IwFfOcdgj/JYvK8LXyI.xyk5Iq.PvX2/cXp8euWmKJhz8cvniP2', 'Số nhà 69, 96 Lĩnh Nam, Hà Nội', '1996-07-02', 1, 1, 1, '2021-09-27 08:25:02', '2021-10-11 10:57:12'),
  -- (2, 'Phan', 'Mai Duyen', 0, 'phanmaiduyen3@gmail.com', '0362270120', '$2y$10$.orVs3SS2lu0wQV8vr4m9.0SYvMuinZnCrSYEGeygundGglbRgDL.', 'Ninh Bình', '2001-06-05', 1, 1, 1, '2021-10-04 19:46:57', '2021-10-04 19:46:57'),
  -- (3, 'Nguyễn', 'Hồng Quân', 1, 'quannguyen@gmail.com', '0862750989', '$2y$10$jUDGm9IeNHt7Mjh01yo46One2dlR9LhV4rj9uKVC.AjiacERLGuMi', 'Ninh Bình', '2001-02-11', 2, 1, 3, '2021-10-04 19:53:52', '2021-10-04 19:53:52'),
  -- (4, 'Trần', 'Thu Hường', 0, 'tranthuhuong@gmail.com', '0854125736', '123', 'Thái Bình', '2001-08-01', 1, 1, 3, '2021-10-04 19:54:45', '2021-10-04 19:54:45'),
  -- (5, 'Nguyễn', 'Khánh Vân', 0, 'nguyenkhanhvan@gmail.com', '0928763455', '$2y$10$2rN0qs0ZI96/ZXhukvpsA.tCTMPTBTllnF7ws4l0mfD/9A6JpgH3O', 'Hà Nội', '2001-04-05', 7, 1, 3, '2021-10-04 19:55:39', '2021-10-04 19:55:39'),
  -- (6, 'Đỗ Hoàng', 'Ngọc Lan', 1, 'dohoangngoclan@gmail.com', '0923675455', '$2y$10$KozeqXrBIsvUkuI1IvSdS.ZBWgJA7lQjTlQqg7m6ChEKwx6hJwCD6', 'Hà Nội', '2001-04-11', 8, 5, 2, '2021-10-04 19:59:27', '2021-10-04 19:59:27'),
  -- (7, 'Kiều', 'Bích Ngọc', 0, 'kieubichngoc@gmail.com', '0923873455', '$2y$10$6gO8U7pEWZoOMxXyto6ByuRstmH16EewH6f1Tk95UFk5wDH0YyNTq', 'Hà Nội', '2001-02-02', 8, 4, 2, '2021-10-07 08:30:44', '2021-10-07 08:30:44'),
  -- (8, 'Phạm', 'Thị Hảo', 0, 'phamthihao@gmail.com', '0957265738', '$2y$10$Lcr.J/2Ge3jfgeM3A2fQT.BnLpstg88ky.wqhXemL2xrZ5Q58UdI6', 'Bắc Giang', '2001-04-02', 3, 3, 3, '2021-10-07 19:15:40', '2021-10-07 19:15:40'),
  -- (9, 'Nguyễn', 'Văn An', 1, 'nguyenvanan@gmail.com', '0966225752', '$2y$10$Q0z4JN1sujICHyHSMpjcEuNMd7JHHT7yMv8q94xBTf/CBnwoZo8lW', 'Bắc Giang', '2002-12-05', 3, 1, 3, '2021-10-07 19:16:46', '2021-10-07 19:16:46'),
  -- (10, 'Nguyễn', 'Hoàng Thái', 1, 'nguyenhoangthai@gmail.com', '0862333482', '$2y$10$EVOxZLfUDRF9WCyzmsi8O.mEdDyRMaXX6OxBImrRDK2sfM7gIQyBe', 'Bắc Ninh', '2000-08-03', 12, 5, 3, '2021-10-07 19:21:24', '2021-10-07 19:21:24'),
  -- (11, 'Hoàng', 'Văn Hưng', 1, 'hoangvanhung@gmail.com', '0398793455', '$2y$10$NoHfBhkOLPvtEBZ8kxRjgO8akjDL9Km4ZRglJNXHeqjpG3EBvBxr2', 'Phú Thọ', '2000-09-09', 10, 1, 3, '2021-10-07 19:22:45', '2021-10-07 19:22:45'),
  -- (12, 'Phạm', 'Anh Quốc', 1, 'phamanhquoc@gmail.com', '0858465832', '$2y$10$w/ucjQdc/KO0K.I2m3zJI.hWSXLOI3baXAuh.jdX/W9u7I9cVERJ2', 'Hải Dương', '2000-08-08', 10, 1, 3, '2021-10-07 19:28:00', '2021-10-07 19:28:00'),
  -- (13, 'Trần', 'Thị Hoa', 0, 'tranthihoa@gmail.com', '0857685736', '$2y$10$.cXScoNVegomxXDN0bfQXeOGsUudsox1fKAy9FCJlm6LZVUw2UoSS', 'Thái Bình', '2000-07-04', 10, 5, 3, '2021-10-07 19:34:25', '2021-10-07 19:34:25'),
  -- (14, 'Kiều', 'Thị Hoài', 0, 'kieuthihoai@gmail.com', '0885768736', '$2y$10$wYVVcG71UslfuPWW/mYrYOKBiuM9kEczKwi9.x6Jte8rJGJoSgsFa', 'Ninh Binh', '2000-09-09', 12, 1, 3, '2021-10-08 03:16:22', '2021-10-08 03:16:22'),
  -- (15, 'Nguyễn', 'Duyen', 0, 'nguyenduyen@gmail.com', '0387972122', '$2y$10$CNqq6glERhmiIWlXRQPz6../z3BBRFD4Yr.I2a3WLTRJ94sIkusd.', 'Ninh Binh', '2000-09-09', 10, 4, 2, '2021-10-08 08:34:54', '2021-10-08 08:34:54'),
  -- (16, 'Le Thi', 'Nam', 1, 'vannamm@gmail.com', '0968845139', '$2y$10$Q1rvDJi.UU2iYGbcFNRxXOcOjK3G217r.V5bNJkm7aS9ySlfvGewG', 'TH', '2000-06-06', 10, 5, 1, '2021-10-11 11:12:34', '2021-10-11 11:12:34'),
  -- (17, 'Mai', 'Duyên', 0, 'maiduyennn@gmail.com', '09665554411', '123', 'HN', '2021-10-05', 15, 1, 1, NULL, NULL);
  
  -- --------------------------------------------------------
  
  --
  -- Cấu trúc đóng vai cho view `student_bill`
  -- (See below for the actual view)
  --
  CREATE TABLE `student_bill` (
  `idS` int(10) unsigned
  ,`firstname` varchar(50)
  ,`lastname` varchar(50)
  ,`email` varchar(50)
  ,`dob` date
  ,`nameGrade` varchar(50)
  );
  
  -- --------------------------------------------------------
  
  --
  -- Cấu trúc đóng vai cho view `student_courses`
  -- (See below for the actual view)
  --
  CREATE TABLE `student_courses` (
  `lastname` varchar(50)
  ,`id_course` int(10) unsigned
  ,`COURSE_NAME` varchar(50)
  );
  
  -- --------------------------------------------------------
  
  --
  -- Cấu trúc đóng vai cho view `student_major`
  -- (See below for the actual view)
  --
  CREATE TABLE `student_major` (
  `lastname` varchar(50)
  ,`hinh_thuc_dong` int(10) unsigned
  ,`MA_LOP` int(10) unsigned
  ,`MA_NGANH` int(10) unsigned
  ,`name` varchar(50)
  );
  
  -- --------------------------------------------------------
  
  --
  -- Cấu trúc bảng cho bảng `tuition`
  --
  
  CREATE TABLE `tuition` (
    `idMajor` int(10) UNSIGNED NOT NULL,
    `idCourse` int(10) UNSIGNED NOT NULL,
    `tuitionNorm` double NOT NULL,
    `created_at` timestamp NULL DEFAULT NULL,
    `updated_at` timestamp NULL DEFAULT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  
  --
  -- Đang đổ dữ liệu cho bảng `tuition`
  --
  
  -- INSERT INTO `tuition` (`idMajor`, `idCourse`, `tuitionNorm`, `created_at`, `updated_at`) VALUES
  -- (1, 1, 70000000, '2021-09-27 08:24:05', '2021-10-11 11:04:02'),
  -- (2, 1, 80000000, '2021-10-08 08:29:20', '2021-10-08 08:29:57'),
  -- (3, 1, 80000000, '2021-10-08 08:29:07', '2021-10-08 08:29:44'),
  -- (4, 1, 80000000, '2021-10-04 19:57:53', '2021-10-04 19:57:53'),
  -- (2, 2, 80000000, '2021-10-08 08:30:52', '2021-10-08 08:30:52'),
  -- (1, 3, 80000000, '2021-10-04 19:58:11', '2021-10-04 19:58:11'),
  -- (4, 4, 90000000, '2021-10-04 20:10:55', '2021-10-04 20:10:55'),
  -- (1, 6, 90000000, '2021-10-08 09:44:43', '2021-10-08 09:44:43');
  
  -- --------------------------------------------------------
  
  --
  -- Cấu trúc bảng cho bảng `typepay`
  --
  
  CREATE TABLE `typepay` (
    `id` int(10) UNSIGNED NOT NULL,
    `typeofpay` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL,
    `discount` double(8,2) NOT NULL,
    `begin` tinyint(4) NOT NULL,
    `end` tinyint(4) NOT NULL,
    `created_at` timestamp NULL DEFAULT NULL,
    `updated_at` timestamp NULL DEFAULT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  
  --
  -- Đang đổ dữ liệu cho bảng `typepay`
  --
  
  -- INSERT INTO `typepay` (`id`, `typeofpay`, `discount`, `begin`, `end`, `created_at`, `updated_at`) VALUES
  -- (1, 'Months', 0.00, 1, 20, '2021-09-27 08:23:31', '2021-09-27 08:23:31'),
  -- (2, 'Years', 5.00, 1, 20, '2021-09-28 07:44:39', '2021-09-28 07:44:39'),
  -- (3, 'Semesters', 10.00, 1, 20, '2021-09-29 11:32:11', '2021-09-29 11:32:11');
  
  -- --------------------------------------------------------
  
  --
  -- Cấu trúc cho view `fullname`
  --
  DROP TABLE IF EXISTS `fullname`;
  
  CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `fullname`  AS  select `student`.`id` AS `idStudent`,concat(`student`.`firstname`,' ',`student`.`lastname`) AS `fullname` from `student` ;
  
  -- --------------------------------------------------------
  
  --
  -- Cấu trúc cho view `gender`
  --
  DROP TABLE IF EXISTS `gender`;
  
  CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `gender`  AS  select `student`.`id` AS `id`,(case when (`student`.`gender` = 1) then 'Male' when (`student`.`gender` = 0) then 'Female' else 'Others' end) AS `gender` from `student` ;
  
  -- --------------------------------------------------------
  
  --
  -- Cấu trúc cho view `list_tuition`
  --
  DROP TABLE IF EXISTS `list_tuition`;
  
  CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `list_tuition`  AS  select `grade`.`id` AS `id_grade`,`grade`.`name` AS `namegGade`,`course`.`id` AS `id_course`,`course`.`name` AS `nameCouse`,`tuition`.`tuitionNorm` AS `tuitionNorm` from ((`course` join `grade` on((`course`.`id` = `grade`.`idCourse`))) join `tuition` on((`course`.`id` = `tuition`.`idCourse`))) ;
  
  -- --------------------------------------------------------
  
  --
  -- Cấu trúc cho view `student_bill`
  --
  DROP TABLE IF EXISTS `student_bill`;
  
  CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `student_bill`  AS  select `student`.`id` AS `idS`,`student`.`firstname` AS `firstname`,`student`.`lastname` AS `lastname`,`student`.`email` AS `email`,`student`.`dob` AS `dob`,`grade`.`name` AS `nameGrade` from (`student` join `grade` on((`student`.`idGrade` = `grade`.`id`))) ;
  
  -- --------------------------------------------------------
  
  --
  -- Cấu trúc cho view `student_courses`
  --
  DROP TABLE IF EXISTS `student_courses`;
  
  CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `student_courses`  AS  select `student`.`lastname` AS `lastname`,`course`.`id` AS `id_course`,`course`.`name` AS `COURSE_NAME` from ((`grade` join `student` on((`grade`.`id` = `student`.`idGrade`))) join `course` on((`grade`.`idMajor` = `course`.`id`))) ;
  
  -- --------------------------------------------------------
  
  --
  -- Cấu trúc cho view `student_major`
  --
  DROP TABLE IF EXISTS `student_major`;
  
  CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `student_major`  AS  select `student`.`lastname` AS `lastname`,`student`.`idTypePay` AS `hinh_thuc_dong`,`student`.`idGrade` AS `MA_LOP`,`grade`.`idMajor` AS `MA_NGANH`,`major`.`name` AS `name` from ((`grade` join `student` on((`grade`.`id` = `student`.`idGrade`))) join `major` on((`grade`.`idMajor` = `major`.`id`))) ;
  
  --
  -- Chỉ mục cho các bảng đã đổ
  --
  
  --
  -- Chỉ mục cho bảng `admin`
  --
  ALTER TABLE `admin`
    ADD PRIMARY KEY (`id`),
    ADD UNIQUE KEY `admin_email_unique` (`email`);
  
  --
  -- Chỉ mục cho bảng `bill`
  --
  ALTER TABLE `bill`
    ADD PRIMARY KEY (`id`),
    ADD KEY `bill_idstudent_foreign` (`idStudent`),
    ADD KEY `bill_idadmin_foreign` (`idAdmin`);
  
  --
  -- Chỉ mục cho bảng `course`
  --
  ALTER TABLE `course`
    ADD PRIMARY KEY (`id`);
  
  --
  -- Chỉ mục cho bảng `grade`
  --
  ALTER TABLE `grade`
    ADD PRIMARY KEY (`id`),
    ADD KEY `grade_idmajor_foreign` (`idMajor`),
    ADD KEY `grade_idcourse_foreign` (`idCourse`);
  
  --
  -- Chỉ mục cho bảng `major`
  --
  ALTER TABLE `major`
    ADD PRIMARY KEY (`id`);
  
  --
  -- Chỉ mục cho bảng `migrations`
  --
  ALTER TABLE `migrations`
    ADD PRIMARY KEY (`id`);
  
  --
  -- Chỉ mục cho bảng `scholarship`
  --
  ALTER TABLE `scholarship`
    ADD PRIMARY KEY (`id`);
  
  --
  -- Chỉ mục cho bảng `student`
  --
  ALTER TABLE `student`
    ADD PRIMARY KEY (`id`),
    ADD UNIQUE KEY `student_email_unique` (`email`),
    ADD UNIQUE KEY `student_phone_unique` (`phone`),
    ADD KEY `student_idgrade_foreign` (`idGrade`),
    ADD KEY `student_idscholarship_foreign` (`idScholarship`),
    ADD KEY `student_idtypepay_foreign` (`idTypePay`);
  
  --
  -- Chỉ mục cho bảng `tuition`
  --
  ALTER TABLE `tuition`
    ADD PRIMARY KEY (`idCourse`,`idMajor`),
    ADD KEY `tuition_idmajor_foreign` (`idMajor`);
  
  --
  -- Chỉ mục cho bảng `typepay`
  --
  ALTER TABLE `typepay`
    ADD PRIMARY KEY (`id`);
  
  --
  -- AUTO_INCREMENT cho các bảng đã đổ
  --
  
  --
  -- AUTO_INCREMENT cho bảng `admin`
  --
  ALTER TABLE `admin`
    MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
  --
  -- AUTO_INCREMENT cho bảng `bill`
  --
  ALTER TABLE `bill`
    MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=10;
  --
  -- AUTO_INCREMENT cho bảng `course`
  --
  ALTER TABLE `course`
    MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7;
  --
  -- AUTO_INCREMENT cho bảng `grade`
  --
  ALTER TABLE `grade`
    MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=16;
  --
  -- AUTO_INCREMENT cho bảng `major`
  --
  ALTER TABLE `major`
    MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;
  --
  -- AUTO_INCREMENT cho bảng `migrations`
  --
  ALTER TABLE `migrations`
    MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=10;
  --
  -- AUTO_INCREMENT cho bảng `scholarship`
  --
  ALTER TABLE `scholarship`
    MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;
  --
  -- AUTO_INCREMENT cho bảng `student`
  --
  ALTER TABLE `student`
    MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=18;
  --
  -- AUTO_INCREMENT cho bảng `typepay`
  --
  ALTER TABLE `typepay`
    MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;
  --
  -- Các ràng buộc cho các bảng đã đổ
  --
  
  --
  -- Các ràng buộc cho bảng `bill`
  --
  ALTER TABLE `bill`
    ADD CONSTRAINT `bill_idadmin_foreign` FOREIGN KEY (`idAdmin`) REFERENCES `admin` (`id`),
    ADD CONSTRAINT `bill_idstudent_foreign` FOREIGN KEY (`idStudent`) REFERENCES `student` (`id`);
  
  --
  -- Các ràng buộc cho bảng `grade`
  --
  ALTER TABLE `grade`
    ADD CONSTRAINT `grade_idcourse_foreign` FOREIGN KEY (`idCourse`) REFERENCES `course` (`id`),
    ADD CONSTRAINT `grade_idmajor_foreign` FOREIGN KEY (`idMajor`) REFERENCES `major` (`id`);
  
  --
  -- Các ràng buộc cho bảng `student`
  --
  ALTER TABLE `student`
    ADD CONSTRAINT `student_idgrade_foreign` FOREIGN KEY (`idGrade`) REFERENCES `grade` (`id`),
    ADD CONSTRAINT `student_idscholarship_foreign` FOREIGN KEY (`idScholarship`) REFERENCES `scholarship` (`id`),
    ADD CONSTRAINT `student_idtypepay_foreign` FOREIGN KEY (`idTypePay`) REFERENCES `typepay` (`id`);
  
  --
  -- Các ràng buộc cho bảng `tuition`
  --
  ALTER TABLE `tuition`
    ADD CONSTRAINT `tuition_idcourse_foreign` FOREIGN KEY (`idCourse`) REFERENCES `course` (`id`),
    ADD CONSTRAINT `tuition_idmajor_foreign` FOREIGN KEY (`idMajor`) REFERENCES `major` (`id`);
  
  /*!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 */;
  