|
1 -- table declarations : |
|
2 create table "code_list_item" ( |
|
3 "l3" bigint not null, |
|
4 "l1" bigint not null, |
|
5 "i18n" boolean not null, |
|
6 "name" varchar(100) not null, |
|
7 "ol2" bigint, |
|
8 "s3" varchar(200) not null, |
|
9 "id" bigint primary key not null, |
|
10 "oi1" integer, |
|
11 "rank" integer not null, |
|
12 "code_list" varchar(40) not null, |
|
13 "dflt" boolean not null, |
|
14 "s2" varchar(200) not null, |
|
15 "i3" integer not null, |
|
16 "os1" varchar(200), |
|
17 "ol1" bigint, |
|
18 "oi2" integer, |
|
19 "i1" integer not null, |
|
20 "s1" varchar(200) not null, |
|
21 "note" varchar(10240), |
|
22 "os2" varchar(200), |
|
23 "i2" integer not null, |
|
24 "oi3" integer, |
|
25 "l2" bigint not null, |
|
26 "ol3" bigint, |
|
27 "os3" varchar(200), |
|
28 "deleted" boolean not null |
|
29 ); |
|
30 create sequence "code_list_item_id_seq"; |
|
31 -- indexes on code_list_item |
|
32 create index "code_list_item_code_list_idx" on "code_list_item" ("code_list"); |
|
33 create table "city" ( |
|
34 "name" varchar(100) not null, |
|
35 "id" bigint primary key not null, |
|
36 "country_id" bigint not null, |
|
37 "note" varchar(10240) |
|
38 ); |
|
39 create sequence "s_city_id"; |
|
40 create table "address" ( |
|
41 "id" bigint primary key not null, |
|
42 "city_id" bigint not null, |
|
43 "zip_code" varchar(100) not null, |
|
44 "street_name" varchar(100) not null, |
|
45 "street_num" varchar(100) not null |
|
46 ); |
|
47 create sequence "s_address_id"; |
|
48 create table "country" ( |
|
49 "iso3" varchar(3) not null, |
|
50 "name" varchar(100) not null, |
|
51 "id" bigint primary key not null, |
|
52 "iso2" varchar(2) not null, |
|
53 "note" varchar(10240) |
|
54 ); |
|
55 create sequence "s_country_id"; |
|
56 create table "contact" ( |
|
57 "name" varchar(100) not null, |
|
58 "id" bigint primary key not null, |
|
59 "work_mobile" varchar(40) not null, |
|
60 "private_mail" varchar(256), |
|
61 "last_name" varchar(80) not null, |
|
62 "work_mail" varchar(256) not null, |
|
63 "first_name" varchar(80) not null, |
|
64 "fax" varchar(40), |
|
65 "note" varchar(10240), |
|
66 "other_mail" varchar(256), |
|
67 "position" varchar(40), |
|
68 "other_mobile" varchar(40), |
|
69 "private_mobile" varchar(40), |
|
70 "private_phone" varchar(40), |
|
71 "work_phone" varchar(40) |
|
72 ); |
|
73 create sequence "contact_id_seq"; |
|
74 create table "company" ( |
|
75 "name" varchar(100) not null, |
|
76 "id" bigint primary key not null, |
|
77 "partner" integer not null, |
|
78 "ico" varchar(40) not null, |
|
79 "note" varchar(10240), |
|
80 "corresp_address_id" bigint, |
|
81 "pin" integer not null, |
|
82 "address_id" bigint not null |
|
83 ); |
|
84 create sequence "s_company_id"; |
|
85 create table "bank_account" ( |
|
86 "number" bigint not null, |
|
87 "id" bigint primary key not null, |
|
88 "prefix" bigint not null, |
|
89 "bank_code" varchar(100) not null, |
|
90 "company_id" bigint not null |
|
91 ); |
|
92 create sequence "s_bank_account_id"; |
|
93 -- foreign key constraints : |
|
94 alter table "address" add constraint "addressFK1" foreign key ("city_id") references "city"("id"); |
|
95 alter table "city" add constraint "cityFK2" foreign key ("country_id") references "country"("id"); |
|
96 alter table "company" add constraint "companyFK3" foreign key ("address_id") references "address"("id"); |
|
97 alter table "company" add constraint "companyFK4" foreign key ("corresp_address_id") references "address"("id"); |
|
98 alter table "bank_account" add constraint "bank_accountFK5" foreign key ("company_id") references "company"("id"); |