SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT = 0;
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 */;

CREATE DATABASE IF NOT EXISTS `oficina` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci;
USE `oficina`;

CREATE TABLE `departamentos` (
  `IdDepartamento` int(11) NOT NULL,
  `Nombre` varchar(128) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

INSERT INTO `departamentos` (`IdDepartamento`, `Nombre`) VALUES
(1, 'Diseño Gráfico'),
(2, 'Desarrollo Frontend'),
(3, 'Desarrollo Backend'),
(4, 'Administración'),
(5, 'Administración de Sistemas');

CREATE TABLE `empleados` (
  `IdEmpleado` int(11) NOT NULL,
  `Nombre` varchar(128) NOT NULL,
  `Apellidos` varchar(255) NOT NULL,
  `IdDepartamento` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

INSERT INTO `empleados` (`IdEmpleado`, `Nombre`, `Apellidos`, `IdDepartamento`) VALUES
(1, 'Manuel', 'García Sánchez', 1),
(2, 'María', 'Perez Sil', 3),
(3, 'Francisco', 'Martín Martín', 2),
(4, 'Raúl', 'Gil Suárez', 1),
(5, 'Clara', 'Mar Pinal', 2),
(6, 'María', 'Gil Ruíz', NULL),
(7, 'Luis', 'Manuel Pérez', 4),
(8, 'Mary', 'Carmen Martín', NULL);


ALTER TABLE `departamentos`
  ADD PRIMARY KEY (`IdDepartamento`);

ALTER TABLE `empleados`
  ADD PRIMARY KEY (`IdEmpleado`);


ALTER TABLE `departamentos`
  MODIFY `IdDepartamento` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;

ALTER TABLE `empleados`
  MODIFY `IdEmpleado` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=9;
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 */;
