1 |
|
---|
2 | drop table if exists project.Policy;
|
---|
3 | drop table if exists project.Customer;
|
---|
4 | drop table if exists project.Pol_dog;
|
---|
5 | drop table if exists project.Payment;
|
---|
6 | drop table if exists project.Package;
|
---|
7 | drop table if exists project.Covers;
|
---|
8 | drop table if exists project.Property_pol;
|
---|
9 | drop table if exists project.Property;
|
---|
10 | drop table if exists project.Travel_pol;
|
---|
11 | drop table if exists project.Pol_osi;
|
---|
12 | drop table if exists project.Auto_pol;
|
---|
13 | drop table if exists project.Vehicle;
|
---|
14 |
|
---|
15 | create schema project;
|
---|
16 |
|
---|
17 | create table project.Package(
|
---|
18 | code serial4 primary key,
|
---|
19 | title varchar(255) not null,
|
---|
20 | total numeric NULL,
|
---|
21 | valuet varchar(255) NULL,
|
---|
22 | type_pol int4 NULL
|
---|
23 | );
|
---|
24 |
|
---|
25 | create table project.Policy(
|
---|
26 | p_id serial4 primary key NOT NULL,
|
---|
27 | sdate date not null,
|
---|
28 | edate date not null,
|
---|
29 | package int4,
|
---|
30 | constraint fk_package_pol foreign key (package) references project.Package(code)
|
---|
31 | );
|
---|
32 |
|
---|
33 | create table project.Payment(
|
---|
34 | payment_num serial4 primary key,
|
---|
35 | "policy" int4,
|
---|
36 | p_date date NULL,
|
---|
37 | p_amount int4 NULL,
|
---|
38 | visa_number varchar(255)
|
---|
39 | constraint fk_payment_pol foreign key (policy) references project.Policy(p_id)
|
---|
40 | );
|
---|
41 |
|
---|
42 | create table project.Covers(
|
---|
43 | cov_id int serial4 primary key,
|
---|
44 | cov_amount int4,
|
---|
45 | package int4,
|
---|
46 | cov_type varchar(max),
|
---|
47 | constraint fk_covers_pol foreign key (package) references project.Package(code)
|
---|
48 | );
|
---|
49 |
|
---|
50 |
|
---|
51 | create table project.Customer(
|
---|
52 | c_id serial4 primary key,
|
---|
53 | name varchar(50),
|
---|
54 | email varchar(50) not null,
|
---|
55 | password varchar(50) not null,
|
---|
56 | type bool not null
|
---|
57 | );
|
---|
58 |
|
---|
59 | create table project.Pol_dog(
|
---|
60 | d_embg varchar(13) primary key,
|
---|
61 | c_id int4 NULL,
|
---|
62 | name varchar(255) not null,
|
---|
63 | policy int4,
|
---|
64 | surname varchar(255),
|
---|
65 | birthdate date not null,
|
---|
66 | kontakt varchar(255),
|
---|
67 | constraint fk_Profile_User foreign key (c_id) references project.Customer(c_id),
|
---|
68 | constraint fk_Pol foreign key (policy) references project.Policy(p_id)
|
---|
69 | );
|
---|
70 |
|
---|
71 | CREATE TABLE project.auto_pol (
|
---|
72 | a_id serial4 NOT NULL,
|
---|
73 | pol_id int4 NULL,
|
---|
74 | CONSTRAINT auto_pol_pkey PRIMARY KEY (a_id)
|
---|
75 | );
|
---|
76 | ALTER TABLE project.auto_pol ADD CONSTRAINT fk_pol_vehicle FOREIGN KEY (pol_id) REFERENCES project."policy"(p_id);
|
---|
77 |
|
---|
78 | create table project.Vehicle(
|
---|
79 | v_id serial4 primary key,
|
---|
80 | policy int4,
|
---|
81 | type varchar(255) not null,
|
---|
82 | marka varchar(255),
|
---|
83 | model varchar(255),
|
---|
84 | license_plate varchar(25) not null,
|
---|
85 | constraint fk_Pol_veh foreign key (policy) references project.Auto_pol(a_id)
|
---|
86 | );
|
---|
87 |
|
---|
88 | create table project.Travel_pol(
|
---|
89 | tr_id serial4 primary key,
|
---|
90 | pol_id int4 ,
|
---|
91 | constraint fk_pol_travel foreign key (pol_id) references project.Policy(p_id)
|
---|
92 | );
|
---|
93 |
|
---|
94 | create table project.Pol_osi(
|
---|
95 | o_embg varchar(13) primary key,
|
---|
96 | policy int4,
|
---|
97 | name varchar(255) not null,
|
---|
98 | surname varchar(255),
|
---|
99 | birthdate date not null,
|
---|
100 | kontakt varchar(255),
|
---|
101 | constraint fk_Polosi foreign key (policy) references project.Travel_pol(tr_id)
|
---|
102 | );
|
---|
103 |
|
---|
104 | create table project.Property_pol(
|
---|
105 | pr_id serial4 primary key,
|
---|
106 | pol_id int4,
|
---|
107 | constraint fk_PolProperty foreign key (pol_id) references project.Policy(p_id)
|
---|
108 | );
|
---|
109 |
|
---|
110 | create table project.Property(
|
---|
111 | prop_id serial4 primary key,
|
---|
112 | policy int4,
|
---|
113 | address varchar(255),
|
---|
114 | floor int4,
|
---|
115 | year_build varchar(255),
|
---|
116 | security bool,
|
---|
117 | constraint fk_pol_propp foreign key (policy) references project.Property_pol(pr_id)
|
---|
118 | );
|
---|