quarta-feira, 19 de junho de 2019

Base de dados oficina às 20.18 do dia 19 de junho de 2019

-- phpMyAdmin SQL Dump
-- version 4.7.5
-- https://www.phpmyadmin.net/
--
-- Host: localhost
-- Generation Time: 19-Jun-2019 às 19:17
-- Versão do servidor: 5.6.34
-- PHP Version: 7.1.11

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT = 0;
START TRANSACTION;
SET time_zone = "+00:00";

--
-- Database: `oficina`
--

-- --------------------------------------------------------

--
-- Estrutura da tabela `funcoes`
--

CREATE TABLE `funcoes` (
  `id` tinyint(4) NOT NULL,
  `funcao` varchar(100) NOT NULL,
  `estado` tinyint(1) NOT NULL DEFAULT '1'
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Extraindo dados da tabela `funcoes`
--

INSERT INTO `funcoes` (`id`, `funcao`, `estado`) VALUES
(1, 'Orçamentista', 1),
(2, 'Recepcionista', 0),
(3, 'Hardware', 1),
(4, 'Software', 1),
(5, 'Gerente', 0);

-- --------------------------------------------------------

--
-- Estrutura da tabela `passwords`
--

CREATE TABLE `passwords` (
  `id` tinyint(4) NOT NULL,
  `pass` varchar(100) NOT NULL,
  `data_atual` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Extraindo dados da tabela `passwords`
--

INSERT INTO `passwords` (`id`, `pass`, `data_atual`) VALUES
(1, 'mloureiro pass', '2019-06-19 18:22:46'),
(2, 'pass da liliana', '2019-06-19 18:35:23');

-- --------------------------------------------------------

--
-- Estrutura da tabela `users`
--

CREATE TABLE `users` (
  `id` tinyint(4) NOT NULL,
  `username` varchar(50) NOT NULL,
  `estado` tinyint(1) NOT NULL DEFAULT '0',
  `data` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='estado=0 para confirmar a autenticidade do username';

--
-- Extraindo dados da tabela `users`
--

INSERT INTO `users` (`id`, `username`, `estado`, `data`) VALUES
(1, 'mloureiro', 0, '2019-06-19 18:21:10'),
(2, 'liliana', 1, '2019-06-19 18:35:00');

-- --------------------------------------------------------

--
-- Estrutura da tabela `users_passwords`
--

CREATE TABLE `users_passwords` (
  `id` tinyint(4) NOT NULL,
  `idUser` tinyint(4) NOT NULL,
  `idPassword` tinyint(4) NOT NULL,
  `estado` tinyint(1) NOT NULL DEFAULT '1',
  `data_atual` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Extraindo dados da tabela `users_passwords`
--

INSERT INTO `users_passwords` (`id`, `idUser`, `idPassword`, `estado`, `data_atual`) VALUES
(1, 1, 1, 1, '2019-06-19 18:26:56'),
(2, 2, 2, 1, '2019-06-19 18:35:56');

-- --------------------------------------------------------

--
-- Stand-in structure for view `v1_funcoes_ativas`
-- (See below for the actual view)
--
CREATE TABLE `v1_funcoes_ativas` (
`idFuncaoAtiva` tinyint(4)
,`funcao` varchar(100)
);

-- --------------------------------------------------------

--
-- Stand-in structure for view `v1_funcoes_inativas`
-- (See below for the actual view)
--
CREATE TABLE `v1_funcoes_inativas` (
`idFuncao` tinyint(4)
,`funcao` varchar(100)
);

-- --------------------------------------------------------

--
-- Stand-in structure for view `v1_login`
-- (See below for the actual view)
--
CREATE TABLE `v1_login` (
`idUser` tinyint(4)
,`username` varchar(50)
,`pass` varchar(100)
);

-- --------------------------------------------------------

--
-- Structure for view `v1_funcoes_ativas`
--
DROP TABLE IF EXISTS `v1_funcoes_ativas`;

CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1_funcoes_ativas`  AS  select `funcoes`.`id` AS `idFuncaoAtiva`,`funcoes`.`funcao` AS `funcao` from `funcoes` where (`funcoes`.`estado` = 1) ;

-- --------------------------------------------------------

--
-- Structure for view `v1_funcoes_inativas`
--
DROP TABLE IF EXISTS `v1_funcoes_inativas`;

CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1_funcoes_inativas`  AS  select `funcoes`.`id` AS `idFuncao`,`funcoes`.`funcao` AS `funcao` from `funcoes` where (`funcoes`.`estado` = 0) ;

-- --------------------------------------------------------

--
-- Structure for view `v1_login`
--
DROP TABLE IF EXISTS `v1_login`;

CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1_login`  AS  select `users_passwords`.`idUser` AS `idUser`,`users`.`username` AS `username`,`passwords`.`pass` AS `pass` from ((`users` join `passwords`) join `users_passwords`) where ((`users`.`id` = `users_passwords`.`idUser`) and (`passwords`.`id` = `users_passwords`.`idPassword`) and (`users_passwords`.`estado` = 1) and (`users`.`estado` = 1)) ;

--
-- Indexes for dumped tables
--

--
-- Indexes for table `funcoes`
--
ALTER TABLE `funcoes`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `passwords`
--
ALTER TABLE `passwords`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `users`
--
ALTER TABLE `users`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `users_passwords`
--
ALTER TABLE `users_passwords`
  ADD PRIMARY KEY (`id`),
  ADD KEY `idUser` (`idUser`),
  ADD KEY `idPassword` (`idPassword`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `funcoes`
--
ALTER TABLE `funcoes`
  MODIFY `id` tinyint(4) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;

--
-- AUTO_INCREMENT for table `passwords`
--
ALTER TABLE `passwords`
  MODIFY `id` tinyint(4) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;

--
-- AUTO_INCREMENT for table `users`
--
ALTER TABLE `users`
  MODIFY `id` tinyint(4) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;

--
-- AUTO_INCREMENT for table `users_passwords`
--
ALTER TABLE `users_passwords`
  MODIFY `id` tinyint(4) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;

--
-- Constraints for dumped tables
--

--
-- Limitadores para a tabela `users_passwords`
--
ALTER TABLE `users_passwords`
  ADD CONSTRAINT `users_passwords_ibfk_1` FOREIGN KEY (`idPassword`) REFERENCES `passwords` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `users_passwords_ibfk_2` FOREIGN KEY (`idUser`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
COMMIT;

Sem comentários:

Enviar um comentário