-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMendixDatabaseDDL.sql
More file actions
81 lines (55 loc) · 1.89 KB
/
Copy pathMendixDatabaseDDL.sql
File metadata and controls
81 lines (55 loc) · 1.89 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
70
71
72
73
74
75
76
77
78
79
80
81
-- mendix.ingredient definition
-- Drop table
-- DROP TABLE mendix.ingredient;
CREATE TABLE mendix.ingredient (
id bigserial NOT NULL,
ingredient_name varchar NOT NULL,
CONSTRAINT ingredient_pk PRIMARY KEY (id)
);
-- Permissions
ALTER TABLE mendix.ingredient OWNER TO postgres;
GRANT ALL ON TABLE mendix.ingredient TO postgres;
-- mendix.recipe definition
-- Drop table
-- DROP TABLE mendix.recipe;
CREATE TABLE mendix.recipe (
id bigserial NOT NULL,
recipe_name varchar NOT NULL,
directions varchar NULL,
yield numeric NULL,
CONSTRAINT recipe_name_un UNIQUE (recipe_name),
CONSTRAINT recipe_pk PRIMARY KEY (id)
);
-- Permissions
ALTER TABLE mendix.recipe OWNER TO postgres;
GRANT ALL ON TABLE mendix.recipe TO postgres;
-- mendix.category definition
-- Drop table
-- DROP TABLE mendix.category;
CREATE TABLE mendix.category (
id bigserial NOT NULL,
recipe_id int8 NOT NULL,
category_name varchar NOT NULL,
CONSTRAINT category_fk FOREIGN KEY (recipe_id) REFERENCES mendix.recipe(id)
);
COMMENT ON TABLE mendix.category IS 'Different category labels for recipes...';
-- Permissions
ALTER TABLE mendix.category OWNER TO postgres;
GRANT ALL ON TABLE mendix.category TO postgres;
-- mendix.recipe_ingredient definition
-- Drop table
-- DROP TABLE mendix.recipe_ingredient;
CREATE TABLE mendix.recipe_ingredient (
id bigserial NOT NULL,
recipe_id int8 NOT NULL,
ingredient_id int8 NOT NULL,
unit varchar NULL,
quantity varchar NULL,
decription varchar NULL,
CONSTRAINT recipe_ingredient_pk PRIMARY KEY (id),
CONSTRAINT recipe_ingredient_fk FOREIGN KEY (recipe_id) REFERENCES mendix.recipe(id) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT recipe_ingredient_fk_1 FOREIGN KEY (ingredient_id) REFERENCES mendix.ingredient(id) ON DELETE CASCADE ON UPDATE CASCADE
);
-- Permissions
ALTER TABLE mendix.recipe_ingredient OWNER TO postgres;
GRANT ALL ON TABLE mendix.recipe_ingredient TO postgres;