Data Visualization Part 12: PowerDesigner configuration to generate tens of millions of data and generate data

introduction:

    At work, I met the need to make tests, so I thought about writing batch inserts by myself. But the amount of data is too large, and batching with insert is too much trouble.

Fact table and dimension table definition, and test data:

    (1) Medical income fact sheet

create table project_cost_fact

(

  id int primary key auto_increment,

  cost_direction_code VARCHAR(20) comment'cost direction code', 

  hospital_code VARCHAR(20) comment'Hospital fixed-point code', 

  level_code VARCHAR(20) comment'Hospital level code',

  time_code VARCHAR(10) comment'time code',

  income_type_code VARCHAR(32) comment'Income category code: 1. Outpatient income 2. Registration income 3. Diagnosis income 4. Inspection income 5. Laboratory examination income 6. Treatment income 7. Surgery income 8. Health materials income 9. Western medicine income 10. Income from Chinese herbal medicine11, income from proprietary Chinese medicine12, income from pharmaceutical service fees13, income from other outpatient services14, income from hospitalization15, income from beds16, income from nursing care17, income from other hospitalization',

  borrowing VARCHAR(32) comment'borrowing direction',

  accrual DOUBLE comment'Amount', 

  total DOUBLE comment'total'

)

    (2) Time dimension table

CREATE TABLE time_type(

  code VARCHAR(20) comment'Time code',

  year INT COMMENT'year',

  year_name VARCHAR(20) comment'year name',

  quarter INT COMMENT'Quarter',

  quarter_name VARCHAR(20) comment'Quarter name',

  month INT COMMENT'month',

  month_name VARCHAR(20) comment'month name',

  create_time VARCHAR(20) comment'create time')

insert into time_type values('1','2017','2017','1','first quarter','1','January','2020-04-24 06:50:53') ;

insert into time_type values('2','2017','2017','1','first quarter','2','February','2020-04-24 06:50:53') ;

insert into time_type values('3','2017','2017','1','first quarter','3','March','2020-04-24 06:50:53') ;

insert into time_type values('4','2017','2017','2','Q2','4','April','2020-04-24 06:50:53') ;

insert into time_type values('5','2017','2017','2','Q2','5','May','2020-04-24 06:50:53') ;

insert into time_type values('6','2017','2017','2','second quarter','6','June','2020-04-24 06:50:53') ;

insert into time_type values('7','2017','2017','3','third quarter','7','July','2020-04-24 06:50:53') ;

insert into time_type values('8','2017','2017','3','third quarter','8','August','2020-04-24 06:50:53') ;

insert into time_type values('9','2017','2017','3','third quarter','9','September','2020-04-24 06:50:53') ;

insert into time_type values('10','2017','2017','4','Q4','10','October','2020-04-24 06:50:53') ;

insert into time_type values('11','2017','2017','4','fourth quarter','11','November','2020-04-24 06:50:53' );

insert into time_type values('12','2017','2017','4','fourth quarter','12','December','2020-04-24 06:50:53' );

insert into time_type values('13','2018','2018','1','first quarter','1','January','2020-04-24 06:50:53') ;

insert into time_type values('14','2018','2018','1','first quarter','2','February','2020-04-24 06:50:53') ;

insert into time_type values('15','2018','2018','1','first quarter','3','March','2020-04-24 06:50:53') ;

insert into time_type values('16','2018','2018','2','second quarter','4','April','2020-04-24 06:50:53') ;

insert into time_type values('17','2018','2018','2','Q2','5','May','2020-04-24 06:50:53') ;

insert into time_type values('18','2018','2018','2','Q2','6','June','2020-04-24 06:50:53') ;

insert into time_type values('19','2018','2018','3','third quarter','7','July','2020-04-24 06:50:53') ;

insert into time_type values('20','2018','2018','3','third quarter','8','August','2020-04-24 06:50:53') ;

insert into time_type values('21','2018','2018','3','third quarter','9','September','2020-04-24 06:50:53') ;

insert into time_type values('22','2018','2018','4','Q4','10','October','2020-04-24 06:50:53') ;

insert into time_type values('23','2018','2018','4','fourth quarter','11','November','2020-04-24 06:50:53' );

insert into time_type values('24','2018','2018','4','fourth quarter','12','December','2020-04-24 06:50:53' );

insert into time_type values('25','2019','2019','1','first quarter','1','January','2020-04-24 06:50:53') ;

insert into time_type values('26','2019','2019','1','first quarter','2','February','2020-04-24 06:50:53') ;

insert into time_type values('27','2019','2019','1','first quarter','3','March','2020-04-24 06:50:53') ;

insert into time_type values('28','2019','2019','2','Q2','4','April','2020-04-24 06:50:53') ;

insert into time_type values('29','2019','2019','2','Q2','5','May','2020-04-24 06:50:53') ;

insert into time_type values('30','2019','2019','2','Q2','6','June','2020-04-24 06:50:53') ;

insert into time_type values('31','2019','2019','3','third quarter','7','July','2020-04-24 06:50:53') ;

insert into time_type values('32','2019','2019','3','third quarter','8','August','2020-04-24 06:50:53') ;

