· 7 years ago · Oct 24, 2018, 01:22 PM
1--- STARTUP DEFAULTS ---------
2SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
3SET time_zone = "+00:00";
4---- DATABASE: Delivery
5CREATE DATABASE IF NOT EXISTS `Delivery` DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
6USE `Delivery`;
7
8CREATE TABLE Branch(
9 id int(4) NOT NULL DEFAULT '0',
10 latitude float(8) DEFAULT NULL,
11 longitude float(8) DEFAULT NULL,
12 address varchar(18) COLLATE utf8_unicode_ci DEFAULT NULL,
13 PRIMARY KEY (id)
14) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
15
16CREATE TABLE Driver(
17 id int(4) NOT NULL DEFAULT '0' ,
18 name varchar(18) COLLATE utf8_unicode_ci DEFAULT NULL,
19 id_branch int(4) DEFAULT NULL,
20 PRIMARY KEY (id),
21 FOREIGN KEY (id_branch) REFERENCES Branch(id)
22) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
23
24CREATE TABLE Vehicle(
25 id int(4) NOT NULL DEFAULT '0',
26 brandname varchar(18) COLLATE utf8_unicode_ci DEFAULT NULL,
27 model varchar(18) COLLATE utf8_unicode_ci DEFAULT NULL,
28 capacity int(4) DEFAULT NULL,
29 id_type int(4) DEFAULT NULL,
30 PRIMARY KEY (id),
31 FOREIGN KEY (id_type) REFERENCES Type(id)
32) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
33
34CREATE TABLE Type(
35 id int(4) NOT NULL DEFAULT '0',
36 name varchar(18) COLLATE utf8_unicode_ci DEFAULT NULL,
37 wheels int(2) DEFAULT NULL,
38 PRIMARY KEY (id)
39) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
40
41CREATE TABLE Business(
42 id int(4) NOT NULL DEFAULT '0',
43 name varchar(18) COLLATE utf8_unicode_ci DEFAULT NULL,
44 latitude float(8) DEFAULT NULL,
45 longitude float(8) DEFAULT NULL,
46 address varchar(18) COLLATE utf8_unicode_ci DEFAULT NULL,
47 id_category int(4) DEFAULT NULL,
48 PRIMARY KEY (id),
49 FOREIGN KEY (id_category) REFERENCES Category(id)
50) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;