-- --------------------------------------------------------
-- Server OS:                    Linux
-- HeidiSQL Version:             12.12.0.7122
-- --------------------------------------------------------



-- Dumping database structure for el_trenesanas_eksamenam_1
CREATE DATABASE IF NOT EXISTS `el_trenesanas_eksamenam_1` /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci */ /*!80016 DEFAULT ENCRYPTION='N' */;
USE `el_trenesanas_eksamenam_1`;

-- Dumping structure for view el_trenesanas_eksamenam_1.el_result_1
-- Creating temporary table to overcome VIEW dependency errors
CREATE TABLE `el_result_1` (
	`id` INT NOT NULL COMMENT 'Unikāls numurs',
	`week_day` TINYINT NULL COMMENT 'Nedēļas diena',
	`date` DATE NULL COMMENT 'Datums katrai dienai',
	`time` TIME NULL COMMENT 'Stundas laiks',
	`start_time` DATETIME NULL COMMENT 'Sākuma laiks',
	`end_time` DATETIME NULL COMMENT 'Beigu laiks'
);

-- Dumping structure for view el_trenesanas_eksamenam_1.el_result_2
-- Creating temporary table to overcome VIEW dependency errors
CREATE TABLE `el_result_2` (
	`id` INT NOT NULL COMMENT 'Unikālais numurs',
	`work_type` VARCHAR(1) NULL COMMENT 'Darba nosaukums' COLLATE 'utf8mb4_general_ci',
	`work_problem` VARCHAR(1) NULL COMMENT 'Darba kļūdu apraksts' COLLATE 'utf8mb4_general_ci',
	`work_nr` DECIMAL(5,2) NULL COMMENT 'Darba numurs',
	`follow_nr` VARCHAR(1) NULL COMMENT 'Apsekojuma numurs' COLLATE 'utf8mb4_general_ci',
	`unit` INT NULL COMMENT 'Mērvienības norādes skaitlis',
	`measurement` VARCHAR(1) NULL COMMENT 'Mērvienības nosaukums' COLLATE 'utf8mb4_general_ci'
);

-- Dumping structure for view el_trenesanas_eksamenam_1.el_result_3
-- Creating temporary table to overcome VIEW dependency errors
CREATE TABLE `el_result_3` (
	`id` INT NOT NULL COMMENT 'Unikāls numurs',
	`worker_name` VARCHAR(1) NULL COMMENT 'Darbinieka vārds' COLLATE 'utf8mb4_general_ci'
);

-- Dumping structure for view el_trenesanas_eksamenam_1.el_result_4
-- Creating temporary table to overcome VIEW dependency errors
CREATE TABLE `el_result_4` (
	`id` INT NOT NULL COMMENT 'Unikāls numurs',
	`work_name` VARCHAR(1) NULL COMMENT 'Darba vietas nosaukums' COLLATE 'utf8mb4_general_ci'
);

-- Dumping structure for view el_trenesanas_eksamenam_1.el_result_5
-- Creating temporary table to overcome VIEW dependency errors
CREATE TABLE `el_result_5` (
	`id` INT NOT NULL COMMENT 'Unikāls numurs',
	`price` DECIMAL(20,0) NULL COMMENT 'Cena par darbu',
	`amount` DECIMAL(20,0) NULL COMMENT 'Daudzums cik nepieciešams',
	`sum` DECIMAL(20,0) NULL COMMENT 'Kopējā summa'
);

-- Removing temporary table and create final VIEW structure
CREATE ALGORITHM=UNDEFINED SQL SECURITY DEFINER VIEW `el_result_1` AS select `date`.`id` AS `id`,`date`.`week_day` AS `week_day`,`date`.`date` AS `date`,`date`.`time` AS `time`,`date`.`start_time` AS `start_time`,`date`.`end_time` AS `end_time` from `date`
;

-- Removing temporary table and create final VIEW structure
CREATE ALGORITHM=UNDEFINED SQL SECURITY DEFINER VIEW `el_result_2` AS select `work`.`id` AS `id`,`work`.`work_type` AS `work_type`,`work`.`work_problem` AS `work_problem`,`work`.`work_nr` AS `work_nr`,`work`.`follow_nr` AS `follow_nr`,`work`.`unit` AS `unit`,`work`.`measurement` AS `measurement` from `work`
;

-- Removing temporary table and create final VIEW structure
CREATE ALGORITHM=UNDEFINED SQL SECURITY DEFINER VIEW `el_result_3` AS select `worker`.`id` AS `id`,`worker`.`worker_name` AS `worker_name` from `worker`
;

-- Removing temporary table and create final VIEW structure
CREATE ALGORITHM=UNDEFINED SQL SECURITY DEFINER VIEW `el_result_4` AS select `work_place`.`id` AS `id`,`work_place`.`work_name` AS `work_name` from `work_place`
;

-- Removing temporary table and create final VIEW structure
CREATE ALGORITHM=UNDEFINED SQL SECURITY DEFINER VIEW `el_result_5` AS select `funds_info`.`id` AS `id`,`funds_info`.`price` AS `price`,`funds_info`.`amount` AS `amount`,`funds_info`.`sum` AS `sum` from `funds_info`
;

