forked from s26450/hurtownia
64 lines
1.6 KiB
MySQL
64 lines
1.6 KiB
MySQL
|
DROP TABLE IF EXISTS dim_factories;
|
||
|
CREATE TABLE dim_factories (
|
||
|
factory_sk INTEGER identity(1,1) PRIMARY KEY,
|
||
|
factory_bk NVARCHAR(100) NOT NULL,
|
||
|
factory_name NVARCHAR(250),
|
||
|
factory_country NVARCHAR(250)
|
||
|
);
|
||
|
GO
|
||
|
|
||
|
DROP TABLE IF EXISTS dim_time;
|
||
|
CREATE TABLE dim_time (
|
||
|
time_sk INTEGER identity(1,1) PRIMARY KEY,
|
||
|
time_bk DATE NOT NULL,
|
||
|
time_string NCHAR(10) NOT NULL,
|
||
|
year INTEGER,
|
||
|
month INTEGER,
|
||
|
day INTEGER,
|
||
|
quarter INTEGER
|
||
|
);
|
||
|
GO
|
||
|
|
||
|
DROP TABLE IF EXISTS dim_drugs;
|
||
|
CREATE TABLE dim_drugs (
|
||
|
drug_sk INTEGER identity(1, 1) PRIMARY KEY,
|
||
|
DrugProductId INTEGER NOT NULL, -- business key
|
||
|
RecordStatus CHAR(1), -- A for active, D for deactivated
|
||
|
DrugProductName NVARCHAR(250),
|
||
|
RONumber NVARCHAR(20),
|
||
|
DrugProductFamilyId INTEGER,
|
||
|
DrugProductFamilyName NVARCHAR(250)
|
||
|
);
|
||
|
GO
|
||
|
|
||
|
DROP TABLE IF EXISTS dim_countries;
|
||
|
CREATE TABLE dim_countries (
|
||
|
country_sk INTEGER identity(1, 1) PRIMARY KEY,
|
||
|
country_code NVARCHAR(2), -- business key
|
||
|
country_name NVARCHAR(250)
|
||
|
);
|
||
|
|
||
|
DROP TABLE IF EXISTS dim_claim_statuses;
|
||
|
CREATE TABLE dim_claim_statuses (
|
||
|
status_sk INTEGER identity(1, 1) PRIMARY KEY,
|
||
|
status_code VARCHAR(1) NOT NULL, -- A for Accepted, D for Declined, W for Waiting
|
||
|
status_description NVARCHAR(50)
|
||
|
);
|
||
|
GO
|
||
|
|
||
|
-- insert statuses
|
||
|
INSERT INTO dim_claim_statuses(status_code, status_description)
|
||
|
VALUES
|
||
|
('A', 'Accepted'),
|
||
|
('D', 'Declined'),
|
||
|
('W', 'Waiting');
|
||
|
GO
|
||
|
|
||
|
DROP TABLE IF EXISTS dim_indications;
|
||
|
CREATE TABLE dim_indications (
|
||
|
indication_sk INTEGER identity(1, 1) PRIMARY KEY,
|
||
|
IndicationId INTEGER NOT NULL,
|
||
|
RecordStatus CHAR(1),
|
||
|
IndicationDescription NVARCHAR(500)
|
||
|
);
|
||
|
GO
|