· 6 years ago · Dec 09, 2019, 07:18 PM
1drop table if exists Orders;
2drop table if exists Package;
3drop table if exists Product;
4drop table if exists Client;
5drop table if exists City;
6drop table if exists Driver;
7drop table if exists Car;
8
9create table Car (
10 id_Car int primary key,
11 carNumber text,
12 carName text,
13 carrying real,
14 fuelConsumption real
15);
16
17create table Driver (
18 id serial primary key,
19 surname text,
20 username text not null,
21 _password text not null,
22 nameDriver text,
23 experience real,
24 carNumber int references Car(id_Car),
25 dateBirth date
26);
27
28create table City(
29 id_city int primary key,
30 nameOfCity text
31);
32
33create table Client(
34 id_Client int primary key,
35 nameOfClient text,
36 telephone text,
37 cardNum text
38);
39
40create table Product (
41 id_product int primary key,
42 nameOfProduct text
43);
44
45create table Package (
46 id_package int primary key,
47 id_Product int references product (id_product),
48 weight real
49);
50
51create table Orders (
52 id_order int primary key,
53 id_car int references car(id_car),
54 id_client int references client(id_client),
55 id_product int references product(id_product),
56 id_driver int references driver (id),
57 dateDelivery timestamp,
58 isDelivery boolean,
59 pointA int references city (id_city),
60 pointB int references city (id_city)
61);
62
63insert into car values (1,'O000OO78','Volvo',3,10.4);
64insert into car values (2,'A111AA178','Kamaz',5,20.1);
65
66insert into driver values (1,'Ivanov','IVAN','0123','Ivan',5,1,'12.03.1900');
67insert into driver values (2,'Petrov','PETYA','123','Petya',2,2,'12.03.0001');
68
69insert into city values (1,'Saint-P');
70insert into city values (2,'Moscow');
71
72insert into client values (1,'Client1','89999999999','1234567890');
73insert into client values (2,'Client2','88888888888','0987654321');
74
75insert into product values (1,'Paper');
76insert into product values (2,'Paper2');