IF NOT EXISTS (
    select * from sysobjects where name='metaInRows' and xtype='U'
) CREATE TABLE metaInRows (
    code NVARCHAR(32) NOT NULL,
    attributeName NVARCHAR(32) NOT NULL,
    attributeValue NVARCHAR(64) NOT NULL
    PRIMARY KEY(code, attributeName)
);
GO

INSERT INTO metaInRows
VALUES (N'plccpi', N'Category', N'Prices'),
(N'plccpi', N'Description', N'Core CPI'),
(N'plccpi', N'Frequency', N'Monthly'),
(N'plccpi', N'Region', N'pl'),
(N'plcpi',  N'Category', N'Prices'),
(N'plcpi',  N'Description', N'Total CPI'),
(N'plcpi',  N'Frequency', N'Monthly'),
(N'plcpi',  N'Region', N'pl'),
(N'plgdp',  N'Category', N'GDP'),
(N'plgdp',  N'Class', N'Flow'),
(N'plgdp',  N'Description', N'Total GDP, PP=100'),
(N'plgdp',  N'Frequency', N'Quarterly'),
(N'plgdp',  N'Region', N'pl'),
(N'secpi',  N'Category', N'Prices'),
(N'secpi',  N'Description', N'Total CPI'),
(N'secpi',  N'Frequency', N'Monthly'),
(N'secpi',  N'Region', N'se'),
(N'secpif', N'Category', N'Prices'),
(N'secpif', N'Description', N'CPI at constant interest rates'),
(N'secpif', N'Frequency', N'Monthly'),
(N'secpif', N'Region', N'se'),
(N'segdp',  N'Category', N'GDP'),
(N'segdp',  N'Class', N'Flow'),
(N'segdp',  N'Description', N'Total GDP'),
(N'segdp',  N'Frequency', N'Quarterly'),
(N'segdp',  N'Region', N'se'),
(N'segdp',  N'Scale', N'6');
GO


IF NOT EXISTS (
    select * from sysobjects where name='obs' and xtype='U'
) CREATE TABLE obs (
    code NVARCHAR(32) NOT NULL,
    ts DATE NOT NULL,
    v FLOAT NOT NULL
    PRIMARY KEY(code, ts)
);
GO

INSERT INTO obs
VALUES (N'plccpi', '2015-01-01', 99.762),
    (N'plccpi', '2015-02-01', 99.85),
    (N'plccpi', '2015-03-01', 100.202),
    (N'plccpi', '2015-04-01', 100.445),
    (N'plccpi', '2015-05-01', 100),
    (N'plccpi', '2015-06-01', 100.049),
    (N'plccpi', '2015-07-01', 99.907),
    (N'plcpi', '2015-01-01', 169.2),
    (N'plcpi', '2015-02-01', 169),
    (N'plcpi', '2015-03-01', 169.3),
    (N'plcpi', '2015-04-01', 170),
    (N'plcpi', '2015-05-01', 170),
    (N'plcpi', '2015-06-01', 170),
    (N'plcpi', '2015-07-01', 169.8),
    (N'plgdp', '2015-01-01', 101),
    (N'plgdp', '2015-04-01', 100.9),
    (N'secpi', '2015-01-01', 310.75),
    (N'secpi', '2015-02-01', 312.93),
    (N'secpi', '2015-03-01', 313.19),
    (N'secpi', '2015-04-01', 313.16),
    (N'secpi', '2015-05-01', 314.24),
    (N'secpi', '2015-06-01', 313.33),
    (N'secpi', '2015-07-01', 313.43),
    (N'secpif', '2015-01-01', 200.87),
    (N'secpif', '2015-02-01', 202.48),
    (N'secpif', '2015-03-01', 202.74),
    (N'secpif', '2015-04-01', 203.06),
    (N'secpif', '2015-05-01', 203.95),
    (N'secpif', '2015-06-01', 203.52),
    (N'secpif', '2015-07-01', 203.81),
    (N'segdp', '2015-01-01', 9966),
    (N'segdp', '2015-04-01', 10063);
GO