insert into time_type values('33','2019','2019','3','third quarter','9','September','2020-04-24 06:50:53') ;

insert into time_type values('34','2019','2019','4','Q4','10','October','2020-04-24 06:50:53') ;

insert into time_type values('35','2019','2019','4','fourth quarter','11','November','2020-04-24 06:50:53' );

insert into time_type values('36','2019','2019','4','fourth quarter','12','December','2020-04-24 06:50:53' );

    (3) Hospital dimension table

create table hospital(

id int primary key auto_increment,

hospital_code VARCHAR(20) comment'hospital code', 

hospital_name VARCHAR(20) comment'hospital name' 

)

insert into hospital(hospital_code,hospital_name) values('6251088','徐水**医院');

insert into hospital(hospital_code,hospital_name) values('6250007','徐水**医院');

insert into hospital(hospital_code,hospital_name) values('6250009','保定**医院');

insert into hospital(hospital_code,hospital_name) values('6251035','保定**医院');

insert into hospital(hospital_code,hospital_name) values('6251001','保定**医院');

insert into hospital(hospital_code,hospital_name) values('6251002','保定**医院');

insert into hospital(hospital_code,hospital_name) values('6251004','保定**院');

insert into hospital(hospital_code,hospital_name) values('6251888','徐**医院');

insert into hospital(hospital_code,hospital_name) values('6251005','徐水**医院');

insert into hospital(hospital_code,hospital_name) values('6258888','徐水**医院');  

    (4) Hospital level dimensions

CREATE TABLE hospital_level(

  level_code VARCHAR(20) comment'Hospital level code',

  level_name VARCHAR(20) comment'Hospital level name',

  create_time VARCHAR(20) comment'create time'

  )

insert into hospital_level values ​​('1','third-level hospital','2020-04-24 06:50:42');

insert into hospital_level values ​​('2','second-level hospital','2020-04-24 06:50:42');

insert into hospital_level values ​​('3','first-level hospital','2020-04-24 06:50:42');

insert into hospital_level values ​​('4','Below first level (community medical)','2020-04-24 06:50:42');

    (5) Department dimension table

create table office_type(

  id int primary key auto_increment,

  office_code VARCHAR(32) comment'Department code',

  office_name VARCHAR(32) comment'Department name'

)

insert into office_type(office_code,office_name) value ('1','普外科');

insert into office_type(office_code,office_name) value ('2','骨外科');

insert into office_type(office_code,office_name) value ('3','心内科');

insert into office_type(office_code,office_name) value ('4','口腔科');

insert into office_type(office_code,office_name) value ('5','消化科');

insert into office_type(office_code,office_name) value ('6','肾内科');

insert into office_type(office_code,office_name) value ('7','眼科');

insert into office_type(office_code,office_name) value ('8','免疫科');

insert into office_type(office_code,office_name) value ('9','Infectious Disease Department');

insert into office_type(office_code,office_name) value ('10','急诊科');

insert into office_type(office_code,office_name) value ('11','皮肤科');

insert into office_type(office_code,office_name) value ('12','神经内科');

insert into office_type(office_code,office_name) value ('13','neonatal medicine');

insert into office_type(office_code,office_name) value ('14','耳鼻喉科科');

insert into office_type(office_code,office_name) value ('15','呼吸中心');

insert into office_type(office_code,office_name) value ('16','Hematological Tumor Center');

    (6) Cost item dimension table

create table project_type

(

id int primary key auto_increment,

 project_code VARCHAR(32) comment'Cost project code',

 project_name VARCHAR(32) comment'Cost project name'

)

insert into project_type(project_code,project_name) values('1','员经费');

insert into project_type(project_code,project_name) values('2','sanitary material fee');

insert into project_type(project_code,project_name) values('3','药品费');

insert into project_type(project_code,project_name) values('4','depreciation of fixed assets');

insert into project_type(project_code,project_name) values('5','intangible asset amortization');

insert into project_type(project_code,project_name) values('6','withdraw medical risk fund');

insert into project_type(project_code,project_name) values('7','other expenses');

insert into project_type(project_code,project_name) values('8','合计');

insert into project_type(project_code,project_name) values('9','Department Income');

insert into project_type(project_code,project_name) values('10','income-cost');

insert into project_type(project_code,project_name) values('11','床日成本');

insert into project_type(project_code,project_name) values('12','诊次成本');

    (7) Income category dimension table

create table income_type(

id int primary key auto_increment,

income_type_code VARCHAR(32) comment'Income category code: 1. Outpatient income 2. Registration income 3. Diagnosis income 4. Inspection income 5. Laboratory examination income 6. Treatment income 7. Surgery income 8. Health materials income 9. Western medicine income 10. Income from Chinese herbal medicine11, income from proprietary Chinese medicine12, income from pharmaceutical service fees13, income from other outpatient services14, income from hospitalization15, income from beds16, income from nursing care17, income from other hospitalization',

income_type_name VARCHAR(32) comment'Name of income category: 1. Outpatient income 2. Registration income 3. Diagnosis income 4. Inspection income 5. Laboratory examination income 6. Treatment income 7. Surgery income 8. Health material income 9. Western medicine income 10. Income from Chinese herbal medicine 11, income from proprietary Chinese medicines 12, income from pharmacy service fees 13, income from other outpatient clinics 14, income from hospitalization 15, income from beds 16, income from nursing care 17, other hospitalization income'

)  

