forked from softcon17/getting-started
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate_the_tables.sql
30 lines (28 loc) · 1.1 KB
/
create_the_tables.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
CREATE TABLE public.machines
(
id uuid NOT NULL,
name text COLLATE pg_catalog."default" NOT NULL,
status text COLLATE pg_catalog."default" NOT NULL,
location text COLLATE pg_catalog."default" NOT NULL,
CONSTRAINT machines_pk PRIMARY KEY (id)
)
WITH (OIDS = FALSE)
TABLESPACE pg_default;
ALTER TABLE public.machines OWNER to postgres;
COMMENT ON TABLE public.machines IS 'Table is used to store information about manufacturing equiptment that can be used to produce products';
CREATE TABLE public.bookings
(
machine_id uuid NOT NULL,
job_id text COLLATE pg_catalog."default" NOT NULL,
date date NOT NULL,
timeslot numeric NOT NULL,
CONSTRAINT bookings_ck PRIMARY KEY (timeslot, date, machine_id),
CONSTRAINT booking_fk FOREIGN KEY (machine_id)
REFERENCES public.machines (id) MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION
)
WITH (OIDS = FALSE)
TABLESPACE pg_default;
ALTER TABLE public.bookings OWNER to postgres;
COMMENT ON TABLE public.bookings IS 'This tables stores jobs that are booked onto machines for processing';