Databázové schéma – jedna z prvních verzí
authorFrantišek Kučera <franta-hg@frantovo.cz>
Tue Apr 28 21:45:30 2009 +0200 (2009-04-28)
changeset 0dadbf814a612
child 1 616aeab8d3c0
Databázové schéma – jedna z prvních verzí
sql/schéma.sql
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/sql/schéma.sql	Tue Apr 28 21:45:30 2009 +0200
     1.3 @@ -0,0 +1,562 @@
     1.4 +--
     1.5 +-- PostgreSQL database dump
     1.6 +--
     1.7 +
     1.8 +-- Started on 2009-04-28 21:06:29 CEST
     1.9 +
    1.10 +SET client_encoding = 'UTF8';
    1.11 +SET standard_conforming_strings = off;
    1.12 +SET check_function_bodies = false;
    1.13 +SET client_min_messages = warning;
    1.14 +SET escape_string_warning = off;
    1.15 +
    1.16 +--
    1.17 +-- TOC entry 6 (class 2615 OID 16386)
    1.18 +-- Name: miniobchod; Type: SCHEMA; Schema: -; Owner: miniobchod
    1.19 +--
    1.20 +
    1.21 +CREATE SCHEMA miniobchod;
    1.22 +
    1.23 +
    1.24 +ALTER SCHEMA miniobchod OWNER TO miniobchod;
    1.25 +
    1.26 +SET search_path = miniobchod, pg_catalog;
    1.27 +
    1.28 +--
    1.29 +-- TOC entry 332 (class 1247 OID 16398)
    1.30 +-- Dependencies: 333 6
    1.31 +-- Name: email; Type: DOMAIN; Schema: miniobchod; Owner: miniobchod
    1.32 +--
    1.33 +
    1.34 +CREATE DOMAIN email AS character varying(255) NOT NULL
    1.35 +	CONSTRAINT email_regexp CHECK (((VALUE)::text ~ '^[_a-zA-Z0-9\\.\\-]+@[_a-zA-Z0-9\\.\\-]+\\.[a-zA-Z]{2,4}$'::text));
    1.36 +
    1.37 +
    1.38 +ALTER DOMAIN miniobchod.email OWNER TO miniobchod;
    1.39 +
    1.40 +--
    1.41 +-- TOC entry 1821 (class 0 OID 0)
    1.42 +-- Dependencies: 332
    1.43 +-- Name: DOMAIN email; Type: COMMENT; Schema: miniobchod; Owner: miniobchod
    1.44 +--
    1.45 +
    1.46 +COMMENT ON DOMAIN email IS 'e-mailová adresa';
    1.47 +
    1.48 +
    1.49 +--
    1.50 +-- TOC entry 344 (class 1247 OID 16566)
    1.51 +-- Dependencies: 345 6
    1.52 +-- Name: psc; Type: DOMAIN; Schema: miniobchod; Owner: miniobchod
    1.53 +--
    1.54 +
    1.55 +CREATE DOMAIN psc AS character varying(255) NOT NULL
    1.56 +	CONSTRAINT psc_regexp CHECK (((VALUE)::text ~ '^\\d{3} ?\\d{2}$'::text));
    1.57 +
    1.58 +
    1.59 +ALTER DOMAIN miniobchod.psc OWNER TO miniobchod;
    1.60 +
    1.61 +--
    1.62 +-- TOC entry 1822 (class 0 OID 0)
    1.63 +-- Dependencies: 344
    1.64 +-- Name: DOMAIN psc; Type: COMMENT; Schema: miniobchod; Owner: miniobchod
    1.65 +--
    1.66 +
    1.67 +COMMENT ON DOMAIN psc IS 'Poštovní směrovací číslo';
    1.68 +
    1.69 +
    1.70 +--
    1.71 +-- TOC entry 55 (class 1255 OID 16459)
    1.72 +-- Dependencies: 6
    1.73 +-- Name: nahodne_heslo(); Type: FUNCTION; Schema: miniobchod; Owner: miniobchod
    1.74 +--
    1.75 +
    1.76 +CREATE FUNCTION nahodne_heslo() RETURNS character
    1.77 +    AS $$select sha512(random()::text || random()::text || random()::text);$$
    1.78 +    LANGUAGE sql;
    1.79 +
    1.80 +
    1.81 +ALTER FUNCTION miniobchod.nahodne_heslo() OWNER TO miniobchod;
    1.82 +
    1.83 +--
    1.84 +-- TOC entry 56 (class 1255 OID 16460)
    1.85 +-- Dependencies: 6
    1.86 +-- Name: sha1(text); Type: FUNCTION; Schema: miniobchod; Owner: miniobchod
    1.87 +--
    1.88 +
    1.89 +CREATE FUNCTION sha1(text) RETURNS text
    1.90 +    AS $_$
    1.91 +SELECT encode(digest(decode($1,'escape'::text),'sha1'::text),'hex');
    1.92 +$_$
    1.93 +    LANGUAGE sql IMMUTABLE STRICT;
    1.94 +
    1.95 +
    1.96 +ALTER FUNCTION miniobchod.sha1(text) OWNER TO miniobchod;
    1.97 +
    1.98 +--
    1.99 +-- TOC entry 57 (class 1255 OID 16461)
   1.100 +-- Dependencies: 6
   1.101 +-- Name: sha256(text); Type: FUNCTION; Schema: miniobchod; Owner: miniobchod
   1.102 +--
   1.103 +
   1.104 +CREATE FUNCTION sha256(text) RETURNS text
   1.105 +    AS $_$
   1.106 +SELECT encode(digest(decode($1,'escape'::text),'sha256'::text),'hex');
   1.107 +$_$
   1.108 +    LANGUAGE sql IMMUTABLE STRICT;
   1.109 +
   1.110 +
   1.111 +ALTER FUNCTION miniobchod.sha256(text) OWNER TO miniobchod;
   1.112 +
   1.113 +--
   1.114 +-- TOC entry 54 (class 1255 OID 16458)
   1.115 +-- Dependencies: 6
   1.116 +-- Name: sha512(text); Type: FUNCTION; Schema: miniobchod; Owner: miniobchod
   1.117 +--
   1.118 +
   1.119 +CREATE FUNCTION sha512(text) RETURNS text
   1.120 +    AS $_$
   1.121 +SELECT encode(digest(decode($1,'escape'::text),'sha512'::text),'hex');
   1.122 +$_$
   1.123 +    LANGUAGE sql IMMUTABLE STRICT;
   1.124 +
   1.125 +
   1.126 +ALTER FUNCTION miniobchod.sha512(text) OWNER TO miniobchod;
   1.127 +
   1.128 +--
   1.129 +-- TOC entry 58 (class 1255 OID 16608)
   1.130 +-- Dependencies: 350 6
   1.131 +-- Name: vyjimka(character varying); Type: FUNCTION; Schema: miniobchod; Owner: miniobchod
   1.132 +--
   1.133 +
   1.134 +CREATE FUNCTION vyjimka(chyba character varying) RETURNS void
   1.135 +    AS $$BEGIN
   1.136 +RAISE EXCEPTION '%', chyba;
   1.137 +END;$$
   1.138 +    LANGUAGE plpgsql;
   1.139 +
   1.140 +
   1.141 +ALTER FUNCTION miniobchod.vyjimka(chyba character varying) OWNER TO miniobchod;
   1.142 +
   1.143 +--
   1.144 +-- TOC entry 1823 (class 0 OID 0)
   1.145 +-- Dependencies: 58
   1.146 +-- Name: FUNCTION vyjimka(chyba character varying); Type: COMMENT; Schema: miniobchod; Owner: miniobchod
   1.147 +--
   1.148 +
   1.149 +COMMENT ON FUNCTION vyjimka(chyba character varying) IS 'Vyhodí výjimku';
   1.150 +
   1.151 +
   1.152 +--
   1.153 +-- TOC entry 1528 (class 1259 OID 16575)
   1.154 +-- Dependencies: 6
   1.155 +-- Name: adresa_seq; Type: SEQUENCE; Schema: miniobchod; Owner: miniobchod
   1.156 +--
   1.157 +
   1.158 +CREATE SEQUENCE adresa_seq
   1.159 +    INCREMENT BY 1
   1.160 +    NO MAXVALUE
   1.161 +    NO MINVALUE
   1.162 +    CACHE 1;
   1.163 +
   1.164 +
   1.165 +ALTER TABLE miniobchod.adresa_seq OWNER TO miniobchod;
   1.166 +
   1.167 +SET default_tablespace = '';
   1.168 +
   1.169 +SET default_with_oids = false;
   1.170 +
   1.171 +--
   1.172 +-- TOC entry 1529 (class 1259 OID 16578)
   1.173 +-- Dependencies: 1804 332 344 6
   1.174 +-- Name: adresa; Type: TABLE; Schema: miniobchod; Owner: miniobchod; Tablespace: 
   1.175 +--
   1.176 +
   1.177 +CREATE TABLE adresa (
   1.178 +    id bigint DEFAULT nextval('adresa_seq'::regclass) NOT NULL,
   1.179 +    uzivatel email,
   1.180 +    jmeno character varying(255),
   1.181 +    ulice character varying(255),
   1.182 +    cp smallint,
   1.183 +    mesto character varying(255),
   1.184 +    psc psc
   1.185 +);
   1.186 +
   1.187 +
   1.188 +ALTER TABLE miniobchod.adresa OWNER TO miniobchod;
   1.189 +
   1.190 +--
   1.191 +-- TOC entry 1824 (class 0 OID 0)
   1.192 +-- Dependencies: 1529
   1.193 +-- Name: TABLE adresa; Type: COMMENT; Schema: miniobchod; Owner: miniobchod
   1.194 +--
   1.195 +
   1.196 +COMMENT ON TABLE adresa IS 'Poštovní adresa';
   1.197 +
   1.198 +
   1.199 +--
   1.200 +-- TOC entry 1825 (class 0 OID 0)
   1.201 +-- Dependencies: 1529
   1.202 +-- Name: COLUMN adresa.jmeno; Type: COMMENT; Schema: miniobchod; Owner: miniobchod
   1.203 +--
   1.204 +
   1.205 +COMMENT ON COLUMN adresa.jmeno IS 'Jméno příjemce';
   1.206 +
   1.207 +
   1.208 +--
   1.209 +-- TOC entry 1826 (class 0 OID 0)
   1.210 +-- Dependencies: 1529
   1.211 +-- Name: COLUMN adresa.cp; Type: COMMENT; Schema: miniobchod; Owner: miniobchod
   1.212 +--
   1.213 +
   1.214 +COMMENT ON COLUMN adresa.cp IS 'Číslo popisné';
   1.215 +
   1.216 +
   1.217 +--
   1.218 +-- TOC entry 1827 (class 0 OID 0)
   1.219 +-- Dependencies: 1529
   1.220 +-- Name: COLUMN adresa.psc; Type: COMMENT; Schema: miniobchod; Owner: miniobchod
   1.221 +--
   1.222 +
   1.223 +COMMENT ON COLUMN adresa.psc IS 'Poštovní směrovací číslo';
   1.224 +
   1.225 +
   1.226 +--
   1.227 +-- TOC entry 1527 (class 1259 OID 16540)
   1.228 +-- Dependencies: 1803 6
   1.229 +-- Name: objednane_zbozi; Type: TABLE; Schema: miniobchod; Owner: miniobchod; Tablespace: 
   1.230 +--
   1.231 +
   1.232 +CREATE TABLE objednane_zbozi (
   1.233 +    objednavka bigint NOT NULL,
   1.234 +    zbozi bit varying NOT NULL,
   1.235 +    mnozstvi smallint DEFAULT 1 NOT NULL
   1.236 +);
   1.237 +
   1.238 +
   1.239 +ALTER TABLE miniobchod.objednane_zbozi OWNER TO miniobchod;
   1.240 +
   1.241 +--
   1.242 +-- TOC entry 1828 (class 0 OID 0)
   1.243 +-- Dependencies: 1527
   1.244 +-- Name: TABLE objednane_zbozi; Type: COMMENT; Schema: miniobchod; Owner: miniobchod
   1.245 +--
   1.246 +
   1.247 +COMMENT ON TABLE objednane_zbozi IS 'Vazební tabulka, která definuje obsah objednávky – objednané zboží';
   1.248 +
   1.249 +
   1.250 +--
   1.251 +-- TOC entry 1525 (class 1259 OID 16408)
   1.252 +-- Dependencies: 6
   1.253 +-- Name: objednavka_seq; Type: SEQUENCE; Schema: miniobchod; Owner: miniobchod
   1.254 +--
   1.255 +
   1.256 +CREATE SEQUENCE objednavka_seq
   1.257 +    INCREMENT BY 1
   1.258 +    NO MAXVALUE
   1.259 +    NO MINVALUE
   1.260 +    CACHE 1;
   1.261 +
   1.262 +
   1.263 +ALTER TABLE miniobchod.objednavka_seq OWNER TO miniobchod;
   1.264 +
   1.265 +--
   1.266 +-- TOC entry 1526 (class 1259 OID 16410)
   1.267 +-- Dependencies: 1800 1801 1802 6 332
   1.268 +-- Name: objednavka; Type: TABLE; Schema: miniobchod; Owner: miniobchod; Tablespace: 
   1.269 +--
   1.270 +
   1.271 +CREATE TABLE objednavka (
   1.272 +    id bigint DEFAULT nextval('objednavka_seq'::regclass) NOT NULL,
   1.273 +    kod character varying DEFAULT nahodne_heslo() NOT NULL,
   1.274 +    uzivatel email,
   1.275 +    podano timestamp with time zone DEFAULT now() NOT NULL,
   1.276 +    adresa bigint
   1.277 +);
   1.278 +
   1.279 +
   1.280 +ALTER TABLE miniobchod.objednavka OWNER TO miniobchod;
   1.281 +
   1.282 +--
   1.283 +-- TOC entry 1829 (class 0 OID 0)
   1.284 +-- Dependencies: 1526
   1.285 +-- Name: TABLE objednavka; Type: COMMENT; Schema: miniobchod; Owner: miniobchod
   1.286 +--
   1.287 +
   1.288 +COMMENT ON TABLE objednavka IS 'Objednávka zboží';
   1.289 +
   1.290 +
   1.291 +--
   1.292 +-- TOC entry 1830 (class 0 OID 0)
   1.293 +-- Dependencies: 1526
   1.294 +-- Name: COLUMN objednavka.id; Type: COMMENT; Schema: miniobchod; Owner: miniobchod
   1.295 +--
   1.296 +
   1.297 +COMMENT ON COLUMN objednavka.id IS 'Číslo objednávky je zároveň variabilním symbolem';
   1.298 +
   1.299 +
   1.300 +--
   1.301 +-- TOC entry 1831 (class 0 OID 0)
   1.302 +-- Dependencies: 1526
   1.303 +-- Name: COLUMN objednavka.kod; Type: COMMENT; Schema: miniobchod; Owner: miniobchod
   1.304 +--
   1.305 +
   1.306 +COMMENT ON COLUMN objednavka.kod IS 'Potvrzovací kód – pošle se zákazníkovi e-mailem a ten pomocí něj objednávku potvrdí.';
   1.307 +
   1.308 +
   1.309 +--
   1.310 +-- TOC entry 1832 (class 0 OID 0)
   1.311 +-- Dependencies: 1526
   1.312 +-- Name: COLUMN objednavka.uzivatel; Type: COMMENT; Schema: miniobchod; Owner: miniobchod
   1.313 +--
   1.314 +
   1.315 +COMMENT ON COLUMN objednavka.uzivatel IS 'Kdo si objednal';
   1.316 +
   1.317 +
   1.318 +--
   1.319 +-- TOC entry 1833 (class 0 OID 0)
   1.320 +-- Dependencies: 1526
   1.321 +-- Name: COLUMN objednavka.podano; Type: COMMENT; Schema: miniobchod; Owner: miniobchod
   1.322 +--
   1.323 +
   1.324 +COMMENT ON COLUMN objednavka.podano IS 'Datum a čas podání objednávky';
   1.325 +
   1.326 +
   1.327 +--
   1.328 +-- TOC entry 1834 (class 0 OID 0)
   1.329 +-- Dependencies: 1526
   1.330 +-- Name: COLUMN objednavka.adresa; Type: COMMENT; Schema: miniobchod; Owner: miniobchod
   1.331 +--
   1.332 +
   1.333 +COMMENT ON COLUMN objednavka.adresa IS 'Kam se má objednávka doručit';
   1.334 +
   1.335 +
   1.336 +--
   1.337 +-- TOC entry 1524 (class 1259 OID 16400)
   1.338 +-- Dependencies: 1798 1799 6 332
   1.339 +-- Name: uzivatel; Type: TABLE; Schema: miniobchod; Owner: miniobchod; Tablespace: 
   1.340 +--
   1.341 +
   1.342 +CREATE TABLE uzivatel (
   1.343 +    email email NOT NULL,
   1.344 +    heslo character varying DEFAULT nahodne_heslo() NOT NULL,
   1.345 +    zalozen timestamp with time zone DEFAULT now()
   1.346 +);
   1.347 +
   1.348 +
   1.349 +ALTER TABLE miniobchod.uzivatel OWNER TO miniobchod;
   1.350 +
   1.351 +--
   1.352 +-- TOC entry 1835 (class 0 OID 0)
   1.353 +-- Dependencies: 1524
   1.354 +-- Name: TABLE uzivatel; Type: COMMENT; Schema: miniobchod; Owner: miniobchod
   1.355 +--
   1.356 +
   1.357 +COMMENT ON TABLE uzivatel IS 'Zákazník';
   1.358 +
   1.359 +
   1.360 +--
   1.361 +-- TOC entry 1836 (class 0 OID 0)
   1.362 +-- Dependencies: 1524
   1.363 +-- Name: COLUMN uzivatel.email; Type: COMMENT; Schema: miniobchod; Owner: miniobchod
   1.364 +--
   1.365 +
   1.366 +COMMENT ON COLUMN uzivatel.email IS 'Uživatel je identifikovaný pomocí své e-mailové adresy';
   1.367 +
   1.368 +
   1.369 +--
   1.370 +-- TOC entry 1837 (class 0 OID 0)
   1.371 +-- Dependencies: 1524
   1.372 +-- Name: COLUMN uzivatel.heslo; Type: COMMENT; Schema: miniobchod; Owner: miniobchod
   1.373 +--
   1.374 +
   1.375 +COMMENT ON COLUMN uzivatel.heslo IS 'Vygenerované heslo, kterým se uživatel prokazuje (pošle se mu na e-mail)';
   1.376 +
   1.377 +
   1.378 +--
   1.379 +-- TOC entry 1838 (class 0 OID 0)
   1.380 +-- Dependencies: 1524
   1.381 +-- Name: COLUMN uzivatel.zalozen; Type: COMMENT; Schema: miniobchod; Owner: miniobchod
   1.382 +--
   1.383 +
   1.384 +COMMENT ON COLUMN uzivatel.zalozen IS 'Datum a čas registrace zákazníka';
   1.385 +
   1.386 +
   1.387 +--
   1.388 +-- TOC entry 1522 (class 1259 OID 16387)
   1.389 +-- Dependencies: 6
   1.390 +-- Name: zbozi_seq; Type: SEQUENCE; Schema: miniobchod; Owner: miniobchod
   1.391 +--
   1.392 +
   1.393 +CREATE SEQUENCE zbozi_seq
   1.394 +    INCREMENT BY 1
   1.395 +    NO MAXVALUE
   1.396 +    NO MINVALUE
   1.397 +    CACHE 1;
   1.398 +
   1.399 +
   1.400 +ALTER TABLE miniobchod.zbozi_seq OWNER TO miniobchod;
   1.401 +
   1.402 +--
   1.403 +-- TOC entry 1523 (class 1259 OID 16389)
   1.404 +-- Dependencies: 1797 6
   1.405 +-- Name: zbozi; Type: TABLE; Schema: miniobchod; Owner: miniobchod; Tablespace: 
   1.406 +--
   1.407 +
   1.408 +CREATE TABLE zbozi (
   1.409 +    id bigint DEFAULT nextval('zbozi_seq'::regclass) NOT NULL,
   1.410 +    nazev character varying(255),
   1.411 +    popis text
   1.412 +);
   1.413 +
   1.414 +
   1.415 +ALTER TABLE miniobchod.zbozi OWNER TO miniobchod;
   1.416 +
   1.417 +--
   1.418 +-- TOC entry 1839 (class 0 OID 0)
   1.419 +-- Dependencies: 1523
   1.420 +-- Name: TABLE zbozi; Type: COMMENT; Schema: miniobchod; Owner: miniobchod
   1.421 +--
   1.422 +
   1.423 +COMMENT ON TABLE zbozi IS 'Položka katalogu';
   1.424 +
   1.425 +
   1.426 +--
   1.427 +-- TOC entry 1840 (class 0 OID 0)
   1.428 +-- Dependencies: 1523
   1.429 +-- Name: COLUMN zbozi.id; Type: COMMENT; Schema: miniobchod; Owner: miniobchod
   1.430 +--
   1.431 +
   1.432 +COMMENT ON COLUMN zbozi.id IS 'Číslo zboží';
   1.433 +
   1.434 +
   1.435 +--
   1.436 +-- TOC entry 1841 (class 0 OID 0)
   1.437 +-- Dependencies: 1523
   1.438 +-- Name: COLUMN zbozi.nazev; Type: COMMENT; Schema: miniobchod; Owner: miniobchod
   1.439 +--
   1.440 +
   1.441 +COMMENT ON COLUMN zbozi.nazev IS 'Název zboží';
   1.442 +
   1.443 +
   1.444 +--
   1.445 +-- TOC entry 1842 (class 0 OID 0)
   1.446 +-- Dependencies: 1523
   1.447 +-- Name: COLUMN zbozi.popis; Type: COMMENT; Schema: miniobchod; Owner: miniobchod
   1.448 +--
   1.449 +
   1.450 +COMMENT ON COLUMN zbozi.popis IS 'Popis zboží';
   1.451 +
   1.452 +
   1.453 +--
   1.454 +-- TOC entry 1815 (class 2606 OID 16586)
   1.455 +-- Dependencies: 1529 1529
   1.456 +-- Name: adresa_pk; Type: CONSTRAINT; Schema: miniobchod; Owner: miniobchod; Tablespace: 
   1.457 +--
   1.458 +
   1.459 +ALTER TABLE ONLY adresa
   1.460 +    ADD CONSTRAINT adresa_pk PRIMARY KEY (id);
   1.461 +
   1.462 +
   1.463 +--
   1.464 +-- TOC entry 1813 (class 2606 OID 16548)
   1.465 +-- Dependencies: 1527 1527 1527
   1.466 +-- Name: objednane_zbozi_pk; Type: CONSTRAINT; Schema: miniobchod; Owner: miniobchod; Tablespace: 
   1.467 +--
   1.468 +
   1.469 +ALTER TABLE ONLY objednane_zbozi
   1.470 +    ADD CONSTRAINT objednane_zbozi_pk PRIMARY KEY (objednavka, zbozi);
   1.471 +
   1.472 +
   1.473 +--
   1.474 +-- TOC entry 1811 (class 2606 OID 16415)
   1.475 +-- Dependencies: 1526 1526
   1.476 +-- Name: objednavka_pk; Type: CONSTRAINT; Schema: miniobchod; Owner: miniobchod; Tablespace: 
   1.477 +--
   1.478 +
   1.479 +ALTER TABLE ONLY objednavka
   1.480 +    ADD CONSTRAINT objednavka_pk PRIMARY KEY (id);
   1.481 +
   1.482 +
   1.483 +--
   1.484 +-- TOC entry 1808 (class 2606 OID 16407)
   1.485 +-- Dependencies: 1524 1524
   1.486 +-- Name: uzivatel_pk; Type: CONSTRAINT; Schema: miniobchod; Owner: miniobchod; Tablespace: 
   1.487 +--
   1.488 +
   1.489 +ALTER TABLE ONLY uzivatel
   1.490 +    ADD CONSTRAINT uzivatel_pk PRIMARY KEY (email);
   1.491 +
   1.492 +
   1.493 +--
   1.494 +-- TOC entry 1806 (class 2606 OID 16397)
   1.495 +-- Dependencies: 1523 1523
   1.496 +-- Name: zbozi_pk; Type: CONSTRAINT; Schema: miniobchod; Owner: miniobchod; Tablespace: 
   1.497 +--
   1.498 +
   1.499 +ALTER TABLE ONLY zbozi
   1.500 +    ADD CONSTRAINT zbozi_pk PRIMARY KEY (id);
   1.501 +
   1.502 +
   1.503 +--
   1.504 +-- TOC entry 1809 (class 1259 OID 16597)
   1.505 +-- Dependencies: 1526
   1.506 +-- Name: fki_objednavka_adresa_fk; Type: INDEX; Schema: miniobchod; Owner: miniobchod; Tablespace: 
   1.507 +--
   1.508 +
   1.509 +CREATE INDEX fki_objednavka_adresa_fk ON objednavka USING btree (adresa);
   1.510 +
   1.511 +
   1.512 +--
   1.513 +-- TOC entry 1605 (class 2618 OID 16598)
   1.514 +-- Dependencies: 1526 1529 1526 58 1526 1526 1526 1529
   1.515 +-- Name: objednavka_adresa_uzivatel; Type: RULE; Schema: miniobchod; Owner: miniobchod
   1.516 +--
   1.517 +
   1.518 +CREATE RULE objednavka_adresa_uzivatel AS ON INSERT TO objednavka WHERE ((new.uzivatel)::text <> ((SELECT adresa.uzivatel FROM adresa WHERE (adresa.id = new.adresa)))::text) DO SELECT vyjimka('Uživatel může objednat zboží jen na svoji adresu'::character varying) AS vyjimka;
   1.519 +
   1.520 +
   1.521 +--
   1.522 +-- TOC entry 1843 (class 0 OID 0)
   1.523 +-- Dependencies: 1605
   1.524 +-- Name: RULE objednavka_adresa_uzivatel ON objednavka; Type: COMMENT; Schema: miniobchod; Owner: miniobchod
   1.525 +--
   1.526 +
   1.527 +COMMENT ON RULE objednavka_adresa_uzivatel ON objednavka IS 'Uživatel může objednat zboží jen na svoji adresu';
   1.528 +
   1.529 +
   1.530 +--
   1.531 +-- TOC entry 1818 (class 2606 OID 16587)
   1.532 +-- Dependencies: 1807 1529 1524
   1.533 +-- Name: adresa_uzivatel_fk; Type: FK CONSTRAINT; Schema: miniobchod; Owner: miniobchod
   1.534 +--
   1.535 +
   1.536 +ALTER TABLE ONLY adresa
   1.537 +    ADD CONSTRAINT adresa_uzivatel_fk FOREIGN KEY (uzivatel) REFERENCES uzivatel(email);
   1.538 +
   1.539 +
   1.540 +--
   1.541 +-- TOC entry 1817 (class 2606 OID 16592)
   1.542 +-- Dependencies: 1814 1529 1526
   1.543 +-- Name: objednavka_adresa_fk; Type: FK CONSTRAINT; Schema: miniobchod; Owner: miniobchod
   1.544 +--
   1.545 +
   1.546 +ALTER TABLE ONLY objednavka
   1.547 +    ADD CONSTRAINT objednavka_adresa_fk FOREIGN KEY (adresa) REFERENCES adresa(id);
   1.548 +
   1.549 +
   1.550 +--
   1.551 +-- TOC entry 1816 (class 2606 OID 16493)
   1.552 +-- Dependencies: 1807 1524 1526
   1.553 +-- Name: objednavka_uzivatel_fk; Type: FK CONSTRAINT; Schema: miniobchod; Owner: miniobchod
   1.554 +--
   1.555 +
   1.556 +ALTER TABLE ONLY objednavka
   1.557 +    ADD CONSTRAINT objednavka_uzivatel_fk FOREIGN KEY (uzivatel) REFERENCES uzivatel(email);
   1.558 +
   1.559 +
   1.560 +-- Completed on 2009-04-28 21:06:38 CEST
   1.561 +
   1.562 +--
   1.563 +-- PostgreSQL database dump complete
   1.564 +--
   1.565 +