[go: up one dir, main page]

CN104462421B - Multi-tenant extended method based on key-value database - Google Patents

Multi-tenant extended method based on key-value database Download PDF

Info

Publication number
CN104462421B
CN104462421B CN201410771826.8A CN201410771826A CN104462421B CN 104462421 B CN104462421 B CN 104462421B CN 201410771826 A CN201410771826 A CN 201410771826A CN 104462421 B CN104462421 B CN 104462421B
Authority
CN
China
Prior art keywords
business entity
tenant
metadata
key
business
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201410771826.8A
Other languages
Chinese (zh)
Other versions
CN104462421A (en
Inventor
刘磊
周渊斐
郑艳伟
袁鼎
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Zhengzhou Xinrand Network Technology Co ltd
Institute of Acoustics CAS
Original Assignee
Institute of Acoustics CAS
Beijing Intellix Technologies Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Institute of Acoustics CAS, Beijing Intellix Technologies Co Ltd filed Critical Institute of Acoustics CAS
Priority to CN201410771826.8A priority Critical patent/CN104462421B/en
Publication of CN104462421A publication Critical patent/CN104462421A/en
Application granted granted Critical
Publication of CN104462421B publication Critical patent/CN104462421B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2453Query optimisation
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/22Indexing; Data structures therefor; Storage structures
    • G06F16/2282Tablespace storage structures; Management thereof

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Software Systems (AREA)
  • Computational Linguistics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

本发明实施例涉及一种基于键‑值数据库的多租户扩展方法,所述方法包括:获取初始业务实体元数据;定制阶段,在所述初始业务实体元数据上扩展业务属性,对所述业务属性定义业务实体和显示标签,生成满足多租户需求的特定业务实体元数据;生成实例阶段,根据所述特定业务实体元数据,创建键‑值Key‑Value数据库;实例运行阶段,以租户标识作为RowKey前缀插入到Key‑Value数据库的业务实体数据,通过所述租户标识生成RowKey的查询范围查询业务实体数据,在所述查询范围内从所述Key‑Value数据库中取出业务实体数据,按照所述特定业务实体元数据生成交互界面,以便将所述业务实体数据展示。

The embodiment of the present invention relates to a multi-tenant extension method based on a key-value database. The method includes: acquiring metadata of an initial business entity; Attributes define business entities and display labels, and generate specific business entity metadata that meets multi-tenant requirements; in the instance generation phase, create a key-value Key-Value database based on the specific business entity metadata; in the instance running phase, the tenant ID is used as The RowKey prefix is inserted into the business entity data of the Key-Value database, and the business entity data is queried within the query range of the RowKey generated by the tenant ID, and the business entity data is taken out from the Key-Value database within the query range, according to the The specific business entity metadata generates an interactive interface for displaying the business entity data.

Description

基于键-值数据库的多租户扩展方法Multi-tenant extension method based on key-value database

技术领域technical field

本发明涉及计算机领域,尤其涉及一种基于键-值数据库的多租户扩展方法。The invention relates to the computer field, in particular to a multi-tenant extension method based on a key-value database.

背景技术Background technique

互联网技术的迅猛发展使得传统数据库在应对海量数据时面临巨大挑战,分布式键-值Key-Value数据库应运而生,Key-Value数据库包括开源的非关系型分布式数据库HBase、非关系型数据库Cassandra、非关系型的数据库否SQL等。Key-Value数据库的分布式构架,相对传统关系型数据库具有可存储大量数据,一个表可以有上亿行;面向列存储,面向列(族)的存储和权限控制,列(族)独立检索;稀疏存储,对于空的列,不占用存储空间,可以将表设计的非常稀疏。The rapid development of Internet technology has made traditional databases face huge challenges in dealing with massive data. Distributed key-value Key-Value databases have emerged as the times require. Key-Value databases include open source non-relational distributed database HBase, non-relational database Cassandra , Non-relational databases, SQL, etc. Compared with the traditional relational database, the distributed architecture of the Key-Value database can store a large amount of data, and a table can have hundreds of millions of rows; column-oriented storage, column (family)-oriented storage and permission control, column (family) independent retrieval; Sparse storage, for empty columns, no storage space is occupied, and the table can be designed very sparsely.

多租户技术主要用于多个租户共享硬件资源,多个租户公用一个应用程序实例。现有技术中,多租户技术在数据存储方面主要包括如下三种方案:Multi-tenant technology is mainly used for multiple tenants to share hardware resources, and multiple tenants share one application instance. In the prior art, multi-tenant technology mainly includes the following three solutions in terms of data storage:

1.每个租户拥有独立数据库1. Each tenant has an independent database

为不同租户提供相互独立的数据库,这样数据隔离性最好,而且由于可以为不同用户单独设计数据库结构,有助于简化数据库结构的设计,出现故障恢复也相对简单。但是为每个租户都建立独立数据库,不同租户没有真正共享硬件资源,购置成本和维护成本高,一般运营商无法接受。Provide independent databases for different tenants, so that the data isolation is the best, and because the database structure can be designed separately for different users, it helps to simplify the design of the database structure, and the failure recovery is relatively simple. However, if an independent database is established for each tenant, different tenants do not really share hardware resources, and the acquisition and maintenance costs are high, which is generally unacceptable to operators.

2.租户共享数据库,但拥有独立库表2. Tenants share the database, but have independent database tables

所有租户共享一个数据库,但是不同租户拥有独立的库表。提供了一定的数据之间隔离性,但扩展起来相对麻烦,不便于扩展,成本也较高,跨租户数据统计难。All tenants share a database, but different tenants have independent database tables. It provides a certain isolation between data, but it is relatively cumbersome to expand, not easy to expand, and the cost is high, and cross-tenant data statistics are difficult.

3.租户共享数据库,共享数据库表3. Tenants share the database and share the database table

所有租户共享数据库,共享库表,这种方法成本最低,共享度最高,允许支持的租户也最多,但是由于不同租户之间的业务需求不一,因此针对这种情况需要精心设计数据库。采用传统关系型数据库时,当租户需要添加自定义字段时,需要在数据库中添加列,对于某租户而言,其他租户添加的列对该租户为无用列,但还是需要在数据库中存在,但当租户数量较大时,需要在数据库中增加大量列,这就导致数据库中存在大量的空值,十分浪费空间。All tenants share the database and shared database tables. This method has the lowest cost, the highest degree of sharing, and the most supported tenants. However, due to the different business needs of different tenants, the database needs to be carefully designed for this situation. When using a traditional relational database, when a tenant needs to add a custom field, it needs to add a column in the database. For a tenant, the columns added by other tenants are useless columns for the tenant, but they still need to exist in the database, but When the number of tenants is large, a large number of columns need to be added to the database, which leads to a large number of null values in the database, which is a waste of space.

发明内容Contents of the invention

本发明实施例提供了一种基于键-值数据库的多租户扩展方法,有效降低多租户数据库的运营成本和维护成本,增加多租户数据库的扩展性,降低租户的定制成本和缩短定制周期。The embodiment of the present invention provides a multi-tenant expansion method based on a key-value database, which can effectively reduce the operation cost and maintenance cost of the multi-tenant database, increase the scalability of the multi-tenant database, reduce the customization cost of tenants and shorten the customization cycle.

本发明实施例提供了一种基于键-值数据库的多租户扩展方法,所述方法包括:An embodiment of the present invention provides a multi-tenant extension method based on a key-value database, the method comprising:

获取初始业务实体元数据;Get initial business entity metadata;

定制阶段,在所述初始业务实体元数据上扩展业务属性,对所述业务属性定义业务实体和显示标签,生成满足多租户需求的特定业务实体元数据;In the customization stage, business attributes are extended on the initial business entity metadata, business entities and display labels are defined for the business attributes, and specific business entity metadata meeting multi-tenant requirements are generated;

生成实例阶段,根据所述特定业务实体元数据,创建键-值Key-Value数据库;In the instance generation phase, a key-value Key-Value database is created according to the metadata of the specific business entity;

实例运行阶段,以租户标识作为RowKey前缀插入到Key-Value数据库的业务实体数据,通过所述租户标识生成RowKey的查询范围查询业务实体数据,在所述查询范围内从所述Key-Value数据库中取出业务实体数据,按照所述特定业务实体元数据生成交互界面,以便将所述业务实体数据展示。In the instance running phase, the business entity data is inserted into the Key-Value database with the tenant ID as the RowKey prefix, and the business entity data is queried within the query range of the RowKey generated by the tenant ID, and the Key-Value database is retrieved within the query range The business entity data is taken out, and an interactive interface is generated according to the specific business entity metadata, so as to display the business entity data.

优选地,所述初始业务实体元数据和所述特定业务实体元数据均至少包括:业务实体的表名、业务实体的显示标签、业务实体的属性列名、业务实体的数据类型、业务实体的索引列标识和业务实体的属性显示标签。Preferably, both the initial business entity metadata and the specific business entity metadata include at least: the table name of the business entity, the display label of the business entity, the attribute column name of the business entity, the data type of the business entity, the Indexed column IDs and properties of business entities display labels.

优选地,在所述生成实例阶段中,所述方法还包括:Preferably, in the stage of generating an instance, the method further includes:

所有租户共享一个所述Key-Value数据库,所述初始业务实体元数据对应的列为所有租户共享。All tenants share one Key-Value database, and the column corresponding to the initial business entity metadata is shared by all tenants.

优选地,在所述生成实例阶段中,所述方法还包括:Preferably, in the stage of generating an instance, the method further includes:

所述扩展业务属性用于满足所述租户的不同业务需求,并且同时生成与新增的业务属性对应的扩展列,所述的扩展列仅对所述租户可见。The extended service attributes are used to meet the different service requirements of the tenants, and at the same time, an extended column corresponding to the newly added service attribute is generated, and the extended column is only visible to the tenant.

优选地,所述以租户标识作为RowKey前缀插入到Key-Value数据库的业务实体数据具体还包括:采用所述租户的标识+所述业务实体的表名作为所述业务实体数据的RowKey前缀。Preferably, inserting the business entity data into the Key-Value database with the tenant ID as the RowKey prefix specifically further includes: using the tenant ID + the business entity table name as the RowKey prefix of the business entity data.

优选地,所述通过所述租户标识生成RowKey的查询范围查询业务实体数据具体包括:查询所述Key-Value数据库,根据所述租户的标识和所述业务实体的表名设定查询范围,在所述设定的查询范围内,根据用户设定的查询条件进行查询获取所述业务实体数据。Preferably, the querying service entity data by generating the query scope of the RowKey generated by the tenant identifier specifically includes: querying the Key-Value database, setting the query scope according to the tenant identifier and the table name of the service entity, in Within the set query range, query is performed according to the query conditions set by the user to obtain the business entity data.

优选地,所述按照所述特定业务实体元数据生成交互界面具体包括:Preferably, the generating the interactive interface according to the metadata of the specific business entity specifically includes:

根据所述租户的标识获取所述租户的特定业务实体元数据;Obtaining the specific business entity metadata of the tenant according to the identifier of the tenant;

根据所述租户的特定业务实体元数据的索引列信息和数据类型生成查询项;generating query items according to the index column information and data types of the tenant's specific business entity metadata;

根据所述租户的特定业务实体元数据中的显示标签和业务实体数据显示查询结果;displaying query results according to display tags and business entity data in the tenant-specific business entity metadata;

根据所述租户的特定业务实体元数据的业务实体的显示标签、业务实体的属性显示标签和业务实体的数据类型生成新建页面的新建项。The new item of the new page is generated according to the display label of the business entity, the attribute display label of the business entity, and the data type of the business entity in the metadata of the specific business entity of the tenant.

本发明提出的基于键-值数据库的多租户扩展方法,能够产生积极的有益效果,具体如下:支持通过定制生成满足租户个性化需求的应用,对于业务流程相似的业务可以避免重复开发;采用共享的Key-Value数据库方便实现扩展,降低运营成本,随着新增租户的增长,随着租户的用户规模的的增长,本发明以租户标识作为所有业务实体数据的RowKey前缀,方便实现扩展,降低运营成本。The multi-tenant expansion method based on the key-value database proposed by the present invention can produce positive beneficial effects, specifically as follows: it supports the generation of applications that meet the individual needs of tenants through customization, and can avoid repeated development for services with similar business processes; The Key-Value database is convenient for expansion and reduces operating costs. With the growth of new tenants and the growth of the user scale of tenants, the present invention uses the tenant identifier as the RowKey prefix of all business entity data to facilitate expansion and reduce operating costs.

附图说明Description of drawings

图1为本发明实施例一提供的基于键-值数据库的多租户扩展方法流程图;FIG. 1 is a flowchart of a multi-tenant extension method based on a key-value database provided in Embodiment 1 of the present invention;

图2为本发明实施例二提供的基于键-值数据库的多租户扩展方法的原理框图。FIG. 2 is a functional block diagram of a key-value database-based multi-tenant extension method provided by Embodiment 2 of the present invention.

具体实施方式Detailed ways

为使本发明的目的、技术方案和优点更加清楚,下面结合附图对本发明具体实施例作进一步的详细描述。In order to make the object, technical solution and advantages of the present invention clearer, the specific embodiments of the present invention will be further described in detail below in conjunction with the accompanying drawings.

实施例一Embodiment one

下面以图1为例详细说明本发明实施例一提供的基于键-值数据库的多租户扩展方法,图1为本发明实施例提供的基于键-值数据库的多租户扩展方法流程图,在本发明实施例中实施主体可以为运营支撑平台。图2显示了本发明实施例提出的基于键-值数据库的多租户扩展方法的原理框图。如图2所示,本发明提出的基于键-值数据库的多租户扩展方法中,采用可扩展可定义的多租户的运营支撑平台,该平台采用分布式Key-Value数据库存储业务信息。结合图1和图2所示,该方法包括如下步骤:The following uses Figure 1 as an example to describe in detail the multi-tenant extension method based on the key-value database provided by Embodiment 1 of the present invention. Figure 1 is a flowchart of the multi-tenant extension method based on the key-value database provided by the embodiment of the present invention. The implementation subject in the embodiment of the invention may be an operation support platform. FIG. 2 shows a functional block diagram of a key-value database-based multi-tenant extension method proposed by an embodiment of the present invention. As shown in Figure 2, in the multi-tenant expansion method based on the key-value database proposed by the present invention, an expandable and definable multi-tenant operation support platform is adopted, and the platform uses a distributed Key-Value database to store business information. As shown in Figure 1 and Figure 2, the method includes the following steps:

步骤101、获取初始业务实体元数据;Step 101, obtaining initial business entity metadata;

初始业务实体元数据至少包括:业务实体的表名、业务实体的显示标签、业务实体的属性列名、业务实体的数据类型、业务实体的索引列标识和业务实体的属性显示标签。The initial business entity metadata includes at least: the table name of the business entity, the display label of the business entity, the attribute column name of the business entity, the data type of the business entity, the index column identifier of the business entity, and the attribute display label of the business entity.

步骤102、定制阶段,在所述初始业务实体元数据上扩展业务属性,对所述业务属性定义业务实体和显示标签,生成满足多租户需求的特定业务实体元数据。Step 102, customization phase, extend business attributes on the initial business entity metadata, define business entities and display labels for the business attributes, and generate specific business entity metadata that meets multi-tenant requirements.

所述初始业务实体元数据和所述特定业务实体元数据均至少包括:业务实体的表名、业务实体的显示标签、业务实体的属性列名、业务实体的数据类型、业务实体的索引列标识和业务实体的属性显示标签。Both the initial business entity metadata and the specific business entity metadata include at least: the table name of the business entity, the display label of the business entity, the attribute column name of the business entity, the data type of the business entity, and the index column identifier of the business entity and attributes of business entities display labels.

具体地,运营支撑平台部署前,根据各模块业务需求制定各模块初始业务实体元数据,并根据初始业务元数据创建Key-Value数据库库表,例如,其中业务元数据结构主要如表1所示:Specifically, before the deployment of the operation support platform, the initial business entity metadata of each module is formulated according to the business requirements of each module, and the Key-Value database table is created according to the initial business metadata. For example, the business metadata structure is mainly shown in Table 1 :

表1业务元数据结构表Table 1 Business metadata structure table

根据模板创建数据库表CRM结构如表2所示:Create the database table CRM structure according to the template as shown in Table 2:

表2数据库表CRM结构表Table 2 Database table CRM structure table

步骤103、生成实例阶段,根据所述特定业务实体元数据,创建键-值Key-Value数据库。Step 103 , in the stage of generating an instance, a key-value Key-Value database is created according to the metadata of the specific business entity.

在所述生成实例阶段中,所述方法还包括:During the generating instance phase, the method further includes:

所有租户共享一个所述Key-Value数据库,所述初始业务实体元数据对应的列为所有租户共享。All tenants share one Key-Value database, and the column corresponding to the initial business entity metadata is shared by all tenants.

具体地,定制阶段中,租户在初始业务实体元数据基础上,按照领域知识对初始业务实体元数据进行定制,通过修改初始列信息,增加自定义列信息生成租户特定业务实体元数据。Specifically, in the customization phase, the tenant customizes the initial business entity metadata based on domain knowledge based on the initial business entity metadata, and generates tenant-specific business entity metadata by modifying the initial column information and adding custom column information.

租户1为某教育机构,根据业务需求,将CRM对应的实体名称改为“学生”;初始业务实体元数据中“USER_NAME”列所对应的属性标签改为“学生姓名”,“USER_ID”对应属性标签改为“学号”;为业务实体“学生”增加属性“年级”,并定义对应自定义列,通过以上定制,租户1生成自定义业务实体元数据如表3所示:Tenant 1 is an educational institution. According to business requirements, the entity name corresponding to CRM is changed to "student"; the attribute label corresponding to the "USER_NAME" column in the initial business entity metadata is changed to "student name", and the corresponding attribute of "USER_ID" Change the label to "student number"; add the attribute "grade" to the business entity "student", and define the corresponding custom column. Through the above customization, tenant 1 generates the metadata of the custom business entity, as shown in Table 3:

表3租户1生成的自定义业务实体元数据Table 3 Custom business entity metadata generated by tenant 1

租户2为某公司用户,根据业务需求,将CRM对应的实体名称改为“员工”;初始业务实体元数据中“USER_NAME”列所对应的属性标签改为“员工姓名”,“USER_ID”对应属性标签改为“员工号”;为业务实体“员工”增加属性“部门”,并定义对应自定义列,通过以上定制,租户2生成自定义业务实体元数据如表4所示:Tenant 2 is a company user. According to business requirements, change the entity name corresponding to CRM to "employee"; the attribute label corresponding to the "USER_NAME" column in the initial business entity metadata is changed to "employee name", and the corresponding attribute of "USER_ID" Change the label to "employee number"; add the attribute "department" to the business entity "employee", and define the corresponding custom column. Through the above customization, tenant 2 generates the metadata of the custom business entity, as shown in Table 4:

表4租户2生成的自定义业务实体元数据Table 4 Custom business entity metadata generated by tenant 2

根据租户1和租户2生成的自定义业务实体元数据,我们可以定义若干个类似的自定义业务实体元数据,同样我们假设租户N为某企业管理层人员,根据业务需求,将CRM对应的实体名称改为“经理”;初始业务实体元数据中“USER_NAME”列所对应的属性标签改为“管理员”,“USER_ID”对应属性标签改为“管理员号”;为业务实体“员工”增加属性“部门”,并定义对应自定义列,通过以上定制,租户N生成自定义业务实体元数据如表5所示:According to the custom business entity metadata generated by tenant 1 and tenant 2, we can define several similar custom business entity metadata. Similarly, we assume that tenant N is a management personnel of an enterprise, and according to business needs, the entity corresponding to CRM The name is changed to "manager"; the attribute label corresponding to the "USER_NAME" column in the initial business entity metadata is changed to "administrator", and the attribute label corresponding to "USER_ID" is changed to "administrator number"; the business entity "employee" is added Attribute "department" and define the corresponding custom columns. Through the above customization, tenant N generates custom business entity metadata as shown in Table 5:

表5租户N生成的自定义业务实体元数据Table 5 Custom business entity metadata generated by tenant N

在所述生成实例阶段中,所述方法还包括:During the generating instance phase, the method further includes:

所述扩展业务属性用于满足所述租户的不同业务需求,并且同时生成与新增的业务属性对应的扩展列,所述的扩展列仅对所述租户可见。The extended service attributes are used to meet the different service requirements of the tenants, and at the same time, an extended column corresponding to the newly added service attribute is generated, and the extended column is only visible to the tenant.

不同租户采用相同初始业务实体元数据扩展后生成实例共享同一数据库表,初始业务实体元数据对应的列为所有租户共享;同时,根据租户生成的特定业务实体的自定义属性为租户添加自定义扩展列,自定义扩展列只由该租户可见。某租户添加自定义列后,只有该租户在该列添加数据,由于Key-Value数据库的稀疏列存储特性,其他租户并不存在该租户自定义列的数据,也不占用任何多余空间。此时租户1业务实体“学生”,租户2业务实体“员工”和租户N业务实体“管理员”共享的Key-Value数据库表CRM结构自动扩展成表6:Different tenants use the same initial business entity metadata extension to generate instances to share the same database table, and the columns corresponding to the initial business entity metadata are shared by all tenants; at the same time, add custom extensions for tenants according to the custom attributes of specific business entities generated by tenants Columns, custom extension columns are only visible by this tenant. After a tenant adds a custom column, only the tenant adds data to the column. Due to the sparse column storage feature of the Key-Value database, other tenants do not have the data in the tenant's custom column and do not occupy any extra space. At this time, the Key-Value database table CRM structure shared by tenant 1 business entity "student", tenant 2 business entity "employee" and tenant N business entity "administrator" is automatically expanded into table 6:

表6Key-Value数据库表CRM结构扩展表Table 6 Key-Value database table CRM structure extension table

步骤104、实例运行阶段,以租户标识作为RowKey前缀插入到Key-Value数据库的业务实体数据,通过所述租户标识生成RowKey的查询范围查询业务实体数据,在所述查询范围内从所述Key-Value数据库中取出业务实体数据,按照所述特定业务实体元数据生成交互界面,以便将所述业务实体数据展示。Step 104, in the instance running phase, insert the tenant ID as the RowKey prefix into the business entity data of the Key-Value database, query the business entity data through the query range of the RowKey generated by the tenant ID, and start from the Key-Value within the query range. The business entity data is fetched from the Value database, and an interactive interface is generated according to the metadata of the specific business entity so as to display the business entity data.

所述通过所述租户标识生成RowKey的查询范围查询业务实体数据具体包括:查询所述Key-Value数据库,根据所述租户的标识和所述业务实体的表名设定查询范围,在所述设定的查询范围内,根据用户设定的查询条件进行查询获取所述业务实体数据。The querying service entity data by generating the query range of the RowKey generated by the tenant ID specifically includes: querying the Key-Value database, setting the query range according to the tenant ID and the table name of the business entity, and setting Within the specified query scope, query and obtain the business entity data according to the query conditions set by the user.

在实例运行阶段,以租户标识作为所有业务实体数据的RowKey前缀插入Key-Value数据库,通过所述租户标识生成RowKey查询范围从Key-Value数据库取出业务实体数据,按照定制后的所述特定业务实体元数据生成交互界面。In the instance running phase, insert the tenant ID as the RowKey prefix of all business entity data into the Key-Value database, generate the RowKey query scope through the tenant ID, and take out the business entity data from the Key-Value database, according to the customized specific business entity Metadata generation interface.

所述按照所述特定业务实体元数据生成交互界面具体包括:The generating the interactive interface according to the specific business entity metadata specifically includes:

根据所述租户的标识获取所述租户的特定业务实体元数据;Obtaining the specific business entity metadata of the tenant according to the identifier of the tenant;

根据所述租户的特定业务实体元数据的索引列信息和数据类型生成查询项;generating query items according to the index column information and data types of the tenant's specific business entity metadata;

根据所述租户的特定业务实体元数据中的显示标签和业务实体数据显示查询结果;displaying query results according to display tags and business entity data in the tenant-specific business entity metadata;

根据所述租户的特定业务实体元数据的业务实体的显示标签、业务实体的属性显示标签和业务实体的数据类型生成新建页面的新建项。The new item of the new page is generated according to the display label of the business entity, the attribute display label of the business entity, and the data type of the business entity in the metadata of the specific business entity of the tenant.

所述以租户标识作为RowKey前缀插入到Key-Value数据库的业务实体数据具体还包括:采用所述租户的标识+所述业务实体的表名作为所述业务实体数据的RowKey前缀。The inserting the business entity data into the Key-Value database with the tenant ID as the RowKey prefix specifically further includes: using the tenant ID + the table name of the business entity as the RowKey prefix of the business entity data.

通过租户标识“Tenant001”获取业务实体“学生”元数据,通过该元数据的业务实体属性显示标签和数据类型生成新建或修改页面的内容及其样式。填写完整用户信息,数据插入Key-Value数据库。插入数据时,采用“租户标识+库表名称”作为该条数据RowKey的前缀,如“Tenant001CRMStudent001”。同理,通过租户2表示“Tenant002”获取业务实体“员工”后生成新建或修改页面,同时插入员工“Tenant002CRMEmployee001”,租户N也同样如此。此时CRM库表中的数据如表7所示,其中BASE代表初始业务元数据结构表,CUSTOM代表扩展业务元数据结构表:Obtain the metadata of the business entity "student" through the tenant ID "Tenant001", and generate the content and style of the newly created or modified page through the business entity attribute display label and data type of the metadata. Fill in the complete user information, and insert the data into the Key-Value database. When inserting data, use "tenant ID + library table name" as the prefix of the data RowKey, such as "Tenant001CRMStudent001". Similarly, tenant 2 represents "Tenant002" to obtain the business entity "employee" to generate a new or modify page, and at the same time insert employee "Tenant002CRMEmployee001", the same is true for tenant N. At this time, the data in the CRM library table is shown in Table 7, where BASE represents the initial business metadata structure table, and CUSTOM represents the extended business metadata structure table:

表7CRM库表数据Table 7 CRM database table data

RowKeyRowKey List Tenant001CRMStudent001Tenant001CRMStudent001 BASE:USER_ID:Student001BASE:USER_ID:Student001 Tenant001CRMStudent001Tenant001CRMStudent001 BASE:USER_NAME:王小二BASE: USER_NAME: Wang Xiaoer Tenant001CRMStudent001Tenant001CRMStudent001 BASE:USER_EMAIL:wangxe@stu.comBASE:USER_EMAIL:wangxe@stu.com Tenant001CRMStudent001Tenant001CRMStudent001 CUSTOM:STUDENT_LEVEL:1CUSTOM:STUDENT_LEVEL:1 Tenant002CRMEmployee001Tenant002CRMEmployee001 BASE:USER_ID:Employee001BASE:USER_ID:Employee001 Tenant002CRMEmployee001Tenant002CRMEmployee001 BASE:USER_NAME:李杜BASE: USER_NAME: Li Du Tenant002CRMEmployee001Tenant002CRMEmployee001 BASE:USER_EMAIL:lid@company.comBASE:USER_EMAIL:lid@company.com Tenant002CRMEmployee001Tenant002CRMEmployee001 CUSTOM:DEPARTMENT:研发CUSTOM:DEPARTMENT:Development

进入查询页面时,利用租户1标识“Tenant001”得到业务实体“学生”元数据,在元数据中获得所有索引项生成查询页面,索引项显示标签包括“学生姓名”、“邮箱”、“年级”。查询结果显示自定义业务实体所有属性,包括“学号”、“学生姓名”、“邮箱”、“年级”。同理,利用租户2标识“Tenant002”得到业务实体“员工”元数据,在元数据中获得所有索引项生成查询页面,索引项显示标签包括“员工姓名”、“邮箱”、“部门”。查询结果显示自定义业务实体所有属性,包括“员工号”、“员工姓名”、“邮箱”、“部门”。当查询某租户库表数据时,根据租户标识和库表名称设定查询范围,在该范围内根据用户设定的查询条件进行查询获得数据,具体来说,采用“租户标识+库表名称”设定为StartRow,将StartRow加一设定为EndRow,该租户在库表中的所有数据即在此范围内,这样使得租户的查询速度只和该租户自己的数据量有关,而和其他租户数据量无关。这种情况下,查询租户1业务实体“学生”数据时,设定StartRow为“Tenant001CRM”,EndRow为“Tenant 001CRN”,设定范围后,查询租户1数据只需在该范围内匹配查询条件即可,而不需要扫描整个数据库表。When entering the query page, use the tenant 1 identifier "Tenant001" to get the metadata of the business entity "student", and get all the index items in the metadata to generate the query page. The index item display labels include "student name", "email", "grade" . The query result displays all attributes of the custom business entity, including "Student ID", "Student Name", "Email", and "Grade". Similarly, use the tenant 2 identifier "Tenant002" to obtain the metadata of the business entity "employee", and obtain all index items in the metadata to generate a query page. The index item display labels include "employee name", "email", and "department". The query result displays all attributes of the custom business entity, including "Employee ID", "Employee Name", "Email", and "Department". When querying the database table data of a certain tenant, set the query range according to the tenant ID and database table name, and within this range, query and obtain data according to the query conditions set by the user. Specifically, use "tenant ID + database table name" Set it to StartRow, set StartRow plus one to EndRow, all the data of the tenant in the database table is within this range, so that the query speed of the tenant is only related to the amount of data of the tenant itself, and not to other tenant data Quantity is irrelevant. In this case, when querying tenant 1 business entity "student" data, set StartRow to "Tenant001CRM" and EndRow to "Tenant 001CRN". After setting the range, query tenant 1 data only needs to match the query conditions within the range. Yes, without scanning the entire database table.

具体地,在实例运行阶段,当租户1业务需求发生改变时,如需要为业务实体“学生”增加属性“专业”,则只需在数据库模板中增加该属性的信息和自定义列名即可,不需要做任何额外定制开发或部署。当运营商租户增加导致服务器容量不够时,只需为分布式Key-Value数据库增加服务器即可,不需要做额外的数据迁移。Specifically, in the instance running phase, when tenant 1's business requirements change, if it is necessary to add the attribute "professional" to the business entity "student", you only need to add the information of the attribute and the custom column name in the database template. , without any additional custom development or deployment. When the server capacity is insufficient due to the increase of operator tenants, it is only necessary to add servers for the distributed Key-Value database without additional data migration.

综上所述,本发明提出了一种基于键-值数据库的多租户扩展方法,该方法在定制阶段,在初始元数据基础上按照领域知识扩展业务实体,并定义业务实体及其属性的显示标签,生成满足租户不同业务需求的特定元数据;在生成实例阶段,根据用户扩展的业务实体元数据,为租户创建Key-Value数据库;在实例运行阶段,租户向数据库插入业务数据时,以“租户标识+库表名称”为前缀生成业务数据RowKey,通过获得租户的特定业务实体元数据生成交互界面,通过RowKey设定查询范围从数据库取出业务数据并显示。本发明支持通过定制生成满足租户个性化需求的应用,对于业务流程相似的业务可以避免重复开发,同时采用共享的Key-Value数据库方便实现扩展,降低运营成本。To sum up, the present invention proposes a multi-tenant extension method based on a key-value database. In the customization stage, the method expands business entities according to domain knowledge on the basis of initial metadata, and defines the display of business entities and their attributes. label to generate specific metadata that meets the different business needs of tenants; in the instance generation phase, a Key-Value database is created for the tenant based on the business entity metadata extended by the user; in the instance running phase, when the tenant inserts business data into the database, the " Tenant ID + library table name" is used as a prefix to generate business data RowKey, and an interactive interface is generated by obtaining tenant-specific business entity metadata, and business data is retrieved from the database and displayed by setting the query range through RowKey. The invention supports customized generation of applications that meet the individual needs of tenants, avoids repeated development for businesses with similar business processes, and uses a shared Key-Value database to facilitate expansion and reduce operating costs.

专业人员应该还可以进一步意识到,结合本文中所公开的实施例描述的各示例的单元及算法步骤,能够以电子硬件、计算机软件或者二者的结合来实现,为了清楚地说明硬件和软件的可互换性,在上述说明中已经按照功能一般性地描述了各示例的组成及步骤。这些功能究竟以硬件还是软件方式来执行,取决于技术方案的特定应用和设计约束条件。专业技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本发明实施例的范围。Professionals should further realize that the units and algorithm steps described in conjunction with the embodiments disclosed herein can be implemented by electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the relationship between hardware and software Interchangeability. In the above description, the composition and steps of each example have been generally described according to their functions. Whether these functions are executed by hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art may use different methods to implement the described functions for each specific application, but such implementation should not be regarded as exceeding the scope of the embodiments of the present invention.

结合本文中所公开的实施例描述的方法或算法的步骤可以用硬件、处理器执行的软件模块,或者二者的结合来实施。软件模块可以置于随机存储器(RAM)、内存、只读存储器(ROM)、电可编程ROM、电可擦除可编程ROM、寄存器、硬盘、可移动磁盘、CD-ROM、或技术领域内所公知的任意其它形式的存储介质中。The steps of the methods or algorithms described in connection with the embodiments disclosed herein may be implemented by hardware, software modules executed by a processor, or a combination of both. Software modules can be placed in random access memory (RAM), internal memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, removable disk, CD-ROM, or any other Any other known storage medium.

以上所述的具体实施方式,对本发明实施例的、技术方案和有益效果进行了进一步详细说明,所应理解的是,以上所述仅为本发明实施例的具体实施方式而已,并不用于限定本发明实施例的保护范围,凡在本发明实施例的精神和原则之内,所做的任何修改、等同替换、改进等,均应包含在本发明实施例的保护范围之内。The specific implementation manners described above further describe the technical solutions and beneficial effects of the embodiments of the present invention in detail. It should be understood that the above descriptions are only specific implementation modes of the embodiments of the present invention and are not intended to limit Within the protection scope of the embodiments of the present invention, any modifications, equivalent replacements, improvements, etc. made within the spirit and principle of the embodiments of the present invention shall be included in the protection scope of the embodiments of the present invention.

Claims (2)

1.一种基于键-值数据库的多租户扩展方法,其特征在于,所述方法包括:1. A multi-tenant extension method based on a key-value database, characterized in that the method comprises: 获取初始业务实体元数据;Get initial business entity metadata; 定制阶段,在所述初始业务实体元数据上扩展业务属性,对所述业务属性定义业务实体和显示标签,生成满足多租户需求的特定业务实体元数据;In the customization stage, business attributes are extended on the initial business entity metadata, business entities and display labels are defined for the business attributes, and specific business entity metadata meeting multi-tenant requirements are generated; 生成实例阶段,根据所述特定业务实体元数据,创建键-值Key-Value数据库;In the instance generation phase, a key-value Key-Value database is created according to the metadata of the specific business entity; 实例运行阶段,以租户标识作为RowKey前缀插入到Key-Value数据库的业务实体数据,通过所述租户标识生成RowKey的查询范围查询业务实体数据,在所述查询范围内从所述Key-Value数据库中取出业务实体数据,按照所述特定业务实体元数据生成交互界面,以便将所述业务实体数据展示;In the instance running phase, the business entity data is inserted into the Key-Value database with the tenant ID as the RowKey prefix, and the business entity data is queried within the query range of the RowKey generated by the tenant ID, and the Key-Value database is retrieved within the query range Take out the business entity data, and generate an interactive interface according to the specific business entity metadata, so as to display the business entity data; 在所述生成实例阶段中,所述方法还包括:During the generating instance phase, the method further includes: 所有租户共享一个所述Key-Value数据库,所述初始业务实体元数据对应的列为所有租户共享;All tenants share one Key-Value database, and the column corresponding to the initial business entity metadata is shared by all tenants; 在所述生成实例阶段中,所述方法还包括:During the generating instance phase, the method further includes: 所述扩展业务属性用于满足所述租户的不同业务需求,并且同时生成与新增的业务属性对应的扩展列,所述的扩展列仅对所述租户可见;The extended business attributes are used to meet the different business requirements of the tenants, and at the same time generate extended columns corresponding to the newly added business attributes, and the extended columns are only visible to the tenants; 所述通过所述租户标识生成RowKey的查询范围查询业务实体数据具体包括:查询所述Key-Value数据库,根据所述租户的标识和所述业务实体的表名设定查询范围,在所述设定的查询范围内,根据用户设定的查询条件进行查询获取所述业务实体数据;The querying service entity data by generating the query range of the RowKey generated by the tenant ID specifically includes: querying the Key-Value database, setting the query range according to the tenant ID and the table name of the business entity, and setting Within the specified query scope, query and obtain the business entity data according to the query conditions set by the user; 所述按照所述特定业务实体元数据生成交互界面具体包括:The generating the interactive interface according to the specific business entity metadata specifically includes: 根据所述租户的标识获取所述租户的特定业务实体元数据;Obtaining the specific business entity metadata of the tenant according to the identifier of the tenant; 根据所述租户的特定业务实体元数据的索引列信息和数据类型生成查询项;generating query items according to the index column information and data types of the tenant's specific business entity metadata; 根据所述租户的特定业务实体元数据中的显示标签和业务实体数据显示查询结果;displaying query results according to display tags and business entity data in the tenant-specific business entity metadata; 根据所述租户的特定业务实体元数据的业务实体的显示标签、业务实体的属性显示标签和业务实体的数据类型生成新建页面的新建项;Generate a new item on the new page according to the display label of the business entity of the specific business entity metadata of the tenant, the attribute display label of the business entity, and the data type of the business entity; 所述以租户标识作为RowKey前缀插入到Key-Value数据库的业务实体数据具体还包括:采用所述租户的标识+所述业务实体的表名作为所述业务实体数据的RowKey前缀;The business entity data inserted into the Key-Value database with the tenant ID as the RowKey prefix specifically further includes: using the tenant ID + the table name of the business entity as the RowKey prefix of the business entity data; 在定制阶段,租户在初始业务实体元数据基础上,按照领域知识对初始业务实体元数据进行定制,通过修改初始列信息,增加自定义列信息生成租户特定业务实体元数据。In the customization phase, the tenant customizes the initial business entity metadata based on domain knowledge based on the initial business entity metadata, and generates tenant-specific business entity metadata by modifying the initial column information and adding custom column information. 2.根据权利要求1所述的基于键-值数据库的多租户扩展方法,其特征在于,所述初始业务实体元数据和所述特定业务实体元数据均至少包括:业务实体的表名、业务实体的显示标签、业务实体的属性列名、业务实体的数据类型、业务实体的索引列标识和业务实体的属性显示标签。2. The multi-tenant extension method based on key-value database according to claim 1, characterized in that, the metadata of the initial business entity and the metadata of the specific business entity at least include: the table name of the business entity, the business The display label of the entity, the attribute column name of the business entity, the data type of the business entity, the index column ID of the business entity, and the attribute display label of the business entity.
CN201410771826.8A 2014-12-12 2014-12-12 Multi-tenant extended method based on key-value database Active CN104462421B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201410771826.8A CN104462421B (en) 2014-12-12 2014-12-12 Multi-tenant extended method based on key-value database

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201410771826.8A CN104462421B (en) 2014-12-12 2014-12-12 Multi-tenant extended method based on key-value database

Publications (2)

Publication Number Publication Date
CN104462421A CN104462421A (en) 2015-03-25
CN104462421B true CN104462421B (en) 2018-06-05

Family

ID=52908456

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201410771826.8A Active CN104462421B (en) 2014-12-12 2014-12-12 Multi-tenant extended method based on key-value database

Country Status (1)

Country Link
CN (1) CN104462421B (en)

Families Citing this family (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105824763B (en) * 2015-11-16 2019-05-17 广东亿迅科技有限公司 A kind of buffer service implementation method
CN105631019A (en) * 2015-12-29 2016-06-01 畅捷通信息技术股份有限公司 Metadata extension method and device
CN106202540A (en) * 2016-07-26 2016-12-07 浪潮通用软件有限公司 Database horizontal expansion method of large application system
CN106469224A (en) * 2016-09-26 2017-03-01 武汉工程大学 A kind of expansible data model for SaaS platform
US11500836B2 (en) * 2017-06-27 2022-11-15 Salesforce, Inc. Systems and methods of creation and deletion of tenants within a database
CN108446363B (en) * 2018-03-13 2021-05-25 北京奇安信科技有限公司 Data processing method and device of KV engine
CN111126876A (en) * 2019-12-31 2020-05-08 亚信科技(中国)有限公司 Method and device for realizing service configuration based on plug-in technology
CN112069210A (en) * 2020-08-21 2020-12-11 北京首汽智行科技有限公司 Saas platform multi-tenant data isolation method
CN112597169A (en) * 2020-12-30 2021-04-02 山东恒远智能科技有限公司 Method for realizing industrial software multi-tenant data isolation
CN112883300B (en) * 2021-02-02 2022-08-30 广州华多网络科技有限公司 Function label customizing method and device, equipment and medium thereof
CN114564734B (en) * 2022-03-01 2025-09-19 浪潮云信息技术股份公司 SM3 state secret-based database table data isolation method and system

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101777057A (en) * 2004-04-02 2010-07-14 易享信息技术(上海)有限公司 Methods and systems for storing customer fields for multiple tenants in multi-tenant database system
CN102200977A (en) * 2010-03-23 2011-09-28 国际商业机器公司 Method and system for extending database table under multi-tenant environment

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20070255741A1 (en) * 2006-04-28 2007-11-01 Business Objects, S.A. Apparatus and method for merging metadata within a repository

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101777057A (en) * 2004-04-02 2010-07-14 易享信息技术(上海)有限公司 Methods and systems for storing customer fields for multiple tenants in multi-tenant database system
CN102200977A (en) * 2010-03-23 2011-09-28 国际商业机器公司 Method and system for extending database table under multi-tenant environment

Also Published As

Publication number Publication date
CN104462421A (en) 2015-03-25

Similar Documents

Publication Publication Date Title
CN104462421B (en) Multi-tenant extended method based on key-value database
US10180992B2 (en) Atomic updating of graph database index structures
Li Transforming relational database into HBase: A case study
CN111708805B (en) Data query method, device, electronic device and storage medium
US20150205885A1 (en) CREATING NoSQL DATABASE INDEX FOR SEMI-STRUCTURED DATA
US20170255708A1 (en) Index structures for graph databases
CN103176989B (en) Data base's table level comparative approach based on data dictionary and variable rules and system
Zhang et al. An implementation approach to store GIS spatial data on NoSQL database
US20180357329A1 (en) Supporting tuples in log-based representations of graph databases
CN104102710A (en) Massive data query method
CN105900093B (en) A method for updating a data table of a KeyValue database and a device for updating table data
US9235613B2 (en) Flexible partitioning of data
JP2015531126A (en) Method and apparatus for realizing product characteristic navigation
CN104346466A (en) Method and device of adding new attribute data in database
CN104239532A (en) Method and device for self-making user extraction information tool in Hive
US8903797B2 (en) System and method for loading objects for object-relational mapping
US20180357278A1 (en) Processing aggregate queries in a graph database
CN115203435A (en) Entity relation generation method and data query method based on knowledge graph
CN107463695A (en) A kind of method and device of data storage
CN106156075B (en) A kind of method and device of report generation and displaying
CN116561074A (en) Method, device, computer equipment and storage medium for grouping resource data
US20180357328A1 (en) Functional equivalence of tuples and edges in graph databases
CN113886505B (en) Management system for realizing dynamic modeling based on search engine and relational database
US20070282804A1 (en) Apparatus and method for extracting database information from a report
CN111143329B (en) Data processing method and device

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
TR01 Transfer of patent right

Effective date of registration: 20210813

Address after: 100190, No. 21 West Fourth Ring Road, Beijing, Haidian District

Patentee after: INSTITUTE OF ACOUSTICS, CHINESE ACADEMY OF SCIENCES

Address before: 100190 Institute of acoustics, Chinese Academy of Sciences, No. 21 West Fourth Ring Road, Haidian District, Beijing

Patentee before: INSTITUTE OF ACOUSTICS, CHINESE ACADEMY OF SCIENCES

Patentee before: BEIJING INTELLIX TECHNOLOGIES Co.,Ltd.

Effective date of registration: 20210813

Address after: Room 1601, 16th floor, East Tower, Ximei building, No. 6, Changchun Road, high tech Industrial Development Zone, Zhengzhou, Henan 450001

Patentee after: Zhengzhou xinrand Network Technology Co.,Ltd.

Address before: 100190, No. 21 West Fourth Ring Road, Beijing, Haidian District

Patentee before: INSTITUTE OF ACOUSTICS, CHINESE ACADEMY OF SCIENCES

TR01 Transfer of patent right