insert into income_type (income_type_code,income_type_name) values('1','门诊收入');

insert into income_type (income_type_code,income_type_name) values('2','挂号收入');

insert into income_type (income_type_code,income_type_name) values('3','诊察收入');

insert into income_type (income_type_code,income_type_name) values('4','检查收入');

insert into income_type (income_type_code,income_type_name) values('5','化验收入');

insert into income_type (income_type_code,income_type_name) values('6','治疗收入');

insert into income_type (income_type_code,income_type_name) values('7','手术收入');

insert into income_type (income_type_code,income_type_name) values('8','卫生材料收入');

insert into income_type (income_type_code,income_type_name) values('9','西药收入');

insert into income_type (income_type_code,income_type_name) values('10','中草药收入');

insert into income_type (income_type_code,income_type_name) values('11','中成药收入');

insert into income_type (income_type_code,income_type_name) values('12','pharmaceutical service fee income');

insert into income_type (income_type_code,income_type_name) values('13','其他门诊收入 ');

insert into income_type (income_type_code,income_type_name) values('14','住院收入');

insert into income_type (income_type_code,income_type_name) values('15','床位收入');

insert into income_type (income_type_code,income_type_name) values('16','护理收入');

insert into income_type (income_type_code,income_type_name) values('17','其他住院收入');

    (8) Cost direction dimension table

create table cost_direction_type(

id int primary key auto_increment,

cost_direction_code VARCHAR(20) comment'cost direction code', 

cost_direction_name VARCHAR(20) comment'Cost direction name' 

)

insert into cost_direction_type(cost_direction_code,cost_direction_name) values('1','医疗收入');

insert into cost_direction_type(cost_direction_code,cost_direction_name) values('2','Financial basic subsidy income');

insert into cost_direction_type(cost_direction_code,cost_direction_name) values('3','Financial project subsidy income');

insert into cost_direction_type(cost_direction_code,cost_direction_name) values('4','Science and Education Project Income');

insert into cost_direction_type(cost_direction_code,cost_direction_name) values('5','其他收入');

insert into cost_direction_type(cost_direction_code,cost_direction_name) values('6','medical business cost');

insert into cost_direction_type(cost_direction_code,cost_direction_name) values('7','Financial project subsidy expenditure');

insert into cost_direction_type(cost_direction_code,cost_direction_name) values('8','science and education project expenditure');

insert into cost_direction_type(cost_direction_code,cost_direction_name) values('9','管理费用');

    The definition and data of the fact table and dimension table are given above. At the beginning of this article, I also mentioned finding a batch insert. You can think about the amount of data that is too much and too much trouble. It can also be achieved through psql programming, and I am too lazy to write stored procedures.

Now let's talk about the large amount of data, how to calculate the amount of data?

Suppose, you want to create 10,000 records for the fact table. It should be almost enough, right? ? ?

Total number of records = time dimension table records * hospital dimension table records * hospital level dimension table records * department dimension records * cost item dimension records * income category dimension table records * expense direction dimension table records *

Total number of records = 36*10*3*16*12*17*9=31726080


PowerDesigner seems to have the function of creating test data, and the operation is convenient, and the realization process can be reused. The realization is as follows:

1. Reversely introduce the table in the library

image.png

image.png

image.png

2. Specify the user to be operated, do not operate by other users, and pay attention to data security

image.png

3. Specify the user, and then specify which tables in the user are to be operated (I only created 1 table here)

image.png

4. The imported table structure is as follows:

image.png

note:

The id is the primary key and can be self-increased, don't care.

According to your business needs, generate test data for the specified column. Here I choose the level_code string type and the accrual DOUBLE type to demonstrate. Other columns in the table will be filled with random strings by default.

5. Double-click the introduced table structure

image.png

6. Find the Columns tab, here are all the columns in the table, each column has a serial number in front of it, find the column to be operated, double-click the serial number in front of it: here my biweekly is the serial number 3 in front of leve_code

image.png

image.png

7. Create a new test data profile file for the level_code column

image.png

8. Specify the generated data type:

Automatic: Represents the generation of numerical data, which can be a regular increasing sequence and random number

List: There are no rules for the generated data. You can put these data in a collection. The data type is not limited, just like the Objct type stored in the List in java.

    1)、Automatic

image.png

image.png

image.png

image.png

The newly created test data profile has been applied to the leve_code column

2)、List

image.png

image.png

image.png

There are no rules for data (except for numeric types, some string types can also be specified)

image.png

If the data has rules

image.png

image.png

image.png

The newly created test data profile has been applied to the accrual column

image.png

As you can see, the two newly created test data profiles

9. Trigger run to generate test data

image.png

image.png

image.png

Generated at 100%



Guess you like

Origin blog.51cto.com/51power/2540509