-
Notifications
You must be signed in to change notification settings - Fork 3
/
postgresql_test.sql
155 lines (103 loc) · 3.38 KB
/
postgresql_test.sql
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
--
-- PostgreSQL database dump
--
-- Dumped from database version 14.1
-- Dumped by pg_dump version 14.1
SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SELECT pg_catalog.set_config('search_path', '', false);
SET check_function_bodies = false;
SET xmloption = content;
SET client_min_messages = warning;
SET row_security = off;
--
-- Name: test; Type: SCHEMA; Schema: -; Owner: test
--
CREATE SCHEMA test;
ALTER SCHEMA test OWNER TO test;
SET default_tablespace = '';
SET default_table_access_method = heap;
--
-- Name: address; Type: TABLE; Schema: test; Owner: test
--
CREATE TABLE test.address (
pk_address_id integer NOT NULL,
street character varying(80),
house_no character varying(10),
city character varying(80),
state_province character varying(80),
postal_code character varying(20),
country character varying(80)
);
ALTER TABLE test.address OWNER TO test;
--
-- Name: TABLE address; Type: COMMENT; Schema: test; Owner: test
--
COMMENT ON TABLE test.address IS 'Address table. Many persons may have the same address.';
--
-- Name: COLUMN address.pk_address_id; Type: COMMENT; Schema: test; Owner: test
--
COMMENT ON COLUMN test.address.pk_address_id IS 'Primary Key of address';
--
-- Name: COLUMN address.street; Type: COMMENT; Schema: test; Owner: test
--
COMMENT ON COLUMN test.address.street IS 'Street part of an address, if applicable';
--
-- Name: person; Type: TABLE; Schema: test; Owner: test
--
CREATE TABLE test.person (
pk_person_id integer NOT NULL,
first_name character varying(80) NOT NULL,
last_name character varying(80) NOT NULL,
date_of_birth date NOT NULL
);
ALTER TABLE test.person OWNER TO test;
--
-- Name: person_address; Type: TABLE; Schema: test; Owner: test
--
CREATE TABLE test.person_address (
fk_adress_id integer,
fk_person_id integer
);
ALTER TABLE test.person_address OWNER TO test;
--
-- Data for Name: address; Type: TABLE DATA; Schema: test; Owner: test
--
COPY test.address (pk_address_id, street, house_no, city, state_province, postal_code, country) FROM stdin;
\.
--
-- Data for Name: person; Type: TABLE DATA; Schema: test; Owner: test
--
COPY test.person (pk_person_id, first_name, last_name, date_of_birth) FROM stdin;
\.
--
-- Data for Name: person_address; Type: TABLE DATA; Schema: test; Owner: test
--
COPY test.person_address (fk_adress_id, fk_person_id) FROM stdin;
\.
--
-- Name: address address_pkey; Type: CONSTRAINT; Schema: test; Owner: test
--
ALTER TABLE ONLY test.address
ADD CONSTRAINT address_pkey PRIMARY KEY (pk_address_id);
--
-- Name: person person_pkey; Type: CONSTRAINT; Schema: test; Owner: test
--
ALTER TABLE ONLY test.person
ADD CONSTRAINT person_pkey PRIMARY KEY (pk_person_id);
--
-- Name: person_address person_address_fk_adress_id_fkey; Type: FK CONSTRAINT; Schema: test; Owner: test
--
ALTER TABLE ONLY test.person_address
ADD CONSTRAINT person_address_fk_adress_id_fkey FOREIGN KEY (fk_adress_id) REFERENCES test.address(pk_address_id);
--
-- Name: person_address person_address_fk_person_id_fkey; Type: FK CONSTRAINT; Schema: test; Owner: test
--
ALTER TABLE ONLY test.person_address
ADD CONSTRAINT person_address_fk_person_id_fkey FOREIGN KEY (fk_person_id) REFERENCES test.person(pk_person_id);
--
-- PostgreSQL database dump complete
--