-- http://www.phpmyadmin.net
--
-- Client :  127.0.0.1
-- Généré le :  Ven 25 Décembre 2015 à 11:22
-- Version du serveur :  10.1.8-MariaDB
-- Version de PHP :  5.6.14




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

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

--
-- Structure de la table `categories`
--

CREATE TABLE `categories` (
  `id` int(10) UNSIGNED NOT NULL,
  `name` varchar(200) COLLATE utf8_unicode_ci NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Contenu de la table `categories`
--

INSERT INTO `categories` (`id`, `name`) VALUES
(1, 'ceramic'),
(2, 'sculpture'),
(3, 'drawing');

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

--
-- Structure de la table `category_subcategory`
--

CREATE TABLE `category_subcategory` (
  `id` int(10) UNSIGNED NOT NULL,
  `category_id` int(10) UNSIGNED NOT NULL,
  `subcategory_id` int(10) UNSIGNED NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Contenu de la table `category_subcategory`
--

INSERT INTO `category_subcategory` (`id`, `category_id`, `subcategory_id`) VALUES
(1, 1, 1),
(2, 1, 2),
(3, 1, 3),
(4, 3, 3);

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

--
-- Structure de la table `category_work`
--

CREATE TABLE `category_work` (
  `id` int(10) UNSIGNED NOT NULL,
  `work_id` int(10) UNSIGNED NOT NULL,
  `category_id` int(10) UNSIGNED NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

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

--
-- Structure de la table `migrations`
--

CREATE TABLE `migrations` (
  `migration` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
  `batch` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Contenu de la table `migrations`
--

INSERT INTO `migrations` (`migration`, `batch`) VALUES
('2014_10_12_000000_create_users_table', 1),
('2014_10_12_100000_create_password_resets_table', 1),
('2015_11_26_210434_create_work_table', 1),
('2015_11_26_210434_create_works_table', 2),
('2015_11_26_210435_create_pictures_table', 2),
('2015_11_29_210436_create_works_table', 3),
('2015_11_29_210437_create_pictures_table', 3),
('2015_11_30_210438_create_works_table', 4),
('2015_11_30_210439_create_pictures_table', 4),
('2015_11_30_210440_create_works_table', 5),
('2015_11_30_210441_create_pictures_table', 5),
('2015_12_02_092058_create_mainpictures_table', 5),
('2015_12_03_182041_create_categories_table', 5),
('2015_12_03_183038_create_subcategories_table', 5),
('2015_12_03_183437_create_workcategories_work_table', 5),
('2015_12_03_183448_create_worksubcategories_work_table', 5),
('2015_12_03_185728_create_categories_subcategories_table', 5);

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

--
-- Structure de la table `pictures`
--

CREATE TABLE `pictures` (
  `id` int(10) UNSIGNED NOT NULL,
  `link` varchar(200) COLLATE utf8_unicode_ci NOT NULL,
  `work_id` int(10) UNSIGNED NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

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

--
-- Structure de la table `picture_work`
--

CREATE TABLE `picture_work` (
  `id` int(10) UNSIGNED NOT NULL,
  `work_id` int(10) UNSIGNED NOT NULL,
  `picture_id` int(10) UNSIGNED NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

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

--
-- Structure de la table `subcategories`
--

CREATE TABLE `subcategories` (
  `id` int(10) UNSIGNED NOT NULL,
  `name` varchar(200) COLLATE utf8_unicode_ci NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Contenu de la table `subcategories`
--

INSERT INTO `subcategories` (`id`, `name`) VALUES
(1, 'birds'),
(2, 'containers'),
(3, '2014');

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

--
-- Structure de la table `subcategory_work`
--

CREATE TABLE `subcategory_work` (
  `id` int(10) UNSIGNED NOT NULL,
  `work_id` int(10) UNSIGNED NOT NULL,
  `subcategory_id` int(10) UNSIGNED NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

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

--
-- Structure de la table `works`
--

CREATE TABLE `works` (
  `id` int(10) UNSIGNED NOT NULL,
  `title` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
  `desc` varchar(500) COLLATE utf8_unicode_ci NOT NULL,
  `date` date NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

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

--
-- Index pour la table `categories`
--
ALTER TABLE `categories`
  ADD PRIMARY KEY (`id`);

--
-- Index pour la table `category_subcategory`
--
ALTER TABLE `category_subcategory`
  ADD PRIMARY KEY (`id`),
  ADD KEY `category_subcategory_category_id_foreign` (`category_id`),
  ADD KEY `category_subcategory_subcategory_id_foreign` (`subcategory_id`);

--
-- Index pour la table `category_work`
--
ALTER TABLE `category_work`
  ADD PRIMARY KEY (`id`),
  ADD KEY `category_work_work_id_foreign` (`work_id`),
  ADD KEY `category_work_category_id_foreign` (`category_id`);

--
-- Index pour la table `pictures`
--
ALTER TABLE `pictures`
  ADD PRIMARY KEY (`id`),
  ADD KEY `pictures_work_id_foreign` (`work_id`);

--
-- Index pour la table `picture_work`
--
ALTER TABLE `picture_work`
  ADD PRIMARY KEY (`id`),
  ADD KEY `picture_work_work_id_foreign` (`work_id`),
  ADD KEY `picture_work_picture_id_foreign` (`picture_id`);

--
-- Index pour la table `subcategories`
--
ALTER TABLE `subcategories`
  ADD PRIMARY KEY (`id`);

--
-- Index pour la table `subcategory_work`
--
ALTER TABLE `subcategory_work`
  ADD PRIMARY KEY (`id`),
  ADD KEY `subcategory_work_work_id_foreign` (`work_id`),
  ADD KEY `subcategory_work_subcategory_id_foreign` (`subcategory_id`);

--
-- Index pour la table `works`
--
ALTER TABLE `works`
  ADD PRIMARY KEY (`id`);

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

--
-- AUTO_INCREMENT pour la table `categories`
--
ALTER TABLE `categories`
  MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;
--
-- AUTO_INCREMENT pour la table `category_subcategory`
--
ALTER TABLE `category_subcategory`
  MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;
--
-- AUTO_INCREMENT pour la table `category_work`
--
ALTER TABLE `category_work`
  MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=80;
--
-- AUTO_INCREMENT pour la table `pictures`
--
ALTER TABLE `pictures`
  MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=214;
--
-- AUTO_INCREMENT pour la table `picture_work`
--
ALTER TABLE `picture_work`
  MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=29;
--
-- AUTO_INCREMENT pour la table `subcategories`
--
ALTER TABLE `subcategories`
  MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;
--
-- AUTO_INCREMENT pour la table `subcategory_work`
--
ALTER TABLE `subcategory_work`
  MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=28;
--
-- AUTO_INCREMENT pour la table `works`
--
ALTER TABLE `works`
  MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=80;
--
-- Contraintes pour les tables exportées
--

--
-- Contraintes pour la table `category_subcategory`
--
ALTER TABLE `category_subcategory`
  ADD CONSTRAINT `category_subcategory_category_id_foreign` FOREIGN KEY (`category_id`) REFERENCES `categories` (`id`),
  ADD CONSTRAINT `category_subcategory_subcategory_id_foreign` FOREIGN KEY (`subcategory_id`) REFERENCES `subcategories` (`id`);

--
-- Contraintes pour la table `category_work`
--
ALTER TABLE `category_work`
  ADD CONSTRAINT `category_work_category_id_foreign` FOREIGN KEY (`category_id`) REFERENCES `categories` (`id`),
  ADD CONSTRAINT `category_work_work_id_foreign` FOREIGN KEY (`work_id`) REFERENCES `works` (`id`);

--
-- Contraintes pour la table `pictures`
--
ALTER TABLE `pictures`
  ADD CONSTRAINT `pictures_work_id_foreign` FOREIGN KEY (`work_id`) REFERENCES `works` (`id`);

--
-- Contraintes pour la table `picture_work`
--
ALTER TABLE `picture_work`
  ADD CONSTRAINT `picture_work_picture_id_foreign` FOREIGN KEY (`picture_id`) REFERENCES `pictures` (`id`),
  ADD CONSTRAINT `picture_work_work_id_foreign` FOREIGN KEY (`work_id`) REFERENCES `works` (`id`);

--
-- Contraintes pour la table `subcategory_work`
--
ALTER TABLE `subcategory_work`
  ADD CONSTRAINT `subcategory_work_subcategory_id_foreign` FOREIGN KEY (`subcategory_id`) REFERENCES `subcategories` (`id`),
  ADD CONSTRAINT `subcategory_work_work_id_foreign` FOREIGN KEY (`work_id`) REFERENCES `works` (`id`);

