GRANT USAGE ON *.* TO 'user'@'%';
DROP USER  'user'@'%';

DROP DATABASE IF EXISTS `user_db` ;

CREATE USER 'user'@'%' IDENTIFIED BY 'password';
GRANT USAGE ON * . * TO 'user'@'%' IDENTIFIED BY 'password' 
       WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0 ;
CREATE DATABASE IF NOT EXISTS `user_db` ;
GRANT ALL PRIVILEGES ON `user_db` . * TO 'user'@'%';



USE `user_db`;
--
-- Database: `user_db`
--

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

--
-- Table structure for table `user`
--

CREATE TABLE IF NOT EXISTS `user` (
  `email` varchar(20) NOT NULL,
  `password` varchar(20) DEFAULT NULL,
  PRIMARY KEY (`email`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `user`
--

INSERT INTO `user` (`email`, `password`) VALUES
('vl@ujf-grenoble.fr', 'passvl'),
('jfb@ujf-grenoble.fr', 'passjfb');
-- --------------------------------------------------------

--
-- Table structure for table `article`
--

CREATE TABLE IF NOT EXISTS `article` (
  `id` int(11) NOT NULL,
  `content` varchar(2048) DEFAULT NULL,
  `email` varchar(20) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

ALTER TABLE `article` ADD CONSTRAINT FK_article_email FOREIGN KEY (`email`) REFERENCES user (`email`) ON DELETE CASCADE ON UPDATE CASCADE;
--
-- Dumping data for table `article`
--

INSERT INTO `article` (`id`, `content`, `email`) VALUES
(1, 'etre directeur des études', 'vl@ujf-grenoble.fr'),
(2, 'etre informaticien au 22ème siecle', 'vl@ujf-grenoble.fr');


