Design and Management of Dictionary Service


Coding issues, who doesn’t want to avoid the edge;

1. Business Background

In terms of search engine functions, I once encountered such a problem that there is a special code in a company name in the database. Although the data has been normally synchronized to the index, the keywords in the system still cannot match the company;

Then do fuzzy matching in the library, copy the company name into the search box, so that the index can be hit normally, then the problem is very clear, this kind of data “stealth” situation, that is, it looks like the same word, but actually Not above, usually caused by special encoding;

Data collection through forms is a common business method, but if there are multiple arbitrary input text boxes in the form, the quality of the obtained data may have many deficiencies, especially for some core fields, strict verification rules are very necessary;

From the perspective of data, although obtaining multi-dimensional data is conducive to panoramic recognition, the accuracy or quality of the values ​​of each dimension is the key. For most business scenarios, only some attributes of data entities are relied on. More Still lies in the quality of the data dimension;

Among the means of improving data quality, the most effective way is to provide enumeration values ​​for field dimensions as much as possible, and limit the data content within the agreed range. Secondly, the verification rules need to be rigorous, so as to ensure the high quality of business data ;

2. Dictionary service

In the distributed system architecture, the more common basic service layers usually include: scheduling, caching, files, messages, dictionaries, etc. Let’s talk about the design of dictionary services and the logic of business collaboration in detail; first, let’s take a look at the interaction logic :

Design and Management of Dictionary Service

In the dictionary service, it usually manages the maintenance of public constants and data enumeration values; under normal circumstances, when the business form is loaded, the enumeration values ​​of each dimension are read from the dictionary service, and when the form is submitted, the verification related Enumerate fields to improve the quality of content;

The fundamental purpose of the enumeration value provided in the dictionary service is to ensure the uniformity of the data value and avoid describing the same information in two ways as much as possible, such as programming tags: “JAVA” and “Java”, although from the perspective of the program Identification can be circumvented, but is practically avoidable;

Design and Management of Dictionary Service

From the perspective of common content management of dictionary services, it usually includes: constants, status descriptions, business identifiers; data code tables such as industries, labels, addresses, schools, etc.; its biggest feature is that it is globally reused and identified in the system;

3. Detailed design

1. Maintenance method

For the maintenance of dictionary data, two methods are usually used: enumeration class management, code table storage, and parameter table storage; how to choose the corresponding method depends more on the attributes of the data:

  • Enumeration class: maintain fields that will not change basically, such as the general state description of data;
  • Code table: Usually the data has a hierarchical or cascading relationship, such as multi-level linkage between addresses and industries;
  • Parameter table: The real-time requirements are very high, such as the definition of field enumeration values, which need dynamic real-time management;

Design and Management of Dictionary Service

Regardless of which method is used to manage dictionary data, it is necessary to enhance the description of business semantics, so that the corresponding enumeration options can be read through the corresponding identifier in the business form, and submission actions outside the scope are intercepted;

2. Data loading

The query of dictionary data usually adopts the Cache-Aside cache mode, that is, the query first accesses the cached data, and returns the data if it hits; otherwise, accesses the database table data, returns the page after obtaining the data, and synchronizes the cache; it also needs to be updated again after modifying the content in the control center. sync cache;

Design and Management of Dictionary Service

Although the dictionary service is not complicated, the system access is very frequent. If an abnormal situation occurs, it will easily have a large-scale impact on the business. It is necessary to consider the traffic of concurrent access, and to design a reasonable query to reduce the loading time and avoid affecting the process. produce a perceived impact;

3. Data modification

Whether you use a dictionary to load enumeration values ​​or use any input method, you will face an unavoidable problem. When field values ​​are continuously optimized in business development, you need to clean the data. As for the process of data cleaning, the previous It has been summarized in detail and will not be repeated here.

4. Data Awareness

The logic of the data dictionary itself is relatively simple, but if it is placed in the data system, it is a basic awareness. It is easy to have the same name but different definitions in the data, or the same definition but different names, which will bring a lot to data analysis. unnecessary trouble;

Therefore, based on the data dictionary, clarify the data caliber while avoiding differences in business semantics, especially for Chinese, what does “meaning” mean?

5. Reference source code

Programming documentation:

Application repository:

Recommended Today

vue-cli3.0 configure Iview custom theme

don’t panic, followIviewCome on, probably . . . no problem! 1. Create a new my-them.less @import ‘~view-design/src/styles/index.less’; /*Theme configuration and other configurations refer to*/ @primary-color: #6C86FF; @link-hover-color: #6C86FF; 2. Import the entry file main.js import ‘./assets/css/my-them.less’; illustrate The less file needs to be supported here, and the project should install less and less-loader // […]