-- phpMyAdmin SQL Dump
-- version 4.2.12deb2+deb8u2
-- http://www.phpmyadmin.net
--
-- Client :  localhost
-- Généré le :  Jeu 05 Octobre 2017 à 16:05
-- Version du serveur :  5.5.57-0+deb8u1
-- Version de PHP :  5.6.30-0+deb8u1

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 utf8 */;

--
-- Base de données :  `platform_iot`
--

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

--
-- Structure de la table `table_service`
--

CREATE TABLE IF NOT EXISTS `table_service` (
`id` int(11) NOT NULL,
  `name` varchar(100) NOT NULL,
  `type` varchar(20) NOT NULL
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=latin1;

--
-- Contenu de la table `table_service`
--

INSERT INTO `table_service` (`id`, `name`, `type`) VALUES
(1, 'myKWHome', 'smarthome'),
(2, 'FridgAlert', 'smarthome'),
(3, 'RUNstats', 'quantifiedself'),
(4, 'traCARE', 'quantifiedself');

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

--
-- Structure de la table `table_subscribe`
--

CREATE TABLE IF NOT EXISTS `table_subscribe` (
  `id_user` int(11) NOT NULL,
  `id_service` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Contenu de la table `table_subscribe`
--

INSERT INTO `table_subscribe` (`id_user`, `id_service`) VALUES
(2, 1),
(2, 2),
(1, 3);

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

--
-- Structure de la table `table_thing`
--

CREATE TABLE IF NOT EXISTS `table_thing` (
  `mac` varchar(17) NOT NULL,
  `id_user` int(11) NOT NULL,
  `type` varchar(20) NOT NULL,
  `param` varchar(100) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Contenu de la table `table_thing`
--

INSERT INTO `table_thing` (`mac`, `id_user`, `type`, `param`) VALUES
('f0:de:f1:39:7f:17', 1, '', ''),
('f0:de:f1:39:7f:18', 2, '', ''),
('f0:de:f1:39:7f:19', 2, 'thingtempo', '60');

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

--
-- Structure de la table `table_user`
--

CREATE TABLE IF NOT EXISTS `table_user` (
`id` int(11) NOT NULL,
  `firstname` varchar(100) NOT NULL,
  `lastname` varchar(100) NOT NULL,
  `email` varchar(100) NOT NULL
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=latin1;

--
-- Contenu de la table `table_user`
--

INSERT INTO `table_user` (`id`, `firstname`, `lastname`, `email`) VALUES
(1, 'Amaya', 'URSUYA', 'amaya@domain.com'),
(2, 'Maialen', 'HOLZARTE', 'm.holzarte@company.fr');

--
-- Index pour les tables exportées
--

--
-- Index pour la table `table_service`
--
ALTER TABLE `table_service`
 ADD PRIMARY KEY (`id`), ADD KEY `id` (`id`), ADD KEY `id_2` (`id`);

--
-- Index pour la table `table_subscribe`
--
ALTER TABLE `table_subscribe`
 ADD PRIMARY KEY (`id_user`,`id_service`), ADD KEY `id_service` (`id_service`);

--
-- Index pour la table `table_thing`
--
ALTER TABLE `table_thing`
 ADD PRIMARY KEY (`mac`), ADD KEY `mac` (`mac`), ADD KEY `mac_2` (`mac`), ADD KEY `mac_3` (`mac`), ADD KEY `TableThing_ibfk_1` (`id_user`);

--
-- Index pour la table `table_user`
--
ALTER TABLE `table_user`
 ADD PRIMARY KEY (`id`), ADD KEY `id` (`id`), ADD KEY `id_2` (`id`);

--
-- AUTO_INCREMENT pour les tables exportées
--

--
-- AUTO_INCREMENT pour la table `table_service`
--
ALTER TABLE `table_service`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=5;
--
-- AUTO_INCREMENT pour la table `table_user`
--
ALTER TABLE `table_user`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=3;
--
-- Contraintes pour les tables exportées
--

--
-- Contraintes pour la table `table_subscribe`
--
ALTER TABLE `table_subscribe`
ADD CONSTRAINT `table_subscribe_ibfk_1` FOREIGN KEY (`id_service`) REFERENCES `table_service` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
ADD CONSTRAINT `table_subscribe_ibfk_2` FOREIGN KEY (`id_user`) REFERENCES `table_user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Contraintes pour la table `table_thing`
--
ALTER TABLE `table_thing`
ADD CONSTRAINT `table_thing_ibfk_1` FOREIGN KEY (`id_user`) REFERENCES `table_user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

/*!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 */;
