Design methods of database design, dynamic columns

 

 

The issues raised:
the database during the development process, we often encounter this situation:
as in industrial computing, there are many projects need to pay wages to calculate summary, such as base salary, piece rate, hourly wages, bonuses for everyone, subsidies, withholding, etc., but we are in the process of building the table we can not determine the name of pay, can not determine in the end how many projects, it faced a problem in the construction of the table when, how many columns built? Since what is his name?
Now I have done before a charging system, for example, briefly explain the process for this situation.
Case case:
a unit charge system, is now determined to close heating bills jurisdictions, property charges, security fees, sanitation fees, subscription fees, over the water heating costs, water costs, rent, utilities, booth fees, retail rents eleven toll project, but are likely to increase customers for rubbish removal freight, green fees of some we have not yet determined the cost and in the future may have to increase fees.
Goals:
According to the case, we must consider the dynamic design of the column, rather than the customer needs when adding columns to modify the database table structure directly.
Method:
using the column map handling of the line, but will map out the meaningless regular column names erratic but meaningful lines.
Implementation steps (design tool PowerDesigner9.5 data to MS SqlServer2000):
First, determine the project up to several
charges specifically how many items, because there are variables, we can not be determined, but will not exceed the maximum number of projects, although we still can not determine but this can be estimated. By using the object's comprehensive analysis of the actual situation and system life cycle system, as this will be temporary or increased fees will not exceed half of existing projects identified, so in this system to estimate the maximum fees will be 16 months. (Note: the increased fees will not exceed half of existing projects identified, refers only to this case, to analyze specific issues).
Second, a project information sheet
Establishing a program for storing (column) table, the table structure information are as follows:

Data reads as follows:

 

In this way, we will use this project to determine the information table corresponding to each item in the column name down, or that the corresponding column names corresponding fees will be finalized at the other table.
When we need to change the name of fees or changes in fees just modify the table category name.
May also be stored in this table according to the actual situation with some additional information, such as increasing the formula column to the formula C13 = C1 + C5, the line number of the equation 13, the column could hold C1 + C5, this is just a simple example, You can save a lot of information with extended according to the actual situation.
First, the use of project information table
we build project information table, mainly to be used in all other tables to use these fees in. For example, we withhold our project another table set the table (which is set by the paying user fees withholding unit is located), the table structure is as follows:

数据表中数据表示次单位是否代扣此项目,如单位编码为001的单位,DK_C01为1表示001单位代扣暖气费,为0表示不代扣。 
其它别的比如收费信息表(存储收费用户个人收费信息),个人收费项目表(存储收费用户个人有哪些收费项目)等表中均可使用类似定义列,我们在做数据库操作的时候,可动态使用列名,如收费信息表中,存储费用信息的列为FY_C01…FY_C16,我们计算此用户总费用时可使用循环累加,列名由循环变里动态组合而成,如”FY_C”+循环变量处理形式表示。
方案优缺点:
优点:1、能够灵活的设置项目(具有共性的多个分类)的名称或表示形式,而不受数据库实际列的限制,而且能夠方便的进行修改。
2、在进行数据处理时能根据某种规律动态生成列名而读取或更新数据。
缺点:如不能正确估计项目最多有几项,会导致需修改多个表。
 
注:这篇文章是我以前做过一个项目中实际碰到实际问题,我只是最近闲下来做了个整理,其实是一个很简单的处理方式,不是写给高手看的,只是希望对碰到问题类似问题的朋友做一参考。
 
————————————————
版权声明:本文为CSDN博主「chaihuo」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/chaihuo/article/details/1631680

Guess you like

Origin www.cnblogs.com/Jeely/p/12366001.html