-- phpMyAdmin SQL Dump
-- version 4.7.9
-- https://www.phpmyadmin.net/
--
-- ???????????: 127.0.0.1
-- ?????? ???????????: 08 ??? 2020 ???? 07:14:29
-- ?????? ??????????: 10.1.31-MariaDB
-- ?????? PHP: 7.2.3
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 */;
--
-- ???? ?????????: `dialectorm`
--
-- --------------------------------------------------------
--
-- ???? ?????? ??? ??? ?????? `comments`
--
CREATE TABLE `comments` (
`id` int(11) NOT NULL,
`content` text NOT NULL,
`post_id` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- --------------------------------------------------------
--
-- ???? ?????? ??? ??? ?????? `postmeta`
--
CREATE TABLE `postmeta` (
`id` int(11) NOT NULL,
`status` enum('approved','published','suspended') CHARACTER SET latin1 COLLATE latin1_general_ci NOT NULL,
`type` enum('article','tutorial','general') CHARACTER SET latin1 COLLATE latin1_general_ci NOT NULL,
`post_id` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- --------------------------------------------------------
--
-- ???? ?????? ??? ??? ?????? `posts`
--
CREATE TABLE `posts` (
`id` int(11) NOT NULL,
`content` text
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- --------------------------------------------------------
--
-- ???? ?????? ??? ??? ?????? `users`
--
CREATE TABLE `users` (
`id` int(11) NOT NULL,
`name` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- --------------------------------------------------------
--
-- ???? ?????? ??? ??? ?????? `user_post`
--
CREATE TABLE `user_post` (
`user_id` int(11) NOT NULL,
`post_id` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- ????????? ??? ????????? ???????
--
--
-- ????????? ??? ?????? `comments`
--
ALTER TABLE `comments`
ADD PRIMARY KEY (`id`),
ADD KEY `comments_post_id_foreign` (`post_id`);
--
-- ????????? ??? ?????? `postmeta`
--
ALTER TABLE `postmeta`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `post_id` (`post_id`);
--
-- ????????? ??? ?????? `posts`
--
ALTER TABLE `posts`
ADD PRIMARY KEY (`id`);
--
-- ????????? ??? ?????? `users`
--
ALTER TABLE `users`
ADD PRIMARY KEY (`id`);
--
-- ????????? ??? ?????? `user_post`
--
ALTER TABLE `user_post`
ADD PRIMARY KEY (`user_id`,`post_id`),
ADD KEY `post_id_foreign` (`post_id`);
--
-- AUTO_INCREMENT ??? ????????? ???????
--
--
-- AUTO_INCREMENT ??? ?????? `comments`
--
ALTER TABLE `comments`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT ??? ?????? `postmeta`
--
ALTER TABLE `postmeta`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT ??? ?????? `posts`
--
ALTER TABLE `posts`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT ??? ?????? `users`
--
ALTER TABLE `users`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
--
-- ??????????? ??? ????????? ???????
--
--
-- ??????????? ??? ?????? `comments`
--
ALTER TABLE `comments`
ADD CONSTRAINT `comments_post_id_foreign` FOREIGN KEY (`post_id`) REFERENCES `posts` (`id`) ON DELETE CASCADE;
--
-- ??????????? ??? ?????? `postmeta`
--
ALTER TABLE `postmeta`
ADD CONSTRAINT `postmeta_post_id_foreign_key` FOREIGN KEY (`post_id`) REFERENCES `posts` (`id`) ON DELETE CASCADE;
--
-- ??????????? ??? ?????? `user_post`
--
ALTER TABLE `user_post`
ADD CONSTRAINT `post_id_foreign` FOREIGN KEY (`post_id`) REFERENCES `posts` (`id`) ON DELETE CASCADE,
ADD CONSTRAINT `user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE;
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 */;
|