· 6 years ago · Dec 10, 2019, 01:44 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 isadmin boolean
27);
28
29create table City(
30 id_city int primary key,
31 nameOfCity text
32);
33
34create table Client(
35 id_Client int primary key,
36 nameOfClient text,
37 telephone text,
38 cardNum text
39);
40
41create table Product (
42 id_product int primary key,
43 nameOfProduct text
44);
45
46create table Orders (
47 id_order int primary key,
48 id_driver int references driver (id),
49 id_client int references client(id_client),
50 id_product int references product(id_product),
51 weight real,
52 dateDelivery timestamp,
53 is_Delivery boolean,
54 point_A int references city (id_city),
55 point_B int references city (id_city)
56);
57
58insert into car values (1,'O000OO78','Volvo',3,10.4);
59insert into car values (2,'A111AA178','Kamaz',5,20.1);
60
61insert into driver values (1,'Ivanov','IVAN','0123','Ivan',5,1,'12.03.1900');
62insert into driver values (2,'Petrov','PETYA','123','Petya',2,2,'12.03.0001');
63insert into driver values (3,'Tvardovsky','admin','123','George',2,2,'01.01.0001', true);
64
65insert into city values (1,'Санкт-Петербург');
66insert into city values (2,'Москва');
67insert into city values (3,'Новосибирск');
68insert into city values (4,'Екатеринбург');
69insert into city values (5,'Нижний Новгород');
70insert into city values (6,'Казань');
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');
77
78insert into orders values (1,1,1,1,10,'12.12.2019',true,1,2)