-- phpMyAdmin SQL Dump
-- version 5.2.1
-- https://www.phpmyadmin.net/
--
-- Host: 172.20.0.2
-- Generation Time: Jul 20, 2023 at 03:02 PM
-- Server version: 10.4.28-MariaDB-1:10.4.28+maria~ubu2004
-- PHP Version: 8.1.15

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
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 */;

--
-- Database: `minibase_relationships`
--

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

--
-- Table structure for table `company`
--

CREATE TABLE `company` (
  `id` int(11) NOT NULL,
  `upload_date` date NOT NULL DEFAULT current_timestamp(),
  `last_update_date` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE current_timestamp(),
  `name` varchar(100) NOT NULL,
  `corporation_type` varchar(50) NOT NULL,
  `role` int(11) NOT NULL,
  `country_bill` varchar(100) NOT NULL,
  `state_bill` varchar(100) NOT NULL,
  `city_bill` varchar(100) NOT NULL,
  `postal_code_bill` int(11) NOT NULL,
  `street_bill` varchar(100) NOT NULL,
  `street_no_bill` int(11) NOT NULL,
  `country_ship` varchar(100) NOT NULL,
  `state_ship` varchar(100) NOT NULL,
  `city_ship` varchar(100) NOT NULL,
  `postal_code_ship` int(11) NOT NULL,
  `street_ship` varchar(100) NOT NULL,
  `street_no_ship` int(11) NOT NULL,
  `main_comapany` tinyint(1) NOT NULL DEFAULT 1,
  `subsidiary_of` int(11) DEFAULT NULL,
  `classification` int(11) NOT NULL,
  `comment` varchar(300) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `company`
--

INSERT INTO `company` (`id`, `upload_date`, `last_update_date`, `name`, `corporation_type`, `role`, `country_bill`, `state_bill`, `city_bill`, `postal_code_bill`, `street_bill`, `street_no_bill`, `country_ship`, `state_ship`, `city_ship`, `postal_code_ship`, `street_ship`, `street_no_ship`, `main_comapany`, `subsidiary_of`, `classification`, `comment`) VALUES
(1, '2022-08-17', '0000-00-00 00:00:00', 'Steinel Solutions', 'AG', 4, 'Switzerland', 'Schwyz', 'Einsiedeln', 8840, 'Allmeindstrasse', 10, 'Switzerland', 'Schwyz', 'Einsiedeln', 8840, 'Allmeindstrasse', 10, 1, 5, 0, 'Main STM Client'),
(5, '2022-10-03', '0000-00-00 00:00:00', 'Steinel Vertrieb', 'GmbH', 3, 'Germany', '', 'Herzebrock-Clarholz', 33442, 'Dieselstrasse', 80, 'Germany', '', 'Herzebrock-Clarholz', 33442, 'Dieselstrasse', 80, 1, NULL, 0, 'OEM PArt of Steinel solutions'),
(6, '2022-10-03', '0000-00-00 00:00:00', 'Steinel Technik', 's.r.o', 1, 'Czechia', '', 'Liberec', 46001, 'Rumunská', 655, 'Czechia', '', 'Liberec', 46001, 'Rumunská', 655, 1, 5, 0, 'Production site of Steinel in Czechia'),
(7, '2022-11-14', '2022-11-14 16:49:15', 'Solutioneer', 'NU', 6, 'Schweiz', 'Zürich', 'Uster', 8610, 'Meirackerstrasse', 10, 'Switzerland', 'Zürich', 'Uster', 8610, 'Meirackerstrasse', 10, 1, NULL, 1, 'The main organisation');

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

--
-- Table structure for table `company_role`
--

CREATE TABLE `company_role` (
  `id` int(11) NOT NULL,
  `name` varchar(50) NOT NULL,
  `description` varchar(300) NOT NULL,
  `reference` varchar(20) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `company_role`
--

INSERT INTO `company_role` (`id`, `name`, `description`, `reference`) VALUES
(1, 'EMS', 'Electronics manufacturing services', 'EMS'),
(2, 'Desing Partner', 'Desing partner for other clients', 'DP'),
(3, 'OEM', 'Original Equipment Manufacturer', 'OEM'),
(4, 'Engineering', 'Engineering Partner for custommer', 'EP'),
(6, 'Owner', 'We are the firm', 'OWNER');

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

--
-- Table structure for table `person`
--

CREATE TABLE `person` (
  `id` int(11) NOT NULL,
  `name` varchar(50) NOT NULL,
  `last_name` varchar(50) NOT NULL,
  `date_of_birth` date NOT NULL,
  `role` int(11) NOT NULL,
  `company` int(11) DEFAULT NULL,
  `tel_prof_fix` varchar(30) DEFAULT NULL,
  `tel_prof_mobile` varchar(30) DEFAULT NULL,
  `tel_priv_fix` varchar(30) DEFAULT NULL,
  `tel_priv_mobile` varchar(30) DEFAULT NULL,
  `mail_prof` varchar(320) NOT NULL,
  `mail_priv` varchar(320) DEFAULT NULL,
  `country` varchar(75) NOT NULL,
  `state` varchar(75) DEFAULT NULL,
  `city` varchar(75) DEFAULT NULL,
  `post_code` varchar(10) DEFAULT NULL,
  `street_name` varchar(150) DEFAULT NULL,
  `street_no` int(11) DEFAULT NULL,
  `upload_date` date NOT NULL DEFAULT current_timestamp(),
  `last_update_date` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `person`
--

INSERT INTO `person` (`id`, `name`, `last_name`, `date_of_birth`, `role`, `company`, `tel_prof_fix`, `tel_prof_mobile`, `tel_priv_fix`, `tel_priv_mobile`, `mail_prof`, `mail_priv`, `country`, `state`, `city`, `post_code`, `street_name`, `street_no`, `upload_date`, `last_update_date`) VALUES
(1, 'Stefan', 'Walker', '1980-11-01', 1, 1, '+41 876 45 35', '+41 876 45 45', NULL, NULL, 'stefan.walker@steinel.ch', NULL, '', NULL, NULL, NULL, NULL, NULL, '2022-11-14', '2022-11-14 16:23:49'),
(2, 'Kerem', 'Yollu', '1991-09-24', 2, 7, NULL, '+41 78 97 166 97', NULL, NULL, 'kerem.yollu@solutioneer.ch', 'Kerem.yollu@gmail.com', 'Switzerland', 'Zürich', 'Uster', '8610', 'Meirackerstrasse', 10, '2022-11-14', '2022-11-14 16:07:38'),
(3, 'Martina', 'Landolt', '1985-12-30', 3, 7, '+41 555 45 56', NULL, NULL, NULL, 'martina.landolt@solutioneer.ch', NULL, '', NULL, NULL, NULL, NULL, NULL, '2022-11-14', '2022-11-14 16:04:13');

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

--
-- Table structure for table `person_role`
--

CREATE TABLE `person_role` (
  `id` int(11) NOT NULL,
  `name` varchar(50) NOT NULL,
  `description` varchar(300) NOT NULL,
  `reference` varchar(20) NOT NULL,
  `upload_date` date NOT NULL DEFAULT current_timestamp(),
  `last_update_date` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `person_role`
--

INSERT INTO `person_role` (`id`, `name`, `description`, `reference`, `upload_date`, `last_update_date`) VALUES
(1, 'Egineering Manager', 'Manages the engineering team', 'Engineering', '2022-11-14', '2022-11-14 15:25:58'),
(2, 'CEO', 'Chief Executif Officer', 'Management', '2022-11-14', '2022-11-14 17:01:28'),
(3, 'FAE', 'Field Application Engineer', 'Engineering', '2022-11-14', '2022-11-14 17:01:28'),
(4, 'FSE', 'Field Sales Engineer', 'Sales', '2022-11-14', '2022-11-14 17:02:50');

--
-- Indexes for dumped tables
--

--
-- Indexes for table `company`
--
ALTER TABLE `company`
  ADD PRIMARY KEY (`id`),
  ADD KEY `fk_client_role` (`role`) USING BTREE,
  ADD KEY `fk_subsidiary` (`subsidiary_of`);

--
-- Indexes for table `company_role`
--
ALTER TABLE `company_role`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `person`
--
ALTER TABLE `person`
  ADD PRIMARY KEY (`id`),
  ADD KEY `fk_role` (`role`),
  ADD KEY `fk_company` (`company`);

--
-- Indexes for table `person_role`
--
ALTER TABLE `person_role`
  ADD PRIMARY KEY (`id`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `company`
--
ALTER TABLE `company`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=8;

--
-- AUTO_INCREMENT for table `company_role`
--
ALTER TABLE `company_role`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7;

--
-- AUTO_INCREMENT for table `person`
--
ALTER TABLE `person`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;

--
-- AUTO_INCREMENT for table `person_role`
--
ALTER TABLE `person_role`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;

--
-- Constraints for dumped tables
--

--
-- Constraints for table `company`
--
ALTER TABLE `company`
  ADD CONSTRAINT `fk_client_role` FOREIGN KEY (`role`) REFERENCES `company_role` (`id`),
  ADD CONSTRAINT `fk_subsidiary` FOREIGN KEY (`subsidiary_of`) REFERENCES `company` (`id`);

--
-- Constraints for table `person`
--
ALTER TABLE `person`
  ADD CONSTRAINT `fk_company` FOREIGN KEY (`company`) REFERENCES `company` (`id`),
  ADD CONSTRAINT `fk_role` FOREIGN KEY (`role`) REFERENCES `person_role` (`id`);
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 */;
