-
-
Save netslow/28ddf67ffc8fb776b109ab13207c4d94 to your computer and use it in GitHub Desktop.
Forks and spoons DDL and data
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE public.items ( | |
item_id int4 NOT NULL, | |
"name" varchar(200) NOT NULL, | |
description varchar(1000) NULL, | |
CONSTRAINT items_pk PRIMARY KEY (item_id) | |
); | |
CREATE TABLE public.items_sales ( | |
item_id int4 NOT NULL, | |
country varchar(100) NOT NULL, | |
"day" int2 NOT NULL, | |
amount int4 NULL, | |
CONSTRAINT items_stat_pk PRIMARY KEY (item_id, country, day), | |
CONSTRAINT items_stat_fk FOREIGN KEY (item_id) REFERENCES items(item_id) ON UPDATE CASCADE ON DELETE CASCADE | |
); | |
INSERT INTO public.items (item_id,"name",description) VALUES | |
(1,'fork',NULL), | |
(2,'spoon',NULL); | |
INSERT INTO public.items_sales (item_id,country,"day",amount) VALUES | |
(1,'Italy',1,10), | |
(1,'Italy',4,2), | |
(1,'Italy',17,14), | |
(1,'France',5,10), | |
(1,'France',1,14), | |
(2,'Italy',1,11), | |
(2,'Italy',4,9), | |
(2,'Italy',27,18), | |
(2,'France',10,23), | |
(2,'France',8,17); | |
INSERT INTO public.items_sales (item_id,country,"day",amount) VALUES | |
(2,'France',1,7), | |
(2,'France',23,11), | |
(1,'France',10,37); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment