-
Notifications
You must be signed in to change notification settings - Fork 0
/
simple_repair_shop.sql
189 lines (155 loc) · 4.58 KB
/
simple_repair_shop.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
-- phpMyAdmin SQL Dump
-- version 5.2.1
-- https://www.phpmyadmin.net/
--
-- Host: localhost
-- Generation Time: Lip 29, 2024 at 09:01 AM
-- Wersja serwera: 10.4.28-MariaDB
-- Wersja PHP: 8.2.4
SET FOREIGN_KEY_CHECKS=0;
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: `repair_shop`
--
CREATE DATABASE IF NOT EXISTS `repair_shop` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
USE `repair_shop`;
-- --------------------------------------------------------
--
-- Struktura tabeli dla tabeli `client`
--
CREATE TABLE `client` (
`id` int(11) NOT NULL,
`name` varchar(50) NOT NULL,
`phone` varchar(18) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-- --------------------------------------------------------
--
-- Struktura tabeli dla tabeli `dealer`
--
CREATE TABLE `dealer` (
`id` int(11) NOT NULL,
`name` varchar(30) NOT NULL,
`phone` varchar(18) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-- --------------------------------------------------------
--
-- Struktura tabeli dla tabeli `repair_application`
--
CREATE TABLE `repair_application` (
`id` int(11) NOT NULL,
`scooter_id` int(11) NOT NULL,
`client_id` int(11) NOT NULL,
`dealer_id` int(11) NOT NULL,
`date_created` datetime NOT NULL DEFAULT current_timestamp(),
`date_changed` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
`description` text NOT NULL,
`status` enum('created','received','in_progress','finished') NOT NULL DEFAULT 'created'
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-- --------------------------------------------------------
--
-- Struktura tabeli dla tabeli `scooter`
--
CREATE TABLE `scooter` (
`id` int(11) NOT NULL,
`make` varchar(20) NOT NULL,
`model` varchar(30) NOT NULL,
`frame_number` varchar(30) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-- --------------------------------------------------------
--
-- Struktura tabeli dla tabeli `user`
--
CREATE TABLE `user` (
`id` int(11) NOT NULL,
`username` varchar(30) NOT NULL,
`hashed_password` varchar(255) NOT NULL,
`active` tinyint(1) NOT NULL DEFAULT 0,
`is_admin` tinyint(1) NOT NULL DEFAULT 0
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;
--
-- Indeksy dla zrzutów tabel
--
--
-- Indeksy dla tabeli `client`
--
ALTER TABLE `client`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `id` (`id`),
ADD KEY `id_2` (`id`);
--
-- Indeksy dla tabeli `dealer`
--
ALTER TABLE `dealer`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `id` (`id`);
--
-- Indeksy dla tabeli `repair_application`
--
ALTER TABLE `repair_application`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `id` (`id`),
ADD KEY `scooter_id` (`scooter_id`),
ADD KEY `client_id` (`client_id`),
ADD KEY `dealer_id` (`dealer_id`);
--
-- Indeksy dla tabeli `scooter`
--
ALTER TABLE `scooter`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `frame_number` (`frame_number`),
ADD UNIQUE KEY `id` (`id`);
--
-- Indeksy dla tabeli `user`
--
ALTER TABLE `user`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `username` (`username`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `client`
--
ALTER TABLE `client`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `dealer`
--
ALTER TABLE `dealer`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `repair_application`
--
ALTER TABLE `repair_application`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `scooter`
--
ALTER TABLE `scooter`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `user`
--
ALTER TABLE `user`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
--
-- Constraints for dumped tables
--
--
-- Constraints for table `repair_application`
--
ALTER TABLE `repair_application`
ADD CONSTRAINT `repair_application_ibfk_1` FOREIGN KEY (`dealer_id`) REFERENCES `dealer` (`id`),
ADD CONSTRAINT `repair_application_ibfk_2` FOREIGN KEY (`client_id`) REFERENCES `client` (`id`),
ADD CONSTRAINT `repair_application_ibfk_3` FOREIGN KEY (`scooter_id`) REFERENCES `scooter` (`id`);
SET FOREIGN_KEY_CHECKS=1;
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 */;