-- http://www.phpmyadmin.net
--
-- Хост: localhost
-- Время создания: Май 05 2016 г., 15:51
-- Версия сервера: 5.5.49-0ubuntu0.14.04.1
-- Версия PHP: 5.5.9-1ubuntu4.16




--
-- База данных: `trusted-contacts`
--

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

--
-- Структура таблицы `categories`
--

CREATE TABLE IF NOT EXISTS `categories` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(100) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=3 ;

--
-- Дамп данных таблицы `categories`
--

INSERT INTO `categories` (`id`, `name`) VALUES
(1, 'Buisiness'),
(2, 'Law');

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

--
-- Структура таблицы `companies`
--

CREATE TABLE IF NOT EXISTS `companies` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) NOT NULL,
  `tooltip_text` varchar(255) DEFAULT NULL,
  `description` text NOT NULL,
  `address` varchar(255) DEFAULT NULL,
  `phone` varchar(45) DEFAULT NULL,
  `companiescol` varchar(45) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=4 ;

--
-- Дамп данных таблицы `companies`
--

INSERT INTO `companies` (`id`, `name`, `tooltip_text`, `description`, `address`, `phone`, `companiescol`) VALUES
(1, 'FlexAspect', 'IT company', 'web sites development, PHP, .NET\r\napplication development, Android, iOs, Windows', 'Berlin, Main street, 123', '0448769743', 'dfg dfgdfg'),
(2, 'Google', 'IT company', 'web sites development, PHP, .NET\r\napplication development, Android, iOs, Windows', 'Russia, Main street, 123', '456456 456 45', 'dfg dfg dfg '),
(3, 'SONY', 'IT company', 'dflkgj ls dfkgj lsdfg hldfkjg hldkfjg hldkfjg hldkfj glsdkfj ldsgk jlsdfkj g', 'Ukrain, Main street, 123', '567 567 567 56', 'dfg dfgdfg');

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

--
-- Структура таблицы `company_tags`
--

CREATE TABLE IF NOT EXISTS `company_tags` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `id_company` int(10) unsigned NOT NULL,
  `id_tag` int(10) unsigned NOT NULL,
  PRIMARY KEY (`id`),
  KEY `fk_company_tags_company_idx` (`id_company`),
  KEY `fk_company_tags_tag_idx` (`id_tag`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;

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

--
-- Структура таблицы `groups`
--

CREATE TABLE IF NOT EXISTS `groups` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `id_category` int(10) unsigned NOT NULL,
  `name` varchar(100) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `fk_Groups_Categories` (`id_category`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=7 ;

--
-- Дамп данных таблицы `groups`
--

INSERT INTO `groups` (`id`, `id_category`, `name`) VALUES
(1, 1, 'Finance'),
(2, 1, 'Industry'),
(3, 1, 'Sales'),
(4, 1, 'Trade'),
(5, 2, 'Edicts'),
(6, 2, 'Civil law');

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

--
-- Структура таблицы `group_companies`
--

CREATE TABLE IF NOT EXISTS `group_companies` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `id_group` int(10) unsigned NOT NULL,
  `id_company` int(10) unsigned NOT NULL,
  PRIMARY KEY (`id`),
  KEY `fk_group_companies_group_idx` (`id_group`),
  KEY `fk_group_companies_company_idx` (`id_company`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=4 ;

--
-- Дамп данных таблицы `group_companies`
--

INSERT INTO `group_companies` (`id`, `id_group`, `id_company`) VALUES
(1, 2, 1),
(2, 2, 2),
(3, 2, 3);

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

--
-- Структура таблицы `tags`
--

CREATE TABLE IF NOT EXISTS `tags` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(100) NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `name_UNIQUE` (`name`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=6 ;

--
-- Дамп данных таблицы `tags`
--

INSERT INTO `tags` (`id`, `name`) VALUES
(3, 'Industry'),
(4, 'law'),
(5, 'logistics'),
(1, 'management');

--
-- Ограничения внешнего ключа сохраненных таблиц
--

--
-- Ограничения внешнего ключа таблицы `company_tags`
--
ALTER TABLE `company_tags`
  ADD CONSTRAINT `fk_company_tags_company` FOREIGN KEY (`id_company`) REFERENCES `companies` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  ADD CONSTRAINT `fk_company_tags_tag` FOREIGN KEY (`id_tag`) REFERENCES `tags` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION;

--
-- Ограничения внешнего ключа таблицы `groups`
--
ALTER TABLE `groups`
  ADD CONSTRAINT `fk_Groups_Categories` FOREIGN KEY (`id_category`) REFERENCES `categories` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION;

--
-- Ограничения внешнего ключа таблицы `group_companies`
--
ALTER TABLE `group_companies`
  ADD CONSTRAINT `fk_group_companies_group` FOREIGN KEY (`id_group`) REFERENCES `groups` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  ADD CONSTRAINT `fk_group_companies_company` FOREIGN KEY (`id_company`) REFERENCES `companies` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION;

