CN112905630A - Data manipulation method, server, and computer-readable medium - Google Patents
Data manipulation method, server, and computer-readable medium Download PDFInfo
- Publication number
- CN112905630A CN112905630A CN202110351973.XA CN202110351973A CN112905630A CN 112905630 A CN112905630 A CN 112905630A CN 202110351973 A CN202110351973 A CN 202110351973A CN 112905630 A CN112905630 A CN 112905630A
- Authority
- CN
- China
- Prior art keywords
- tenant
- data
- database
- request
- query statement
- 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.)
- Pending
Links
- 238000000034 method Methods 0.000 title claims abstract description 48
- 238000013523 data management Methods 0.000 claims abstract description 15
- 238000002955 isolation Methods 0.000 claims description 23
- 238000013507 mapping Methods 0.000 claims description 9
- 238000004590 computer program Methods 0.000 claims description 5
- 238000003860 storage Methods 0.000 abstract description 13
- 238000012423 maintenance Methods 0.000 abstract description 9
- 238000011161 development Methods 0.000 abstract description 7
- 238000004891 communication Methods 0.000 description 12
- 238000010586 diagram Methods 0.000 description 10
- 238000007726 management method Methods 0.000 description 6
- 238000012986 modification Methods 0.000 description 4
- 230000004048 modification Effects 0.000 description 4
- 230000002085 persistent effect Effects 0.000 description 4
- 238000012545 processing Methods 0.000 description 4
- 230000007246 mechanism Effects 0.000 description 3
- 230000008569 process Effects 0.000 description 3
- 230000006978 adaptation Effects 0.000 description 2
- 238000003491 array Methods 0.000 description 2
- 238000006243 chemical reaction Methods 0.000 description 2
- 230000006872 improvement Effects 0.000 description 2
- 229940004975 interceptor Drugs 0.000 description 2
- 230000003287 optical effect Effects 0.000 description 2
- 238000012546 transfer Methods 0.000 description 2
- 238000013500 data storage Methods 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 230000006870 function Effects 0.000 description 1
- 230000014509 gene expression Effects 0.000 description 1
- 238000009434 installation Methods 0.000 description 1
- 230000002452 interceptive effect Effects 0.000 description 1
- 238000004519 manufacturing process Methods 0.000 description 1
- 238000002360 preparation method Methods 0.000 description 1
- 230000002441 reversible effect Effects 0.000 description 1
- 238000000926 separation method Methods 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
- 238000012795 verification Methods 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/24—Querying
- G06F16/242—Query formulation
- G06F16/2433—Query languages
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/23—Updating
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- Data Mining & Analysis (AREA)
- Databases & Information Systems (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Mathematical Physics (AREA)
- Computational Linguistics (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The application provides a data operation method, a server and a computer readable storage medium. The method comprises the following steps: receiving a data operation request; analyzing a token from the data operation request, and acquiring a corresponding tenant ID according to the token; placing the tenant ID in the context of the execution thread; constructing a corresponding database query statement based on the data operation request; acquiring and analyzing a database query statement, and confirming that a corresponding database table has a tenant ID field; acquiring a tenant ID from the context of the execution thread based on the data addition request and setting the tenant ID into a tenant ID attribute of a database table, or splicing a tenant ID field into a query condition of a database query statement based on the data updating request or the data reading request; a database driver is invoked to execute a database query statement. The method realizes data operation in the multi-tenant isolated data management system which distinguishes the tenants according to the tenant ID fields with lower acquisition cost, maintenance cost and development cost.
Description
Technical Field
The present application relates to the field of database technologies, and in particular, to a data operation method, a server, and a computer-readable storage medium.
Background
In the SaaS business system, the SaaS system running on one or a set of servers can provide services for a plurality of tenants (customers), which use the same set of programs in an internet environment. The tenant data is stored in a centralized manner, so that data isolation among tenants needs to be realized to ensure the security of the data.
Providing an independent database for each tenant is one of the data isolation solutions of the SaaS multi-tenant system. The scheme has the advantages that the user data isolation level is highest, unique requirements of different tenants can be met, the safety is best, and the technical difficulty is low. However, the scheme increases the installation quantity of the database, the maintenance workload is large, the tenant opening time is long, and the application program needs to be deployed more, so that the implementation cost is highest.
Providing an independent table space for each tenant is another data isolation solution for SaaS multi-tenant systems. The implementation mode of the scheme is that all tenants share the same application, the application back end is only connected with one database system, all tenants share the database system, and each tenant has an independent table space in the database system. That is, data of different tenants is stored under the same database, but uses different tables. The scheme provides a certain degree of logic data isolation, one database system can support a plurality of tenants, and the isolation level is high and the technical difficulty is low. However, the scheme has the disadvantages of large maintenance workload, long tenant opening time, more deployment of application programs and higher implementation cost.
Therefore, how to reduce the acquisition cost, the maintenance cost and the development cost of the multi-tenant isolated data management system is a problem that needs to be solved urgently by those skilled in the art.
Disclosure of Invention
The technical problem to be solved by the application is to provide a data operation method, a server and a computer readable storage medium, which can reduce the acquisition cost, the maintenance cost and the development cost of a multi-tenant isolated data management system.
In order to solve the above technical problem, the present application provides a data operation method, which is applicable to a data management system with multi-tenant isolation, and the method includes: receiving a data operation request sent by a client, wherein the data operation request is a data adding request, a data updating request or a data reading request and comprises data to be operated and a token of a requester; analyzing the token from the data operation request, and acquiring a tenant ID corresponding to the requester according to the token; placing the tenant ID in a context of an execution thread; constructing a database query statement corresponding to the data operation request based on the data operation request, wherein the database query statement comprises the data to be operated; acquiring and analyzing the database query statement, and confirming that a database table corresponding to the data operation request has a tenant ID field according to the database query statement; when the data operation request is the data addition request, acquiring the tenant ID from the context of the execution thread based on the data addition request and setting the tenant ID into the tenant ID attribute of the database table; when the data operation request is the data updating request or the data reading request, the tenant ID field is spliced into the query condition of the database query statement based on the data updating request or the data reading request; and invoking a database driver to execute the database query statement.
In an embodiment of the application, before the step of obtaining and parsing the database query statement, the method further includes: calling a preset actuator; and the executor calls the interceptor; the step of acquiring and analyzing the database query statement, and confirming that the database table corresponding to the data operation request has a tenant ID field according to the database query statement, and the step of acquiring the tenant ID from the context of the execution thread based on the data addition request and setting the tenant ID into the tenant ID attribute of the database table, or splicing the tenant ID field into the query condition of the database query statement based on the data updating request or the data reading request are executed by the interceptor.
In an embodiment of the application, before the step of invoking the preset executor, the method further includes: calling an ORM framework; the step of calling a preset executor is executed by the ORM framework; the executor and the interceptor belong to the ORM framework.
In an embodiment of the application, the database table corresponding to the data operation request is inherited from a preset basic object, and the basic object is applicable to a multi-tenant isolated data system based on an ORM framework.
In an embodiment of the application, the mapping relationship between the database table corresponding to the data operation request and the preset metadata is recorded by a preset object-relationship mapping object.
In an embodiment of the present application, the step of confirming that the database table corresponding to the data operation request has the tenant ID field according to the database query statement includes: and confirming that the metadata information of the database table has the tenant ID field according to the database query statement.
In an embodiment of the present application, the database driver is a Java database connection; the step of invoking a database driver to execute the database query statement comprises: and the executor calls a method corresponding to the data operation request in the Java database connection to execute the database query statement.
In an embodiment of the application, the step of invoking a database driver to execute the database query statement further includes:
and the Java database is connected with the executor and returns the execution result to the executor after executing the database query statement.
In order to solve the above technical problem, the present application provides a server for data management of multi-tenant isolation, where the server includes: a memory for storing instructions executable by the processor; and a processor for executing the instructions to implement the method as described above.
To solve the above technical problem, the present application provides a computer readable medium having stored thereon computer program code, which when executed by a processor implements the method as described above.
Compared with the prior art, the data operation method, the server and the computer readable storage medium obtain the tenant ID according to the token, then realize the transfer of the tenant ID through the context, and modify the database query statement related to the tenant ID, so that the data operation of the multi-tenant isolated data management system for distinguishing tenants according to the tenant ID field is realized with lower acquisition cost, maintenance cost and development cost.
Drawings
The accompanying drawings, which are included to provide a further understanding of the application and are incorporated in and constitute a part of this application, illustrate embodiment(s) of the application and together with the description serve to explain the principle of the application. In the drawings:
fig. 1 is a schematic structural diagram illustrating a multi-tenant isolated data management system according to an embodiment of the present application.
Fig. 2 is a schematic flow chart diagram illustrating a data adding and updating method according to an embodiment of the present application.
FIG. 3 is a diagram of a common object inheritance architecture provided in accordance with an embodiment of the present application.
Fig. 4 is a schematic diagram of unified memory metadata management according to an embodiment of the present application.
Fig. 5 is a schematic block diagram illustrating a server according to an embodiment of the present application.
Detailed Description
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings used in the description of the embodiments will be briefly introduced below. It is obvious that the drawings in the following description are only examples or embodiments of the application, from which the application can also be applied to other similar scenarios without inventive effort for a person skilled in the art. Unless otherwise apparent from the context, or otherwise indicated, like reference numbers in the figures refer to the same structure or operation.
As used in this application and the appended claims, the terms "a," "an," "the," and/or "the" are not intended to be inclusive in the singular, but rather are intended to be inclusive in the plural unless the context clearly dictates otherwise. In general, the terms "comprises" and "comprising" merely indicate that steps and elements are included which are explicitly identified, that the steps and elements do not form an exclusive list, and that a method or apparatus may include other steps or elements.
The relative arrangement of the components and steps, the numerical expressions, and numerical values set forth in these embodiments do not limit the scope of the present application unless specifically stated otherwise. Meanwhile, it should be understood that the sizes of the respective portions shown in the drawings are not drawn in an actual proportional relationship for the convenience of description. Techniques, methods, and apparatus known to those of ordinary skill in the relevant art may not be discussed in detail but are intended to be part of the specification where appropriate. In all examples shown and discussed herein, any particular value should be construed as merely illustrative, and not limiting. Thus, other examples of the exemplary embodiments may have different values. It should be noted that: like reference numbers and letters refer to like items in the following figures, and thus, once an item is defined in one figure, further discussion thereof is not required in subsequent figures.
Flow charts are used herein to illustrate operations performed by systems according to embodiments of the present application. It should be understood that the preceding or following operations are not necessarily performed in the exact order in which they are performed. Rather, various steps may be processed in reverse order or simultaneously. Meanwhile, other operations are added to or removed from these processes.
The separation of tenants according to the tenant identification (also called tenant ID) field (also called row record isolation) is a data isolation solution for realizing the SaaS multi-tenant system with lower cost. The implementation mode of the scheme is that multiple tenants share the same database and the same table space, but data fields of TennantID (tenant ID) multiple tenants are added in the table. The scheme has the advantages of simple program deployment, small maintenance workload, short tenant opening time and the like, has lower maintenance and acquisition cost than the former two solutions, allows the number of the tenants supported by each database to be the maximum, and can provide services for the maximum tenants by the minimum servers. The scheme needs to have the identification of one tenant when writing one piece of data. So that the data of different tenants can be distinguished in the same table. However, this solution requires a system developer to pay attention to the details of SaaS data isolation to develop the solution, resulting in high development cost and high error susceptibility.
The application provides a data operation method, which is suitable for a data management system with multi-tenant isolation, in particular suitable for a SaaS (software as a service) multi-tenant isolation data management system for distinguishing tenants according to tenant ID (identity) fields.
Fig. 1 is a schematic structural diagram illustrating a multi-tenant isolated data management system according to an embodiment of the present application. As shown in fig. 1, the multi-tenant isolated data management system includes a client 101, an application server 102, and a Database (Database) 103.
The data isolation solution applied in the database 103 is to distinguish tenants (also called row record isolation) according to the tenant identification (also called tenant ID) field, and multiple tenants can share the same database and the same table space. The database needs to have a tenant identity every time the database writes one piece of data. So that the data of different tenants can be distinguished in the same table. When the tenant changes the data through the client, the tenant can only write and edit the data of the tenant, and the whole data reading isolation process is transparent to the user.
An application server (also called application server) 102 is interposed between the client 101 and the database 103. Communication of data information between the client 101 and the database 103 may be established through the application server 102. The application server 102 is responsible for receiving a data operation request from a client and performing corresponding operation on the database 103 according to the database operation request.
The communication connection between the client 101 and the application server 102 may be a wired and/or wireless network connection. Application server 102 may be communicatively coupled to multiple clients simultaneously. Alternatively, the client 101 may be in the same local area network as the application server 102, or may be in a different local area network.
In addition, a communication connection is also established between the application server 102 and the database 103, and the communication connection can be a wired or wireless network connection. Optionally, in deployment implementation, the application server 102 and the database 103 may be deployed on the same physical device, or may be deployed on different physical devices. When the application server 102 and the database 103 are deployed on different physical devices, they may be deployed in the same local area network or in different local area networks.
The client 101 may be seen as an interactive interface provided by the database 103 towards the user, allowing the user to access the database 103 through the client 101. When a user needs to access the database 103, or when the client 101 has a database access requirement, the client 101 may send a database access request to the application server 102; the application server 102 may perform corresponding operations on the database 103 according to the database access request.
In one database data manipulation scenario, a client 101 may send a data manipulation request to an application server 102. The application server 102 performs corresponding data operation on the database 103 through a database query statement according to the received data operation request. The data operation request may be a data addition request, a data update request, or a data read request.
In an embodiment of the present application, the data operation method of the present application may be implemented on an application server, and executed by an application service running on the application server. An ORM (Object Relational Mapping) framework may be included in the application service, and the ORM framework may operate in an application service execution thread. In one embodiment of the present application, the ORM framework may be MyBatis.
Before implementing the data operation method of the present application, the application service running on the application server may perform one or more of the following basic preparations: the system comprises a public object inheritance system, unified memory metadata management, unified context management and a database query statement execution interception mechanism.
In a common object inheritance hierarchy, there may be one or more base objects. FIG. 3 is a diagram of a common object inheritance architecture provided in accordance with an embodiment of the present application. As shown in fig. 3, a base object BasePO (PO, persistent object) may be used to define a data table base object related to tenant isolation, and a tenent _ ID in the base object BasePO may be a tenant ID. The service data table (tent _ isolated _ business _ XXX _ PO) inherits the base object BasePO. The object inheritance system is a basis for object interception and writing of tenant IDs. And the object inheritance system can simply judge which objects need to be subjected to tenant isolation.
Unified memory metadata management means that, on the basis of a common object inheritance system, an application service can load all objects and field information of the objects into a memory in a starting process. Fig. 4 is a schematic diagram of unified memory metadata management according to an embodiment of the present application. The application service may record the mapping relationship between the Java object and the Table metadata in the memory through an oramapping object. Table is composed of columns, tables correspond to POs (persistent object) one by one, and fields correspond to attributes of POs one by one. As shown in fig. 4, the sqlName in Column may be the name of the field in the database; the JavaName may be the name of the field in the Java object; nullable means whether it can be null, and verification will be performed according to whether it is null when inserting, and an error will be reported if the Java object of the field that cannot be null lacks a value; defaultValue may be a default value, i.e., a default value that is filled in if no value is provided when a Java object is converted to a database query statement; the sqlType can be a type of a field in a database, and is convenient for type conversion of data; the JavaType can be a type of a field in a Java object, and type conversion of data is facilitated. The JavaName in the Table can be a fully qualified name of the Java type corresponding to the Table; the sqlName may be the name of a table in a database; comment may be a remark name that is tabulated in the database; columns may be the set of all fields under the table. In an example of a data addition request, the corresponding database query statement may be insert inter XXXX _ table (column 1, column2, column3, column4) values (value1, value2, value3, value 4). By recording the relationship between the persistent object type (Class) and the Table metadata, the Table and the database field in the Table can be obtained through the persistent object type, and the information can provide Table information and field information for insert and update statements. The upper layers of the ORM framework all manipulate data through Java objects. The actual type of ORMapping may be ConcurrentMap < Class <? Table >.
Unified context management refers to the fact that by transferring login information of a user (such as a token of the user) from an application entry to a thread variable of an application service execution thread, a context can be obtained from the thread variable at any time, and then a tenant ID is obtained from the context.
The database query statement execution interception mechanism refers to presetting an Executor (Executor) and an Interceptor (Interceptor). The executors and interceptors may be part of an ORM framework. The enforcers and interceptors may be mechanisms provided by the ORM framework. The executor may be used to execute the database query language translated by the ORM framework. The executor can be used for intercepting, and the interceptor can be executed after interception. The interceptor can acquire a database query statement (state), extract a database table from the database query statement, and determine whether the database table has a tenant ID field according to metadata information in the database table.
FIG. 2 is a schematic flow chart diagram illustrating a method of data manipulation according to an embodiment of the present application. As shown in fig. 2, the data manipulation method includes the following steps 201-207:
in step 201, when a requester performs a data operation at a client, the client sends a corresponding data operation request to an application server. The application service receives a data operation request sent by a client. The data operation request is a data adding request, a data updating request or a data reading request, and the data operation request comprises data to be operated and a token of a requester.
In step 202, the application service parses out the Token (Token) from the data operation request, and obtains the tenant id (tenantid) corresponding to the requester according to the Token. In one example, the application service may obtain user information including a tenant ID from a user profile according to the token and generate a Session. And the application service records Session information and maintains a mapping relation of Token- > Session. By acquiring the tenant ID from the token, the requester is enabled to perform data operations without providing the tenant ID.
In step 203, the application service puts the acquired tenant ID into the context of the application service execution thread. By putting the tenant ID into the context of the execution thread, the tenant ID in the context can be acquired at any time by the subsequent steps operating in the execution thread.
And step 204, the application service constructs a database query statement corresponding to the data operation request based on the data operation request, wherein the database query statement comprises the data to be operated. When the data operation request is a data adding request, the application service constructs an adding database query statement containing data to be operated based on the data adding request; when the data operation request is a data reading request, the application service constructs a reading database query statement containing data to be operated based on the data reading request; when the data operation request is a data updating request, the application service constructs an updating database query statement containing the data to be operated based on the data updating request.
In an embodiment of the present application, before the step 205 is described later, the method may further include the following steps 208 and 210:
at step 208, the application service calls the ORM framework.
In step 209, the ORM framework calls a default executor.
In an embodiment of the present application, the mapping relationship between the database table corresponding to the data operation request and the preset metadata may be recorded through a preset object-relationship mapping object. In an embodiment of the present application, the step of confirming that the database table corresponding to the data operation request has the tenant ID field according to the database query statement in step 205 may be specifically implemented by: and confirming that the metadata information of the database table has a tenant ID field according to the database query statement.
Step 206 can be divided into two cases. When the data operation request is a data addition request, the application service performs step 206 a: and acquiring the tenant ID from the context of the execution thread based on the data addition request and setting the tenant ID into the tenant ID attribute of the database table. By setting the tenant ID into the tenant ID attribute of the database table, the database in the subsequent step can isolate data according to the tenant ID when executing a database query language statement. When the data operation request is a data update request or a data read request, the application service performs step 206 b: and splicing the tenant ID field into the query condition of the database query statement based on the data updating request or the data reading request. By splicing the tenant ID field into the query condition of the database query statement, the data can be isolated according to the tenant ID when the database of the subsequent step executes the database query language statement. In one example, splicing the tenant ID field into the query conditions of the database query statement may refer to adding a condition related to the tenant ID (e.g., tenent _ ID ═ tenntid) in the where portion of the query statement. In an embodiment of the present application, step 206 may be performed by an interceptor.
In an embodiment of the present application, the database driver may be a Java database connection, and step 207 may include the following steps: and calling a method corresponding to the data operation request in Java Database connection (JDBC) to execute the Database query statement. In an embodiment of the present application, step 207 may further include the following steps: the Java database connection returns the execution result to the executor after executing the database query statement. JDBC does not belong to the ORM framework nor to the database.
In an embodiment of the present application, the steps 205-. The ORM framework may operate in an application service execution thread. In one embodiment of the present application, the ORM framework may be MyBatis. By using the ORM framework to encapsulate the steps, common application developers do not need to pay more attention to relevant details of data isolation, and development cost is reduced.
In summary, the data operation method of the present application obtains the tenant ID according to the token, and then realizes the transfer of the tenant ID through the context, and modifies the database query statement in relation to the tenant ID, thereby realizing the data operation in the multi-tenant isolated data management system that distinguishes tenants according to the tenant ID field with lower acquisition cost, maintenance cost and development cost.
The application provides a server for data management of multi-tenant isolation, the server includes: a memory for storing instructions executable by the processor; and a processor for executing the instructions to implement the data manipulation method as described above.
Fig. 5 is a schematic block diagram illustrating a server according to an embodiment of the present application. The server 500 may include an internal communication bus 501, a Processor (Processor)502, a Read Only Memory (ROM)503, a Random Access Memory (RAM)504, and a communication port 505. When implemented on a personal computer, the server 500 may also include a hard disk 507. The internal communication bus 501 may enable data communication among the components of the server 500. The processor 502 may make the determination and issue the prompt. In some embodiments, the processor 502 may be comprised of one or more processors. The communication port 505 may enable data communication of the server 500 with the outside. In some embodiments, server 500 may send and receive information and data from a network through communication port 505. The server 500 may also include various forms of program storage units and data storage units such as a hard disk 507, Read Only Memory (ROM)503 and Random Access Memory (RAM)504, capable of storing various data files for computer processing and/or communication, as well as possible program instructions for execution by the processor 502. The processor executes these instructions to implement the main parts of the method.
The data manipulation method described above can be implemented as a computer program, stored in the hard disk 507, and recorded in the processor 502 to be executed, so as to implement any data manipulation method in the present application.
The present application provides a computer readable medium having stored thereon computer program code which, when executed by a processor, implements a method of data manipulation as described above.
When the data manipulation method is implemented as a computer program, it may also be stored in a computer-readable storage medium as an article of manufacture. For example, computer-readable storage media can include but are not limited to magnetic storage devices (e.g., hard disk, floppy disk, magnetic strips), optical disks (e.g., Compact Disk (CD), Digital Versatile Disk (DVD)), smart cards, and flash memory devices (e.g., electrically Erasable Programmable Read Only Memory (EPROM), card, stick, key drive). In addition, various storage media described herein can represent one or more devices and/or other machine-readable media for storing information. The term "machine-readable medium" can include, without being limited to, wireless channels and various other media (and/or storage media) capable of storing, containing, and/or carrying code and/or instructions and/or data.
It should be understood that the above-described embodiments are illustrative only. The embodiments described herein may be implemented in hardware, software, firmware, middleware, microcode, or any combination thereof. For a hardware implementation, the processing units may be implemented within one or more Application Specific Integrated Circuits (ASICs), Digital Signal Processors (DSPs), Digital Signal Processing Devices (DSPDs), Programmable Logic Devices (PLDs), Field Programmable Gate Arrays (FPGAs), processors, controllers, micro-controllers, microprocessors, and/or other electronic units designed to perform the functions described herein, or a combination thereof.
Having thus described the basic concept, it will be apparent to those skilled in the art that the foregoing disclosure is by way of example only, and is not intended to limit the present application. Various modifications, improvements and adaptations to the present application may occur to those skilled in the art, although not explicitly described herein. Such modifications, improvements and adaptations are proposed in the present application and thus fall within the spirit and scope of the exemplary embodiments of the present application.
Also, this application uses specific language to describe embodiments of the application. Reference throughout this specification to "one embodiment," "an embodiment," and/or "some embodiments" means that a particular feature, structure, or characteristic described in connection with at least one embodiment of the present application is included in at least one embodiment of the present application. Therefore, it is emphasized and should be appreciated that two or more references to "an embodiment" or "one embodiment" or "an alternative embodiment" in various places throughout this specification are not necessarily all referring to the same embodiment. Furthermore, some features, structures, or characteristics of one or more embodiments of the present application may be combined as appropriate.
Aspects of the present application may be embodied entirely in hardware, entirely in software (including firmware, resident software, micro-code, etc.) or in a combination of hardware and software. The above hardware or software may be referred to as "data block," module, "" engine, "" unit, "" component, "or" system. The processor may be one or more Application Specific Integrated Circuits (ASICs), Digital Signal Processors (DSPs), digital signal processing devices (DAPDs), Programmable Logic Devices (PLDs), Field Programmable Gate Arrays (FPGAs), processors, controllers, microcontrollers, microprocessors, or a combination thereof. Furthermore, aspects of the present application may be represented as a computer product, including computer readable program code, embodied in one or more computer readable media. For example, computer-readable media may include, but are not limited to, magnetic storage devices (e.g., hard disk, floppy disk, magnetic strips … …), optical disks (e.g., Compact Disk (CD), Digital Versatile Disk (DVD) … …), smart cards, and flash memory devices (e.g., card, stick, key drive … …).
Similarly, it should be noted that in the preceding description of embodiments of the application, various features are sometimes grouped together in a single embodiment, figure, or description thereof for the purpose of streamlining the disclosure aiding in the understanding of one or more of the embodiments. This method of disclosure, however, is not intended to require more features than are expressly recited in the claims. Indeed, the embodiments may be characterized as having less than all of the features of a single embodiment disclosed above.
Although the present application has been described with reference to the present specific embodiments, it will be recognized by those skilled in the art that the foregoing embodiments are merely illustrative of the present application and that various changes and substitutions of equivalents may be made without departing from the spirit of the application, and therefore, it is intended that all changes and modifications to the above-described embodiments that come within the spirit of the application fall within the scope of the claims of the application.
Claims (10)
1. A data operation method is suitable for a data management system with multi-tenant isolation, and comprises the following steps:
receiving a data operation request sent by a client, wherein the data operation request is a data adding request, a data updating request or a data reading request and comprises data to be operated and a token of a requester;
analyzing the token from the data operation request, and acquiring a tenant ID corresponding to the requester according to the token;
placing the tenant ID in a context of an execution thread;
constructing a database query statement corresponding to the data operation request based on the data operation request, wherein the database query statement comprises the data to be operated;
acquiring and analyzing the database query statement, and confirming that a database table corresponding to the data operation request has a tenant ID field according to the database query statement;
when the data operation request is the data addition request, acquiring the tenant ID from the context of the execution thread based on the data addition request and setting the tenant ID into the tenant ID attribute of the database table;
when the data operation request is the data updating request or the data reading request, the tenant ID field is spliced into the query condition of the database query statement based on the data updating request or the data reading request; and
invoking a database driver to execute the database query statement.
2. The method of claim 1, prior to the step of obtaining and parsing the database query statement, further comprising: calling a preset actuator; and the executor calls the interceptor;
the step of acquiring and analyzing the database query statement, and confirming that the database table corresponding to the data operation request has a tenant ID field according to the database query statement, and the step of acquiring the tenant ID from the context of the execution thread based on the data addition request and setting the tenant ID into the tenant ID attribute of the database table, or splicing the tenant ID field into the query condition of the database query statement based on the data updating request or the data reading request are executed by the interceptor.
3. The method of claim 2, further comprising, prior to the step of invoking the preset executor: calling an ORM framework;
the step of calling a preset executor is executed by the ORM framework;
the executor and the interceptor belong to the ORM framework.
4. The method of claim 1, wherein the database table corresponding to the data operation request is inherited from a preset base object, the base object being applicable to an ORM framework based multi-tenant isolated data system.
5. The method of claim 1, wherein the mapping relationship of the database table corresponding to the data operation request and the preset metadata is recorded by a preset object-relationship mapping object.
6. The method of claim 5, wherein the step of validating from the database query statement that the database table corresponding to the data operation request has a tenant ID field comprises:
and confirming that the metadata information of the database table has the tenant ID field according to the database query statement.
7. The method of claim 1, wherein the database driver is a Java database connection; the step of invoking a database driver to execute the database query statement comprises:
and the executor calls a method corresponding to the data operation request in the Java database connection to execute the database query statement.
8. The method of claim 7, wherein the step of invoking a database driver to execute the database query statement further comprises:
and the Java database is connected with the executor and returns the execution result to the executor after executing the database query statement.
9. A server for data management for multi-tenant isolation, the server comprising:
a memory for storing instructions executable by the processor; and
a processor for executing the instructions to implement the method of any one of claims 1-8.
10. A computer-readable medium having stored thereon computer program code which, when executed by a processor, implements the method of any of claims 1-8.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110351973.XA CN112905630A (en) | 2021-03-31 | 2021-03-31 | Data manipulation method, server, and computer-readable medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110351973.XA CN112905630A (en) | 2021-03-31 | 2021-03-31 | Data manipulation method, server, and computer-readable medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN112905630A true CN112905630A (en) | 2021-06-04 |
Family
ID=76109784
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202110351973.XA Pending CN112905630A (en) | 2021-03-31 | 2021-03-31 | Data manipulation method, server, and computer-readable medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN112905630A (en) |
Cited By (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113535744A (en) * | 2021-07-09 | 2021-10-22 | 深圳市蘑菇财富技术有限公司 | Tenant data modification method, system, device and storage medium |
CN113779625A (en) * | 2021-08-31 | 2021-12-10 | 成都商汤科技有限公司 | Data access method and device, electronic equipment and storage medium |
CN114153858A (en) * | 2021-11-26 | 2022-03-08 | 泰康保险集团股份有限公司 | Method and device for automatically updating tenant in MySQL table space |
CN115118508A (en) * | 2022-06-28 | 2022-09-27 | 平安银行股份有限公司 | Data management method and device, electronic equipment and storage medium |
Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN108920494A (en) * | 2018-05-21 | 2018-11-30 | 深圳市彬讯科技有限公司 | Isolation access method, server-side and the storage medium of multi-tenant database |
CN109241028A (en) * | 2018-08-02 | 2019-01-18 | 山东浪潮通软信息科技有限公司 | A kind of database multi-tenant implementation method based on Mycat |
CN110765489A (en) * | 2019-10-30 | 2020-02-07 | 深圳前海环融联易信息科技服务有限公司 | Multi-tenant database isolation method and system, electronic device and computer storage medium |
CN111177776A (en) * | 2019-12-20 | 2020-05-19 | 平安资产管理有限责任公司 | Multi-tenant data isolation method and system |
WO2020232569A1 (en) * | 2019-05-17 | 2020-11-26 | 环球雅途集团有限公司 | Database access layer representation method and device |
CN112069210A (en) * | 2020-08-21 | 2020-12-11 | 北京首汽智行科技有限公司 | Saas platform multi-tenant data isolation method |
-
2021
- 2021-03-31 CN CN202110351973.XA patent/CN112905630A/en active Pending
Patent Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN108920494A (en) * | 2018-05-21 | 2018-11-30 | 深圳市彬讯科技有限公司 | Isolation access method, server-side and the storage medium of multi-tenant database |
CN109241028A (en) * | 2018-08-02 | 2019-01-18 | 山东浪潮通软信息科技有限公司 | A kind of database multi-tenant implementation method based on Mycat |
WO2020232569A1 (en) * | 2019-05-17 | 2020-11-26 | 环球雅途集团有限公司 | Database access layer representation method and device |
CN110765489A (en) * | 2019-10-30 | 2020-02-07 | 深圳前海环融联易信息科技服务有限公司 | Multi-tenant database isolation method and system, electronic device and computer storage medium |
CN111177776A (en) * | 2019-12-20 | 2020-05-19 | 平安资产管理有限责任公司 | Multi-tenant data isolation method and system |
CN112069210A (en) * | 2020-08-21 | 2020-12-11 | 北京首汽智行科技有限公司 | Saas platform multi-tenant data isolation method |
Non-Patent Citations (1)
Title |
---|
明湖居士2018: "实战saas系统多租户数据隔离(二)使用租户id字段区分租户数据", 《HTTPS:// BLOG.CSDN.NET/JOHNSU2006/ARTICLE/DETAILS/100600533》 * |
Cited By (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113535744A (en) * | 2021-07-09 | 2021-10-22 | 深圳市蘑菇财富技术有限公司 | Tenant data modification method, system, device and storage medium |
CN113535744B (en) * | 2021-07-09 | 2023-12-08 | 深圳市蘑菇财富技术有限公司 | Tenant data modification method, system, equipment and storage medium |
CN113779625A (en) * | 2021-08-31 | 2021-12-10 | 成都商汤科技有限公司 | Data access method and device, electronic equipment and storage medium |
CN114153858A (en) * | 2021-11-26 | 2022-03-08 | 泰康保险集团股份有限公司 | Method and device for automatically updating tenant in MySQL table space |
CN115118508A (en) * | 2022-06-28 | 2022-09-27 | 平安银行股份有限公司 | Data management method and device, electronic equipment and storage medium |
CN115118508B (en) * | 2022-06-28 | 2023-09-19 | 平安银行股份有限公司 | Data management method, device, electronic equipment and storage medium |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US11741100B2 (en) | Providing matching security between data stores in a database system | |
US11544623B2 (en) | Consistent filtering of machine learning data | |
US11455217B2 (en) | Transaction consistency query support for replicated data from recovery log to external data stores | |
CN112905630A (en) | Data manipulation method, server, and computer-readable medium | |
AU2015219103B2 (en) | Transparent discovery of semi-structured data schema | |
US8200705B2 (en) | Method and apparatus for applying database partitioning in a multi-tenancy scenario | |
CA3137857A1 (en) | Multi-language fusion query method and multi-model database system | |
CN112905636A (en) | Data manipulation method, server, and computer-readable medium | |
US9535948B1 (en) | Data access statement translation | |
CN113704247A (en) | Method executed by database platform, database platform and medium | |
US11405328B2 (en) | Providing on-demand production of graph-based relationships in a cloud computing environment | |
US10262024B1 (en) | Providing consistent access to data objects transcending storage limitations in a non-relational data store | |
US20140258217A1 (en) | View Based Table Replacement for Applications | |
CN117171108B (en) | Virtual model mapping method and system | |
CN112905617B (en) | Data writing method, server and computer readable storage medium | |
US11620311B1 (en) | Transformation of directed graph into relational data | |
US11354313B2 (en) | Transforming a user-defined table function to a derived table in a database management system | |
US11741134B2 (en) | Conversion and migration of key-value store to relational model | |
US9542246B2 (en) | Sharing a partitioned data set across parallel applications | |
US20170032004A1 (en) | Core data services based cross-system analytics | |
US11663216B2 (en) | Delta database data provisioning | |
EP4036746A1 (en) | Extracting sap archive data on a non-original system | |
CN117785936A (en) | Log query and analysis system and method for multiple tenants |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20210604 |
|
RJ01 | Rejection of invention patent application after publication |