pivot_forecast/setup_sql/schema.sql

38 lines
1.7 KiB
MySQL
Raw Normal View History

--assumes schema fc already exists
2020-12-08 01:30:02 -05:00
--DROP TABLE IF EXISTS fc.target_meta;
CREATE TABLE IF NOT EXISTS fc.target_meta (
tname text
,cname text
,opos int
,func text
,fkey text
,pretty text
,dtype text
,mastcol text
,appcol text
,dateref text
);
--ALTER TABLE fc.target_meta DROP CONSTRAINT IF EXISTS target_meta_pk;
2020-12-08 01:30:02 -05:00
ALTER TABLE fc.target_meta ADD CONSTRAINT IF NOT EXISTS target_meta_pk PRIMARY KEY (tname, cname);
COMMENT ON TABLE fc.target_meta IS 'target table layout info';
COMMENT ON COLUMN fc.target_meta.tname IS 'schema.table_name of target sales data table';
COMMENT ON COLUMN fc.target_meta.cname IS 'column name';
COMMENT ON COLUMN fc.target_meta.opos IS 'ordinal position of column';
COMMENT ON COLUMN fc.target_meta.func IS 'a functional entity (like customer, part number) that master tables will be build from';
COMMENT ON COLUMN fc.target_meta.fkey IS 'primary key for functional entity';
COMMENT ON COLUMN fc.target_meta.pretty IS 'the presentation name of the column';
COMMENT ON COLUMN fc.target_meta.dtype IS 'data type of the sales table column';
COMMENT ON COLUMN fc.target_meta.mastcol IS 'associated field from the master data table if it is different (oseas would refer to ssyr in fc.perd)';
COMMENT ON COLUMN fc.target_meta.appcol IS 'supply column name to be used for application variables - (specifcy the order date column)';
COMMENT ON COLUMN fc.target_meta.dateref IS 'reference to the relevant hard coded perd table column for dates';
2020-12-08 01:30:02 -05:00
CREATE TABLE IF NOT EXISTS fc.log (
id int GENERATED ALWAYS AS IDENTITY
,doc jsonb
);
COMMENT ON TABLE fc.log IS 'forecast change log';