-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdbScript.txt
78 lines (60 loc) · 1.64 KB
/
dbScript.txt
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
--usuario insertado para facilitar utilización
--username: 'admin' password: 'admin'
CREATE DATABASE "EP2"
WITH
OWNER = postgres
ENCODING = 'UTF8'
LC_COLLATE = 'English_United States.1252'
LC_CTYPE = 'English_United States.1252'
TABLESPACE = pg_default
CONNECTION LIMIT = -1;
CREATE TABLE public.appuser
(
idUser serial primary key,
fullname character varying(50) not null,
username character varying(50) not null unique,
password character varying(50) not null,
userType bool not null
)
TABLESPACE pg_default;
ALTER TABLE public.appuser
OWNER to postgres;
CREATE TABLE public.address
(
idAddress serial primary key,
idUser int references appuser(idUser),
address character varying(50) not null
)
TABLESPACE pg_default;
ALTER TABLE public.address
OWNER to postgres;
CREATE TABLE public.business
(
idBusiness serial primary key,
name character varying(50) not null,
description character varying(100) not null
)
TABLESPACE pg_default;
ALTER TABLE public.business
OWNER to postgres;
CREATE TABLE public.product
(
idProduct serial primary key,
idBusiness int references business(idBusiness),
name character varying(50) not null
)
TABLESPACE pg_default;
ALTER TABLE public.product
OWNER to postgres;
CREATE TABLE public.apporder
(
idOrder serial primary key,
createDate date not null,
idProduct int references product(idProduct),
idAddress int references address(idAddress)
)
TABLESPACE pg_default;
ALTER TABLE public.apporder
OWNER to postgres;
INSERT INTO appuser (username, password, usertype, fullname)
VALUES ('admin', '21232f297a57a5a743894a0e4a801fc3', true, 'admin');