This commit is contained in:
Mariusz Sielski 2018-12-02 11:13:40 +01:00
parent f0db18d731
commit 6d72578228
2 changed files with 54 additions and 46 deletions

View File

@ -1,3 +1,6 @@
DROP TABLE IF EXISTS FT_Refund;
DROP TABLE IF EXISTS FT_Registration;
DROP TABLE IF EXISTS dim_factories; DROP TABLE IF EXISTS dim_factories;
CREATE TABLE dim_factories ( CREATE TABLE dim_factories (
factory_sk INTEGER identity(1,1) PRIMARY KEY, factory_sk INTEGER identity(1,1) PRIMARY KEY,
@ -54,6 +57,13 @@ VALUES
('W', 'Waiting'); ('W', 'Waiting');
GO GO
DROP TABLE IF EXISTS claim_status_mapping;
CREATE TABLE claim_status_mapping (
status_code_bk VARCHAR(1),
status_code_value VARCHAR(50)
);
GO
DROP TABLE IF EXISTS dim_indications; DROP TABLE IF EXISTS dim_indications;
CREATE TABLE dim_indications ( CREATE TABLE dim_indications (
indication_sk INTEGER identity(1, 1) PRIMARY KEY, indication_sk INTEGER identity(1, 1) PRIMARY KEY,
@ -68,37 +78,35 @@ GO
--IF OBJECT_ID('dbo.FT1_Registartion') IS NOT NULL DROP TABLE dbo.MyCategories; --IF OBJECT_ID('dbo.FT1_Registartion') IS NOT NULL DROP TABLE dbo.MyCategories;
DROP TABLE IF EXISTS FT1_Registration; CREATE TABLE FT_Registration (
CREATE TABLE FT1_Registration ( ft_registration_sk INTEGER identity(1,1) PRIMARY KEY,
id INTEGER identity(1,1) PRIMARY KEY, expected_response_time_fk integer FOREIGN KEY REFERENCES dim_time(time_sk) NOT NULL,
expected_response_time_fk integer FOREIGN KEY REFERENCES dim_time(time_sk), submission_date_fk integer FOREIGN KEY REFERENCES dim_time(time_sk) NOT NULL,
submission_date_fk integer FOREIGN KEY REFERENCES dim_time(time_sk), response_time_fk integer FOREIGN KEY REFERENCES dim_time(time_sk), -- moze byc null
response_time_fk integer FOREIGN KEY REFERENCES dim_time(time_sk), drug_fk integer FOREIGN KEY REFERENCES dim_drugs(drug_sk) NOT NULL,
drug_fk integer FOREIGN KEY REFERENCES dim_drugs(drug_sk), factory_API_fk integer FOREIGN KEY REFERENCES dim_factories(factory_sk) NOT NULL,
factory_API_fk integer FOREIGN KEY REFERENCES dim_factories(factory_sk), factory_bulk_fk integer FOREIGN KEY REFERENCES dim_factories(factory_sk) NOT NULL,
factory_bulk_fk integer FOREIGN KEY REFERENCES dim_factories(factory_sk), factory_package_fk integer FOREIGN KEY REFERENCES dim_factories(factory_sk) NOT NULL,
factory_package_fk integer FOREIGN KEY REFERENCES dim_factories(factory_sk), country_fk integer FOREIGN KEY REFERENCES dim_countries(country_sk) NOT NULL,
country_fk integer FOREIGN KEY REFERENCES dim_countries(country_sk),
--claim status do uspójnienia z tabelą dim_status, wydaje mi się, że można by dodać przedrostek claim do kolumn, będzie czytelniej :) --claim status do uspójnienia z tabelą dim_status, wydaje mi się, że można by dodać przedrostek claim do kolumn, będzie czytelniej :)
claim_status_fk integer FOREIGN KEY REFERENCES dim_claim_statuses(claim_status_sk), claim_status_fk integer FOREIGN KEY REFERENCES dim_claim_statuses(claim_status_sk) NOT NULL,
indication_fk integer FOREIGN KEY REFERENCES dim_indications(indication_sk), indication_fk integer FOREIGN KEY REFERENCES dim_indications(indication_sk) NOT NULL,
claim_number NVARCHAR(50), claim_number NVARCHAR(50),
-- cnt jest tylko zliczeniowy, będzie miał 1, więc dałbym tinyint -- cnt jest tylko zliczeniowy, będzie miał 1, więc dałbym tinyint
cnt tinyint, cnt tinyint,
); );
GO GO
DROP TABLE IF EXISTS FT2_Refund; CREATE TABLE FT_Refund (
CREATE TABLE FT2_Refund ( ft_registartion_sk INTEGER identity(1,1) PRIMARY KEY,
id INTEGER identity(1,1) PRIMARY KEY, claim_status_fk integer FOREIGN KEY REFERENCES dim_claim_statuses(claim_status_sk) NOT NULL,
claim_status_fk integer FOREIGN KEY REFERENCES dim_claim_statuses(claim_status_sk), drug_fk integer FOREIGN KEY REFERENCES dim_drugs(drug_sk) NOT NULL,
drug_fk integer FOREIGN KEY REFERENCES dim_drugs(drug_sk), submission_date_fk integer FOREIGN KEY REFERENCES dim_time(time_sk) NOT NULL,
submission_date_fk integer FOREIGN KEY REFERENCES dim_time(time_sk), expected_response_fk integer FOREIGN KEY REFERENCES dim_time(time_sk) NOT NULL,
expected_response_fk integer FOREIGN KEY REFERENCES dim_time(time_sk), response_time_fk integer FOREIGN KEY REFERENCES dim_time(time_sk), -- moze byc null
response_time_fk integer FOREIGN KEY REFERENCES dim_time(time_sk), country_fk integer FOREIGN KEY REFERENCES dim_countries(country_sk) NOT NULL,
country_fk integer FOREIGN KEY REFERENCES dim_countries(country_sk), indication_fk integer FOREIGN KEY REFERENCES dim_indications(indication_sk) NOT NULL,
indication_fk integer FOREIGN KEY REFERENCES dim_indications(indication_sk), registration_country_fk integer FOREIGN KEY REFERENCES dim_countries(country_sk) NOT NULL,
registration_country_fk integer FOREIGN KEY REFERENCES dim_countries(country_sk),
--decimal zjada mniej, niż money, do przedyskutowania (precyzja - liczba miejsc przed i po przecinku, skala - liczba miejsc po przecinku) --decimal zjada mniej, niż money, do przedyskutowania (precyzja - liczba miejsc przed i po przecinku, skala - liczba miejsc po przecinku)
price money, price money,
reimbursement_amountPercent smallint, reimbursement_amountPercent smallint,

View File

@ -1,32 +1,32 @@
DROP INDEX IF EXISTS expected_response_time_fk_ft1_index ON FT1_Registration; DROP INDEX IF EXISTS expected_response_time_fk_ft1_index ON FT_Registration;
CREATE INDEX expected_response_time_fk_ft1_index ON FT1_Registration(expected_response_time_fk); -- CREATE INDEX expected_response_time_fk_ft1_index ON FT_Registration(expected_response_time_fk);
DROP INDEX IF EXISTS submission_date_fk_ft1_index ON FT1_Registration; DROP INDEX IF EXISTS submission_date_fk_ft1_index ON FT_Registration;
CREATE INDEX submission_date_fk_ft1_index ON FT1_Registration(submission_date_fk); -- CREATE INDEX submission_date_fk_ft1_index ON FT_Registration(submission_date_fk);
DROP INDEX IF EXISTS submission_date_fk_ft1_index ON FT1_Registration; DROP INDEX IF EXISTS submission_date_fk_ft1_index ON FT_Registration;
CREATE INDEX submission_date_fk_ft1_index ON FT1_Registration(submission_date_fk); -- CREATE INDEX submission_date_fk_ft1_index ON FT_Registration(submission_date_fk);
DROP INDEX IF EXISTS response_time_fk_ft1_index ON FT1_Registration; DROP INDEX IF EXISTS response_time_fk_ft1_index ON FT_Registration;
CREATE INDEX response_time_fk_ft1_index ON FT1_Registration(response_time_fk); -- CREATE INDEX response_time_fk_ft1_index ON FT_Registration(response_time_fk);
DROP INDEX IF EXISTS drug_fk_ft1_index ON FT1_Registration; DROP INDEX IF EXISTS drug_fk_ft1_index ON FT_Registration;
CREATE INDEX drug_fk_ft1_index ON FT1_Registration(drug_fk); -- CREATE INDEX drug_fk_ft1_index ON FT_Registration(drug_fk);
DROP INDEX IF EXISTS factory_API_fk_ft1_index ON FT1_Registration; DROP INDEX IF EXISTS factory_API_fk_ft1_index ON FT_Registration;
CREATE INDEX factory_API_fk_ft1_index ON FT1_Registration(factory_API_fk); -- CREATE INDEX factory_API_fk_ft1_index ON FT_Registration(factory_API_fk);
DROP INDEX IF EXISTS factory_bulk_fk_ft1_index ON FT1_Registration; DROP INDEX IF EXISTS factory_bulk_fk_ft1_index ON FT_Registration;
CREATE INDEX factory_bulk_fk_ft1_index ON FT1_Registration(factory_bulk_fk); -- CREATE INDEX factory_bulk_fk_ft1_index ON FT_Registration(factory_bulk_fk);
DROP INDEX IF EXISTS factory_package_fk_ft1_index ON FT1_Registration; DROP INDEX IF EXISTS factory_package_fk_ft1_index ON FT_Registration;
CREATE INDEX factory_package_fk_ft1_index ON FT1_Registration(factory_package_fk); -- CREATE INDEX factory_package_fk_ft1_index ON FT_Registration(factory_package_fk);
DROP INDEX IF EXISTS country_fk_ft1_index ON FT1_Registration; DROP INDEX IF EXISTS country_fk_ft1_index ON FT_Registration;
CREATE INDEX country_fk_ft1_index ON FT1_Registration(country_fk); -- CREATE INDEX country_fk_ft1_index ON FT_Registration(country_fk);
DROP INDEX IF EXISTS claim_status_fk_ft1_index ON FT1_Registration; DROP INDEX IF EXISTS claim_status_fk_ft1_index ON FT_Registration;
CREATE INDEX claim_status_fk_ft1_index ON FT1_Registration(claim_status_fk); -- CREATE INDEX claim_status_fk_ft1_index ON FT_Registration(claim_status_fk);
DROP INDEX IF EXISTS indication_fk_ft1_index ON FT1_Registration; DROP INDEX IF EXISTS indication_fk_ft1_index ON FT_Registration;
CREATE INDEX indication_fk_ft1_index ON FT1_Registration(indication_fk); -- CREATE INDEX indication_fk_ft1_index ON FT_Registration(indication_fk);