Slimming Ideas for Wide Watches

In the previous paragraph, we need to develop a system that integrates various preferential activities in different industries. The algorithm for calculating income involves a lot of data. For
example , you can get points when you stay in a hotel. How much is the gift, one night is free after staying for N days, how much is the discount for the full amount...
Then the table for calculating points needs to have the number of points, the type of points (multiple or fixed value or exchange), the denominator used for exchange, and the type of denominator ( The number of rooms, the length of stay, the number of member points...), the unit, the number of revenue repetitions, etc.


And because of the business relationship, the table cannot be split, but if you use a wide table, one row of records, most of the data is empty, readability Very poor, the data items are trending more and more.
(Insert a sentence, we use oracle)

For this type of wide table (in a row of records, there is not much valid data), my solution is to keep the data items that need to be associated with other tables unchanged, while the calculation-related data items remain unchanged. All fields are replaced with a large field, and the data is stored in the large field in the form of json.
The original design has become the promotion ID, business type, calculation type, and calculation data (a large field of 4000 characters),

although the readability is somewhat reduced (but compared to the empty fields in a line, it must be pulled back and forth. You can only find all the required fields by taking it, and I think the readability is improved.)

Although this scheme, at first glance, violates the first generic form of the database, the first normal form does not stipulate the splitting of data items, which must be based on the basic data type. shall prevail;

especially for relational databases, if the "basic data item" is changed to the dimension associated with the outer table, and the item that needs to be queried in other tables, it must conform to the first normal form;
and only valid for this table. Multiple data items, scattered into multiple or combined into one, should be subject to the project requirements.

For example, for a piece of news, no one will split the text into multiple parts by word and symbol.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326169508&siteId=291194637
Recommended