1
0
forked from s26450/hurtownia

update create.sql

This commit is contained in:
Mariusz Sielski 2018-12-02 09:46:29 +01:00
parent 1d3bcc6efe
commit 71f280027d

View File

@ -22,12 +22,12 @@ 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)
drug_product_id_bk INTEGER NOT NULL, -- business key
record_status CHAR(1), -- A for active, D for deactivated
drug_product_name NVARCHAR(250),
ro_number NVARCHAR(20),
drug_product_family_id INTEGER,
drug_product_family_name NVARCHAR(250)
);
GO
@ -41,13 +41,13 @@ CREATE TABLE dim_countries (
DROP TABLE IF EXISTS dim_claim_statuses;
CREATE TABLE dim_claim_statuses (
claim_status_sk INTEGER identity(1, 1) PRIMARY KEY,
status_code VARCHAR(1) NOT NULL, -- A for Accepted, D for Declined, W for Waiting
status_code_bk 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)
INSERT INTO dim_claim_statuses(status_code_bk, status_description)
VALUES
('A', 'Accepted'),
('D', 'Declined'),
@ -57,9 +57,9 @@ 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)
indication_id_bk INTEGER NOT NULL,
record_status CHAR(1),
indication_description NVARCHAR(500)
);
GO
@ -68,40 +68,43 @@ GO
--IF OBJECT_ID('dbo.FT1_Registartion') IS NOT NULL DROP TABLE dbo.MyCategories;
DROP TABLE IF EXISTS FT1_Registartion;
CREATE TABLE FT1_Registartion (
DROP TABLE IF EXISTS FT1_Registration;
CREATE TABLE FT1_Registration (
id INTEGER identity(1,1) PRIMARY KEY,
expected_response integer,
submission_date integer,
response_time integer,
drug_sk integer,
factory_sk_API integer,
factory_sk_bulk integer,
factory_sk_package integer,
country_sk integer,
expected_response_fk integer,
submission_date_fk integer,
response_time_fk integer,
drug_fk integer,
factory_API_fk integer,
factory_bulk_fk integer,
factory_package_fk integer,
country_fk integer,
--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_sk integer,
indication_sk integer,
claim_status_fk integer,
indication_fk integer,
claim_number integer,
-- cnt jest tylko zliczeniowy, będzie miał 1, więc dałbym tinyint
cnt tinyint
cnt tinyint,
);
GO
DROP TABLE IF EXISTS FT2_Refund;
CREATE TABLE FT2_Registartion (
CREATE TABLE FT2_Refund (
id INTEGER identity(1,1) PRIMARY KEY,
claim_status_sk integer,
drug_sk integer,
submission_date integer,
expected_response integer,
country_sk integer,
indication_sk integer,
registration_country integer,
claim_status_fk integer,
drug_fk integer,
submission_date_fk integer,
expected_response_fk integer,
response_time_fk integer,
country_fk integer,
indication_fk integer,
registration_country_fk integer,
--decimal zjada mniej, niż money, do przedyskutowania (precyzja - liczba miejsc przed i po przecinku, skala - liczba miejsc po przecinku)
price decimal(9,2),
price money,
reimbursement_amountPercent smallint,
--tu obliczymy jako iloczyn price * reimbursement_amountPercent
reimbursement_amount decimal(9,2),
claim_number integer,
cnt tinyint,
);
GO