-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathschema.sql
More file actions
69 lines (51 loc) · 1.85 KB
/
schema.sql
File metadata and controls
69 lines (51 loc) · 1.85 KB
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
begin;
create type management_type as enum ('weg', 'mv');
create type unit_type as enum ('apartment', 'office', 'garden', 'parking');
create table property_managers (
id serial primary key,
name text not null,
address text not null,
unique (name, address)
);
create table accountants (
id serial primary key,
name text not null,
address text not null,
unique (name, address)
);
create table properties (
id serial primary key,
name text not null,
unique_number text not null unique,
management_type management_type not null,
total_mea numeric not null,
property_manager_id int not null references property_managers(id),
accountant_id int not null references accountants(id)
);
create table declaration_files (
property_id int primary key references properties(id) on update cascade on delete cascade,
content bytea not null
);
create table buildings (
id serial primary key,
property_id int not null references properties(id) on update cascade on delete cascade,
name text not null,
street text not null,
house_number text not null,
construction_year int not null,
description text not null default ''
);
create table units (
id serial primary key,
building_id int not null references buildings(id) on update cascade on delete cascade,
number text not null,
type unit_type not null,
floor text not null,
entrance text not null,
size numeric not null,
co_ownership_share numeric not null,
construction_year int not null,
rooms int not null default 0,
description text not null default ''
);
commit;