WO2017107652A1 - 一种数据访问方法、装置及系统 - Google Patents

一种数据访问方法、装置及系统 Download PDF

Info

Publication number
WO2017107652A1
WO2017107652A1 PCT/CN2016/103414 CN2016103414W WO2017107652A1 WO 2017107652 A1 WO2017107652 A1 WO 2017107652A1 CN 2016103414 W CN2016103414 W CN 2016103414W WO 2017107652 A1 WO2017107652 A1 WO 2017107652A1
Authority
WO
WIPO (PCT)
Prior art keywords
data
data table
type
access
accessed
Prior art date
Application number
PCT/CN2016/103414
Other languages
English (en)
French (fr)
Inventor
陈文军
Original Assignee
华为技术有限公司
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 华为技术有限公司 filed Critical 华为技术有限公司
Priority to EP16877463.6A priority Critical patent/EP3373159A4/en
Publication of WO2017107652A1 publication Critical patent/WO2017107652A1/zh
Priority to US16/016,059 priority patent/US20180307716A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR 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/2455Query execution
    • G06F16/24553Query execution of query operations
    • G06F16/24558Binary matching operations
    • G06F16/2456Join operations
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR 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
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR 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/2452Query translation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR 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
    • G06F16/24534Query rewriting; Transformation
    • G06F16/24537Query rewriting; Transformation of operators
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR 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
    • G06F16/24534Query rewriting; Transformation
    • G06F16/24542Plan optimisation
    • G06F16/24544Join order optimisation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR 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/25Integrating or interfacing systems involving database management systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR 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/28Databases characterised by their database models, e.g. relational or object models
    • G06F16/284Relational databases

Definitions

  • the present invention relates to the field of database technologies, and in particular, to a data access method, apparatus, and system.
  • Relational databases such as Oracle, mysql, etc.
  • APP applications
  • DBMS database management system
  • Java database connectivity Java Data Base Connectivity
  • JDBC Java Data Base Connectivity
  • the first storage method :
  • the data table of the physical data table type refers to directly storing the data in the data table, and the data table of each physical data table type may include an index, and the APP may directly access when accessing a certain data table, for example, during access.
  • An index of the data table can be obtained to locate the data to be accessed according to the index.
  • the physical data table type is a special data table type, that is, the data stored in one data table is highly correlated. For example, a company's payroll can be placed in a data table of a physical data table type.
  • This data storage method is a relatively common method at present, and the operation is simple and the access performance is good.
  • the APP needs to be modified, such as modifying the execution code in the APP or in the APP. Implant new code, etc., so that the APP knows how the updated data table should be accessed.
  • the implementation is more complicated and less flexible.
  • the second storage method is a first storage method
  • the data is stored in a data table of the Object Data table type.
  • the database also stores a metadata table and an index table
  • Metadata is stored in the metadata table
  • the metadata includes a table structure in the object data table stored in the database.
  • the definition of the field structure, the definition of the index, the definition of the index, the definition of the relationship between the table objects, etc., the location of the corresponding field is stored in the index table.
  • the database can be accessed by the metadata engine according to the definition in the metadata table, and the APP does not need to directly access the database, so the access method is flexible, and the APP is basically not required to be modified.
  • the object data table type is a general data table type, that is, a data table can store a variety of data that are not related to each other.
  • an object data table type data table can contain multiple physical data table types. The data in the data table. Therefore, the amount of data stored in the data table of the current object data table type is generally large. However, when querying data, it is necessary to search in the entire data table. If the amount of data stored in such a data table is too large, it will obviously affect the query speed, resulting in impaired system performance.
  • the current two storage methods have their own shortcomings.
  • the current database can only support one storage mode, that is, either the first storage mode or the second storage mode is supported, and the storage cannot be achieved well.
  • the present application provides a data access method, device and system for solving the technical problem that the current database cannot achieve good storage.
  • a data access method including:
  • Determining an access type of the data table accessed by the data access request Determining an access type of the data table accessed by the data access request; wherein the access type of the data table includes a physical data table type and an object data table type stored in the database in the form of metadata;
  • the accessed data is obtained from the accessed data table according to the determined access type of the data table.
  • the database can support two storage methods at the same time, that is, the access type of the data table in the database can be Including physical data table type and object data table type, so different storage methods can be used for different data.
  • storage flexibility of data with small data volume can be considered, for example, data table storage of object data table type can be adopted.
  • Data with a small amount of data can also consider the high access performance of data with a large amount of data.
  • a data table of a physical data table type can be used to store data with a large amount of data, etc., respectively, for different data.
  • Provide a more suitable storage method so that the storage method in the database is more reasonable.
  • determining an access type of the data table accessed by the data access request includes:
  • the access type of the first data table is the physical data table type
  • the access type of the second data table is The object data table type
  • the correspondence between the information of the data table and the access type of the data table may be pre-stored, so that after receiving the data access request, only the information of the data table to be accessed carried in the data access request may be obtained to determine the to-be-accessed
  • the access type of the data table which can relatively easily distinguish the data tables of different access types, avoid confusion, and ensure that the data tables of different access types can be accessed in the correct manner.
  • the accessed data is obtained from the accessed data table according to the determined access type of the data table, include:
  • N are positive Integer
  • the acquired second data is associated with the M first data, and after the N association operations are performed, the accessed is obtained. data.
  • the user may want to obtain the data after associating the contents of the two data tables, so the data acquired in the first data table and the second data may be obtained.
  • the data obtained in the table is associated, so that the user can present more regular data without the user having to combine it.
  • each acquired second data can be associated with the M first data, and the associated operation is timely, which helps improve efficiency.
  • the acquiring the second data to be associated with the M first data includes:
  • association condition carried in the data access request; the association condition is used to perform an associating operation on the M first data and the N second data;
  • a method for performing an association operation is provided, and the association operation is performed according to the association condition carried in the data access request, which not only meets the requirements of the user, but also has a relatively fast operation process.
  • the method also includes:
  • the amount of data included in the third data table stored in the database is greater than a preset threshold, and the type of the third data table is the object data table type, outputting the first prompt information; the first prompt information Used to indicate that the type of the third data table is converted to the physical data table type.
  • the preset threshold may be set by the data access device, for example, the system may be set according to the learning experience, or may be set by the user if the data table of the object data type (such as the third data) Table)
  • the amount of data included is greater than the preset threshold, so it takes more time to access the third data table, which may affect system performance. Therefore, if the amount of data included in the third data table is greater than a preset threshold, data access The device may output the first prompt information, so that the user can select whether to convert the access type of the third data table to the physical data table type to improve data access performance.
  • the method also includes:
  • the request message carries an amount of data included in the fourth data table
  • the fourth data table includes a data amount that is less than or equal to a preset threshold, and outputs second prompt information, where the second prompt information is used to indicate that the fourth data table is established by using the object data table type.
  • the data access device may output a suggestion (ie, second prompt information) according to the amount of data included in the fourth data table to be established. If the data amount is greater than a preset threshold, it is recommended to establish a fourth data table by using a physical data table type to improve the data. Access performance, if the amount of data is less than or equal to the preset threshold, it is recommended to establish a fourth data table with the object data table type to improve the flexibility of data access. In this way, different types of data tables can be established according to different data amounts, so that the storage manner in the database is more reasonable, and the data access performance is maximized.
  • a suggestion ie, second prompt information
  • a data access device including:
  • a memory for storing instructions
  • a processor configured to execute the instruction, to determine an access type of the data table accessed by the data access request; wherein the access type of the data table includes a physical data table type and an object stored in the database in the form of metadata The data table type; the accessed data is obtained from the accessed data table according to the determined access type of the data table.
  • the processor is configured to:
  • the access type of the first data table is the physical data table type
  • the access type of the second data table is The object data table type
  • the processor is configured to:
  • N are positive Integer
  • the acquired second data is associated with the M first data, and after the N association operations are performed, the accessed is obtained. data.
  • the processor is configured to:
  • association condition carried in the data access request; the association condition is used to perform an associating operation on the M first data and the N second data;
  • the device also includes a transmitter; the processor is further configured to:
  • the type of the third data table is the object data table type, and the first prompt information is output by the sender; the first prompt information is used to indicate that the type of the third data table is converted into the physical Data table type.
  • the device also includes a transmitter
  • the receiver is further configured to: receive a request message for requesting to establish a fourth data table; and the request message carries an amount of data included in the fourth data table;
  • the processor is further configured to: if it is determined that the amount of data included in the fourth data table is greater than a preset threshold, output, by the sender, second prompt information, where the second prompt information is used to indicate the physical data
  • the table type establishes the fourth data table; or, if it is determined that the data amount included in the fourth data table is less than or equal to a preset threshold, the second prompt information is output by the transmitter, and the second prompt information is used to indicate The fourth data table is established with the object data table type.
  • a data access system including:
  • a database for storing a data table; wherein the access type of the data table includes a physical data table type and an object data table type stored in the database in the form of metadata;
  • the data access apparatus of any one of the first possible implementation to the fifth possible implementation of the second aspect or the second aspect, for receiving a data access request according to the received data access request The database is accessed to retrieve the accessed data from the accessed data table.
  • another data access device comprising means for performing the method of the first aspect.
  • the database in the embodiment of the present invention simultaneously supports the two data storage modes as above, so that different storage modes can be selected for different data, and only the type of the data table in which the data to be accessed is located is determined according to the access request when accessing the data.
  • Know how to access the data the implementation is simple, easy to promote and use.
  • 1A-1B are two schematic diagrams of a first storage method in a database
  • FIG. 2 is a schematic diagram of a second storage mode in a database
  • FIG. 3 is a schematic diagram of a storage manner in a database in an embodiment of the present invention.
  • 4A-4B are schematic diagrams showing the structure of a data access device according to an embodiment of the present invention.
  • FIG. 5 is a schematic structural diagram of a data access system according to an embodiment of the present invention.
  • FIG. 6 is a flowchart of a data access method in an embodiment of the present invention.
  • FIG. 7 is a structural block diagram of a data access apparatus according to an embodiment of the present invention.
  • the first storage method storing data in a data table of a physical data table type.
  • the user When the data table of the physical data table type is established, the user establishes directly in the database through the APP. For example, the user establishes several data tables of the physical data table type in the database, as shown in FIG. 1A, which are data table 1, data respectively.
  • Table 2 and data table 3 of course, after the establishment of a data table, the index corresponding to the data table is also established, and the index is generally stored together with the data table. And, after creating a data table, the table structure, fields, and the like in the data table are also defined.
  • These definitions can be placed in the Extensible Markup Language (XML) information of the data table, and the XML information can also be followed by the data table. Stored together.
  • XML Extensible Markup Language
  • APP wants to access data table 1, it can directly access the JDBC interface of the application service layer.
  • Data table 1 may obtain an index of the data table 1 at the time of access, thereby locating the data to be accessed according to the index.
  • the APP can directly access the database without going through the application service layer.
  • FIG. 1B for example, the user establishes several physical data table type data tables in the database, which are data table 1, data table 2, and data table 3, respectively. Users can directly access these data tables by operating the APP without going through the application service layer.
  • the APP and the application service layer can be regarded as two functional modules.
  • the two functional modules are generally implemented by software, and the two functional modules can be located in the same device, or can be located in different devices.
  • the JDBC interface is generally an interface provided by the application service layer for the APP to access the database.
  • the database can also be regarded as a function module, which can generally be realized by a storage device in the device.
  • the three functional modules of the APP, the application service layer, and the database may be located in the same device, or may be located in different devices, or any two of the functional modules may be located in the same device, and the like.
  • the second storage method storing data in a data table of an object data table type.
  • a metadata table needs to be established.
  • the system can provide an interface dedicated to establishing a metadata table, and the user can directly establish a metadata table in the interface. After the user inputs, the user can choose to submit.
  • the metadata driving engine located at the application service layer can create a metadata table in the database according to the content input by the user, and generate a metadata in the metadata table according to the content input by the user.
  • the data for example, the metadata may include a definition of a table structure in an object data table to be established, a definition of a field structure, an index definition, a definition of a relationship between the table objects, and the like, and the metadata driving engine may also establish a corresponding in the database.
  • Object data table to store data.
  • the metadata driver engine can also create an index table for querying data in the object data table in the database.
  • the object data table can store various unrelated data. Therefore, only one object data table can be created in the database.
  • the solution for establishing multiple object data tables is also in the protection scope of the embodiment of the present invention. within.
  • the metadata driving engine does not need to create a new metadata table, but directly generates metadata according to the content submitted by the user, and puts the metadata into the generated metadata table.
  • the object data table has been created in the database
  • the metadata is driven The engine does not need to create a new object data table, but puts the data to be stored into the created object data table.
  • an index table has been created in the database
  • the metadata-driven engine does not need to create a new index table, but directly adds the index of the new data to the established index table.
  • the metadata driving engine can obtain the definition of the table structure of the object data table from the metadata table, and then query by the metadata driving engine according to the index table to obtain the data in the object data table.
  • the database in the embodiment of the present invention simultaneously supports the two data storage modes as above, so that different storage modes can be selected for different data, and only the type of the data table in which the data to be accessed is located is determined according to the access request when accessing the data.
  • Know how to access the data the implementation is simple, easy to promote and use.
  • FIG. 3 is a schematic diagram of a storage manner of a database in an embodiment of the present invention.
  • the data table 1 is a data table of a physical data table type
  • the data table 2 is a data table of an object data table type
  • the metadata table and an index table corresponding to the data table 2 are also stored in the database, wherein the data table The index of 1 is stored with data table 1, not shown in FIG.
  • a data table of a physical data table type is taken as an example. In an actual application, a data table of multiple physical data table types may be stored in the database.
  • the embodiment of the present invention provides a hybrid engine that is also located in an application service layer, and the hybrid engine can respectively communicate with a metadata driving engine for accessing an object data table and a physical data table access engine for accessing a physical data table, and the hybrid engine can Receiving the access request input through the APP, after determining which type of data table the data table in which the data to be accessed is located, the hybrid engine may invoke the corresponding engine (metadata driving engine or physical data table access engine) to respond to the access.
  • the metadata driving engine or the physical data table access engine obtains the data to be accessed, the data may be directly fed back to the APP, not through the hybrid engine, or the data to be accessed may be fed back to the hybrid engine, and the hybrid engine feeds back to the APP. This allows access to different types of data tables.
  • the metadata driving engine and the physical data table access engine may be located in the hybrid engine, that is, the hybrid engine may include a metadata driving engine and a physical data table access engine, and of course, the hybrid engine may further include other functional modules, or a hybrid engine. , metadata driven engine and physical data table access The engine can also be three separate modules, and the hybrid engine can communicate with the metadata-driven engine and the physical data table access engine respectively ( Figure 3 for example).
  • the embodiment of the present invention provides a physical data table access engine for accessing a data table of a physical data table type.
  • the physical data table access engine may be a JDBC interface, or may be another data table for accessing a physical data table type. Interface or engine.
  • an embodiment of the present invention provides a data access apparatus, which may include a memory 401, a processor 402, and a receiver 403.
  • the processor 402 may be a central processing unit (CPU) or an application specific integrated circuit (ASIC), and may be one or more integrated circuits for controlling program execution, and may be a field programmable gate array.
  • the hardware circuit developed by Field Programmable Gate Array (FPGA) can be a baseband chip.
  • the number of memories 401 may be one or more.
  • the memory 401 may include a read only memory (ROM), a random access memory (RAM), and a disk storage.
  • the receiver 403 can be used to communicate with an external device, for example the receiver 403 can communicate with the APP.
  • the apparatus may further include a transmitter 404, which may be used to communicate with an external device, for example, the transmitter 404 may also communicate with the APP.
  • a transmitter 404 which may be used to communicate with an external device, for example, the transmitter 404 may also communicate with the APP.
  • the transmitter 404 and the receiver 403 may be the same physical module, for example, may be a physical module capable of implementing a transceiving function, such as a transceiver, or the transmitter 404 and the receiver 403 may be separate physical modules.
  • These memories 401, transmitters 404 and receivers 403 may be coupled to the processor 402 via a bus (as such by way of example in Figures 4A-4B), or may be coupled to the processor 402 via dedicated connection lines, respectively.
  • processor 402 By design programming the processor 402, the code corresponding to the method shown below is solidified into the chip, so that the chip can perform the method shown in FIG. 5 below when it is running. How to processor The design and programming of 402 is well known to those skilled in the art and will not be described again here.
  • the data access device can implement the function of the hybrid engine in FIG.
  • the data access device may be implemented by software, for example, may be a set of software programs that are solidified in the device, or may be implemented by hardware, for example, may be a hardware module added in the device, or may be used in the device.
  • the hardware module implementation such as the processor 402 can be implemented by a data processing system in the device, the memory 401 can be implemented by a storage device in the device, or the memory 401 can also be implemented by an internal cache of the data processing system in the device, the transmitter 404
  • the and receiver 403 can be implemented by a data transceiving system in the device.
  • an embodiment of the present invention further provides a data access system, which may include a database, and may further include a data access device as shown in FIG. 4A or 4B.
  • the database and the data access device in the system may be located in the same device (for example, FIG. 5), for example, may be located in the same server, or may be located in different devices, such as may be located in different servers, or It can also be located in different other types of devices.
  • an embodiment of the present invention provides a data access method, which may be performed by a data access device as described above, and a flow of the method is as follows.
  • Step 601 Receive a data access request.
  • Step 602 Determine an access type of the data table accessed by the data access request, where the access type of the data table includes a physical data table type and an object data table type stored in the database in the form of metadata;
  • Step 603 Acquire the accessed data from the accessed data table according to the determined access type of the data table.
  • the receiver 403 can receive a data access request input by the APP.
  • the data access request input by the APP can be a Structured Query Language (SQL) statement.
  • the data access request may carry information of the accessed data table, and the information of the data table may include, for example, an access type, a name, or an identity (ID) of the data table.
  • Processor 402 can determine the type of access to the data table accessed by the data access request. Optional, If the data access request directly carries the access type of the accessed data table, the processor 402 can directly determine the access type of the accessed data table according to the data access request, if the data access request carries the data table Other information, such as carrying the ID of the data table or the name of the data table, etc., the processor 402 also needs to determine the access type of the accessed data table.
  • the correspondence between the information of the data table and the access type of the data table may be pre-stored in the memory 401, so that after receiving the data access request, the processor 402 may obtain the information of the data table carried in the data access request, and then according to The correspondence between the information of the stored data table and the access type of the data table determines the type of the data table to be accessed.
  • the pre-stored in the memory 401 is the correspondence between the ID of the data table and the access type of the data table.
  • the data access request sent by the APP should also be the ID of the data table, so that the processor 402 receives After the data access request, the ID of the data table carried in the data access request may be obtained, and then the access type of the data table to be accessed is determined according to the correspondence between the ID of the stored data table and the access type of the data table.
  • BILL_SUM consolidated billing table
  • BILL_DETAIL detailed billing table
  • the data size of BILL_SUM is 60 million.
  • Table 1 For the table structure of BILL_SUM, please refer to Table 1:
  • the data size of BILL_DETAIL is 10 times that of BILL_SUM, which is estimated to be 600 million pieces of data.
  • Table 2 For the table structure of BILL_DETAIL, please refer to Table 2:
  • the data table of the physical data table type is flexible and the access speed is fast, but it is often necessary to modify the APP, which is troublesome.
  • the data table of the object data table type does not need to be modified at the time of access, but because of the excessive data included, the access speed is relatively high. Compared with the data table of the physical data table type, the data table is slower. Therefore, in the embodiment of the present invention, different storage modes may be adopted for different data, and data of a smaller data amount may be stored by using an object data table type data table. Because the amount of data is small, the access speed is not too slow. You can also use the data table of the object data table type as much as possible without modifying the advantages of the APP. According to the large amount of data, if the data table of the object data table type is used for storage, the access speed may be affected. Therefore, the data table storage of the physical data table type may be considered to maximize the access speed and avoid system performance damage. .
  • the preset threshold may be preset, and the set preset threshold is stored in the memory 401. If the amount of data to be stored is less than or equal to the preset threshold, the data may be stored in the data of the object data table type. In the table, if the amount of data to be stored is greater than the preset threshold, the data can be stored in a data table of a physical data table type.
  • the preset threshold may be set by the processor 402 itself, for example, the processor 402 may be set according to the storage experience, or may be set by the user.
  • the preset threshold is 80 million.
  • the type of BILL_SUM may be an object data table type
  • the type of BILL_DETAIL may be a physical data table type.
  • the memory 401 may store a correspondence between other information of the data table and an access type of the data table (for example, storing the correspondence in a data table named an object type table), such as stored in Example 1. Is the correspondence between the name of the data table and the access type of the data table, see Table 3:
  • the object type table may also store information such as data size and data table structure information of different data tables, and may continue to refer to Table 3, object type.
  • the table is not limited as long as it can be used to determine the access type of the data table requested by the data access request by the processor 402.
  • the other information stored in the object type table is not limited.
  • the data access request may be sent to the data access device, where the data access request may be a general SQL access request.
  • the data access request may carry the data table to be accessed.
  • receiver 403 receives access please After the request, the processor 402 can determine the access type of the data table to be accessed according to the object type table.
  • the processor 402 determines that the access type of the data table to be accessed is a physical data table type, and the processor 402 can invoke the physical data table access engine.
  • the physical data table access engine obtains the data access request, obtains the table structure, the field and the like information requested by the data access request, and determines the definition according to the acquired table structure, the field, and the like according to the XML information of the BILL_DETAIL, and then passes the index of BILL_DETAIL. Access the required data in BILL_DETAIL.
  • the physical data table access engine may consider that all the corresponding table structures, fields, and the like are required to be accessed, and the physical data table access engine may use the BILL_DETAIL XML information to The data access request is reassembled, and all the table structures, fields, and the like of BILL_DETAIL are added to the data access request, and the required data is accessed in BILL_DETAIL through the index of BILL_DETAIL. Then, the physical data table access engine can directly feed the accessed data to the APP, or the physical data table access engine can also feed the accessed data to the data access device, and the processor 402 feeds back to the APP through the transmitter 404.
  • the processor 402 determines that the access type of the data table to be accessed is the object data table type, and the processor 402 can invoke the metadata driving engine.
  • the metadata driving engine obtains the data access request, obtains the table structure, the field and the like information requested by the data access request, determines the definition of the obtained table structure, the field, and the like according to the metadata table, and then passes the index table in the BILL_SUM. Access the data you need. Thereafter, the metadata driving engine can directly feed the accessed data to the APP, or the metadata driving engine can feed back the accessed data to the data access device, and the processor 402 feeds back to the APP through the transmitter 404.
  • a billing type table for example, Bill_TYPE
  • a detail billing table for example, BILL_DETAIL
  • the amount of data of Bill_TYPE is not large, and is smaller than a preset threshold (for example, a preset threshold of 80 million), so it can be considered to use a data table of an object data table type for storage.
  • a preset threshold for example, a preset threshold of 80 million
  • the table structure of Bill_TYPE can refer to Table 4:
  • the object type table stored in the memory 401 can refer to Table 5:
  • the data access request may be sent to the data access device, where the data access request may be a general SQL access request, and the data access request may carry the name of the data table to be accessed, and the receiver
  • the processor 402 determines the access type of the data table to be accessed according to the object type table.
  • this SQL query request needs to query the data in the data tables of two different access types. Then, for the data in the two data tables, a join operation may be performed, and the result of the association operation is used as a data access result fed back to the APP.
  • a join operation may be performed, and the result of the association operation is used as a data access result fed back to the APP.
  • the association operation first, according to the data access request, it may be determined which one of the accessed data tables is the primary table and which is the secondary table. For example, according to the above data access request, the processor 402 may determine that the BILL_DETAIL is the primary table, and the BILL_TYPE is the secondary table. , then deal with The processor 402 can associate the data acquired from the table with the data acquired in the main table, respectively. The association process is described below.
  • the processor 402 calls the physical data table access engine to obtain the data to be accessed in the BILL_DETAIL through the physical data table access engine, for example, obtains M first data, and the processor 402 can store the M first data in the cache, and cache. It may be provided by memory 401 or may also be provided by processor 402.
  • the processor 402 also needs to invoke the metadata driving engine to obtain the data to be accessed in the BILL_TYPE through the metadata driving engine. Then, if the processor 402 directly obtains all the data to be accessed in the BILL_TYPE through the metadata driving engine.
  • the data to be accessed obtained from the BILL_TYPE is referred to as the second data, for example, N pieces of second data can be obtained in total, and then the association operation is performed, and the M first data and the N second data are stored together in the cache.
  • the processor 402 can invoke the metadata driving engine to The second data is obtained in sequence in the BILL_TYPE. For example, each time the second data is obtained, the processor 402 can associate the obtained second data with the M first data according to the association condition to see whether the obtained second data can be related to the M.
  • At least one first data of the first data is associated, and if the obtained second data can be associated with the at least one first data, The obtained second data and the at least one first data can satisfy the association condition, and the processor 402 obtains a set of associated data, the set of associated data includes the obtained second data and at least one first data, the set of associated data That is, the data in the data to be accessed is equivalent to the processor 402 performing N association operations. After obtaining the last second data (ie, the Nth second data) from the BILL_TYPE, the processor 402 performs the Nth association.
  • the processor 402 can obtain the data to be accessed, and the data to be accessed may include K group association data, where K is an integer less than or equal to N and greater than or equal to 0, and the K group association data is The data to be accessed.
  • the association condition may be carried in the data access request, and the processor 402 may obtain the association condition by parsing the data access request, thereby associating the M first data and the N second data.
  • the processor 402 may first determine the master-slave relationship of the data table according to the data access request.
  • the rule may be that the data table with a large amount of data is used as the main table, and the other data tables are used as the slave table, that is, the A table is used as the main table, and the table B is used.
  • the data acquisition condition that is, the access condition for the slave table carried in the data access request is determined.
  • the extracted data may be associated with the data in the primary table, and the association condition may be carried in the data access request, such as the data access request in this example, A.
  • a data obtained from the table may be associated with at least one data in the primary table, and then at least one data obtained from the data in the table and the primary table may be regarded as a group of associated data, or a slave table.
  • Some of the data in the data may not be associated with any data obtained in the primary table, that is, the association condition is not met, then the data obtained from the table that cannot be associated with any data obtained in the primary table may not be the APP.
  • the data accessed can discard this part of the data, which also helps to save storage space.
  • the obtained associated data may be fed back as the accessed data, and the number obtained from the table that cannot be associated with any data obtained in the primary table may be used. According to the data, as well as the data obtained in the main table that cannot be associated with any data obtained from the table, it can be discarded.
  • the data is fed back so that the data the user gets is more complete.
  • the processor 402 can feed the accessed data to the APP through the transmitter 404, or after obtaining the accessed data, the processor 402 can also sort the accessed data (for example, Example 2) It can be sorted according to the bill type), and then fed back to the APP through the sender 404.
  • the processor 402 can feed the accessed data to the APP through the transmitter 404, or after obtaining the accessed data, the processor 402 can also sort the accessed data (for example, Example 2) It can be sorted according to the bill type), and then fed back to the APP through the sender 404.
  • the processor 402 can also scan various types of data tables stored in the database, for example, can be scanned periodically or periodically, or can be scanned under the trigger of the user. For example, the scan determines that the amount of data included in the third data table stored in the database is greater than a preset threshold, and the processor 402 may determine an access type of the third data table, for example, the access type of the third data table is an object data table type. Then, in order to improve the access performance of the database, the processor 402 may send a message to the APP, and the APP may output the first prompt information to the user, where the first prompt information may be used to indicate that the access type of the third data table is converted into a physical data table type. . After receiving the first prompt information, if the user accepts the suggestion, the data included in the third data table may be re-stored in the physical data table type.
  • the user may first send a request message to the data access device by using the APP.
  • the user may send a request message to the data access device through the APP, where the request message may be Carry the amount of data included in the fourth data table.
  • the receiver 403 receives the request message sent by the APP, and the processor 402 may determine whether the data amount of the fourth data table is greater than a preset threshold stored in the memory 401, thereby giving a storage indication for the fourth data table, for example, if the fourth data If the amount of data included in the table is greater than the preset threshold, the processor 402 may indicate that the fourth data table is established in a storage manner of the physical data table type. If the data amount included in the fourth data table is less than or equal to the preset threshold, the processor 402 may The instruction indicates that the fourth data table is established in the storage manner of the object data table type, the sender 404 can send the indication of the processor 402 to the APP, and the APP can output the second prompt information.
  • the second prompt information may be used to indicate that the fourth data table is established in a storage manner of the physical data table type, if the data amount included in the fourth data table is less than or equal to a preset.
  • the second prompt information may be used to indicate that the fourth data table is established in the storage manner of the object data table type, and the user may subsequently establish the fourth data table according to the second prompt information.
  • an embodiment of the present invention further provides a data access device, where the device may include a receiving module 701 and a processing module 702.
  • the device may further include a sending module 703.
  • the device may be implemented by software, or may be implemented by hardware.
  • the physical device corresponding to the processing module 702 in the device may be the processor 402 in FIG. 4A-4B, and the receiving module 701.
  • the corresponding physical device may be the receiver 403 in FIG. 4A-4B, and the physical device corresponding to the sending module 703 may be the transmitter 404 in FIG. 4B.
  • the device may be used to perform the method described in FIG. 6 above. Therefore, for the functions and the like implemented by the units in the device, reference may be made to the description of the previous method portion, and details are not described herein.
  • the database can simultaneously support two storage modes, that is, the access type of the data table in the database may include a physical data table type and an object data table type, so that different storage modes may be adopted for different data.
  • the storage flexibility of data with a small amount of data can be considered.
  • a data table of an object data table type can be used to store data with a small amount of data, and on the other hand, a high access performance of data with a large amount of data can be considered.
  • a data table of a physical data table type can be used to store data with a large amount of data, and the like, and a storage method suitable for different data is provided, so that the storage mode in the database is more reasonable.
  • the disclosed apparatus, system, and method may be implemented in other ways.
  • the device embodiments described above are merely illustrative.
  • the division of the unit or unit is only a logical function division, and the actual implementation may have another division manner.
  • multiple units or components may be combined or integrated into another system, or some features may be omitted or not implemented.
  • the mutual coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection through some interface, device or unit, and may be electrical or otherwise.
  • the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, may be located in one place, or may be distributed to multiple network units. Some or all of the units may be selected according to actual needs to implement the embodiments of the present invention.
  • the functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may also be an independent physical module.
  • the integrated unit if implemented in the form of a software functional unit and sold or used as a standalone product, may be stored in a computer readable storage medium.
  • all or part of the technical solution of the present invention may be embodied in the form of a software product stored in a storage medium, including a plurality of instructions for causing a computer device (which may be a personal computer, A server, or network device, or the like, or a processor, performs all or part of the steps of the methods described in various embodiments of the present invention.
  • the foregoing storage medium includes: a universal serial bus flash drive, a removable hard disk, a ROM, a RAM, a magnetic disk, or an optical disk, and the like, which can store program codes.

Landscapes

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

Abstract

一种数据访问方法、装置及系统,用以解决目前的数据库无法实现较好地存储的技术问题。该方法包括:接收数据访问请求(601);确定所述数据访问请求所访问的数据表的存取类型;其中,数据表的存取类型包括物理数据表类型及以元数据形式存储在数据库中的对象数据表类型(602);根据确定的数据表的存取类型,从所访问的数据表中获取所访问的数据(603)。

Description

一种数据访问方法、装置及系统
本申请要求于2015年12月25日提交中国专利局、申请号为201510998317.3,发明名称为“一种数据访问方法、装置及系统”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本发明涉及数据库技术领域,尤其涉及一种数据访问方法、装置及系统。
背景技术
关系型数据库(如Oracle、mysql等)通常采用数据表的方式存储数据,应用(APP)则可以通过数据库提供的数据库管理系统(Database Management System,DBMS)接口,如Java数据库连接(Java Data Base Connectivity,JDBC)等,访问数据库中的数据表。
目前,数据库大概支持两种不同的数据存储方式:
第一种存储方式:
以物理数据表类型的数据表存储数据。其中,物理数据表类型的数据表是指直接将数据存储在数据表中,每个物理数据表类型的数据表可以包括索引,则APP要访问某个数据表时可以直接访问,比如在访问时可以获取该数据表的索引,从而根据索引定位待访问的数据。
物理数据表类型是一种专用的数据表类型,即一个数据表中存储的数据之间关联性较强,比如可以将一个公司的工资表放在一个物理数据表类型的数据表中。这种数据存储方式是当前比较常见的方式,操作简单,访问性能较好。但在这种数据存储方式下,如果新增了数据表或者对已有的数据表中的字段结构进行了修改等,都需要对APP进行改造,比如修改APP中的执行代码或是在APP中植入新的代码等,以使得APP获知更新后的数据表应该如何访问,显然实现较为复杂,灵活性较差。
第二种存储方式:
以对象数据(Object Data)表类型的数据表存储数据。在这种存储方式下,数据库中还存储有元数据表以及索引(Index)表,元数据表中存储的是元数据(Metadata),元数据包括对数据库中存储的对象数据表中的表结构的定义、字段结构的定义、索引定义、表对象之间的关系的定义等,索引表中存储的是相应字段所在的位置等。APP在访问时,可首先从元数据表中获取相应的定义,之后通过索引表定位待访问的数据。
在这种访问方式下,可以由元数据引擎根据元数据表中的定义来对数据库进行访问,无需APP直接访问数据库,所以访问方式较为灵活,基本无需改造APP。但对象数据表类型是一种通用数据表类型,即一个数据表中可以存储互不相关的多种数据,通俗解释,就是一个对象数据表类型的数据表中可以包含多个物理数据表类型的数据表中的数据。因此,目前对象数据表类型的数据表中存储的数据量一般都比较大。然而,在查询数据时,是要在整张数据表中进行检索,如果这种数据表中存储的数据量过大,显然会影响查询速度,导致系统的性能受损。
可见,目前的两种存储方式都各有缺点,然而现在的数据库都只能支持一种存储方式,即要么支持第一种存储方式要么支持第二种存储方式,无法实现较好地存储。
发明内容
本申请提供一种数据访问方法、装置及系统,用以解决目前的数据库无法实现较好地存储的技术问题。
第一方面,提供一种数据访问方法,包括:
接收数据访问请求;
确定所述数据访问请求所访问的数据表的存取类型;其中,数据表的存取类型包括物理数据表类型及以元数据形式存储在数据库中的对象数据表类型;
根据确定的数据表的存取类型,从所访问的数据表中获取所访问的数据。
数据库可以同时支持两种存储方式,即数据库中的数据表的存取类型可以 包括物理数据表类型及对象数据表类型,这样,针对不同的数据可以采用不同的存储方式,一方面可以考虑数据量较小的数据的存储灵活性,比如可以采用对象数据表类型的数据表存储数据量较小的数据,另一方面也可以考虑数据量较大的数据的高访问性能,比如可以采用物理数据表类型的数据表存储数据量较大的数据,等等,分别为不同的数据提供较为适合的存储方式,使得数据库中的存储方式更为合理。在访问数据时只需根据访问请求确定所访问的数据所在的数据表的类型即可实现对数据的访问,实现较为简单,便于推广使用。
结合第一方面,在第一方面的第一种可能的实现方式中,确定所述数据访问请求所访问的数据表的存取类型,包括:
获取所述数据访问请求所携带的待访问的第一数据表的信息及第二数据表的信息;
根据存储的数据表的信息与数据表的存取类型之间的对应关系确定所述第一数据表的存取类型为所述物理数据表类型,及所述第二数据表的存取类型为所述对象数据表类型。
可以预先存储数据表的信息与数据表的存取类型之间的对应关系,这样在接收数据访问请求后,只需获取数据访问请求中携带的待访问的数据表的信息就可以确定待访问的数据表的存取类型,这样可以较为简单地区分不同存取类型的数据表,避免混淆,保证后续能够采用正确的方式访问不同存取类型的数据表。
结合第一方面的第一种可能的实现方式,在第一方面的第二种可能的实现方式中,根据确定的数据表的存取类型,从所访问的数据表中获取所访问的数据,包括:
根据所述数据访问请求携带的针对所述第一数据表的第一访问条件,从所述第一数据表中获取符合所述第一访问条件的M个第一数据;
根据所述数据访问请求携带的针对所述第二数据表的第二访问条件,从所述第二数据表中获取符合所述第二访问条件的N个第二数据;M、N均为正整数;
在获取所述N个第二数据的过程中,每获取一个第二数据,将获取的第二数据与所述M个第一数据进行关联操作,在进行N次关联操作后,得到所访问的数据。
如果访问的是不同存取类型的数据表,那么用户可能想要得到的是将两个数据表中的内容进行关联后的数据,因此,可以将第一数据表中获取的数据与第二数据表中获取的数据进行关联操作,这样可以呈现给用户较为有规律的数据,无需用户再自行进行组合。另外,在获取第二数据的过程中,每获取一个第二数据就可以将获取的第二数据与M个第一数据进行关联操作,关联操作较为及时,有助于提高效率。
结合第一方面的第二种可能的实现方式,在第一方面的第三种可能的实现方式中,将获取的第二数据与所述M个第一数据进行关联操作,包括:
获取所述数据访问请求中携带的关联条件;所述关联条件用于将所述M个第一数据及所述N个第二数据进行关联操作;
确定所述获取的第二数据是否与所述M个第一数据中的至少一个第一数据满足所述关联条件;
若所述获取的第二数据与所述至少一个第一数据满足所述关联条件,则得到包括所述获取的第二数据与所述至少一个第一数据的一组关联数据。
提供了一种进行关联操作的方式,根据数据访问请求中携带的关联条件进行关联操作,既符合用户的需求,操作过程也较为快捷。
结合第一方面或第一方面的第一种可能的实现方式至第三种可能的实现方式中的任一种可能的实现方式,在第一方面的第四种可能的实现方式中,所述方法还包括:
若所述数据库中存储的第三数据表包括的数据量大于预设阈值,且所述第三数据表的类型为所述对象数据表类型,则输出第一提示信息;所述第一提示信息用于指示将所述第三数据表的类型转换为所述物理数据表类型。
预设阈值可以是数据访问装置自行设定的,比如可以是系统根据学习经验设定的,或者可以是用户设定的,如果对象数据表类型的数据表(如第三数据 表)包括的数据量大于预设阈值,那么在访问第三数据表时就需要耗费较多的时间,可能会影响系统性能,因此如果第三数据表包括的数据量大于预设阈值,数据访问装置可以输出第一提示信息,这样用户可以选择是否要将第三数据表的存取类型转换为物理数据表类型,以提高数据访问性能。
结合第一方面或第一方面的第一种可能的实现方式至第四种可能的实现方式中的任一种可能的实现方式,在第一方面的第五种可能的实现方式中,所述方法还包括:
接收用于请求建立第四数据表的请求消息;所述请求消息中携带所述第四数据表包括的数据量;
若所述第四数据表包括的数据量大于预设阈值,输出第二提示信息,所述第二提示信息用于指示以所述物理数据表类型建立所述第四数据表;或,若所述第四数据表包括的数据量小于等于预设阈值,输出第二提示信息,所述第二提示信息用于指示以所述对象数据表类型建立所述第四数据表。
数据访问装置可以根据待建立的第四数据表包括的数据量输出建议(即第二提示信息),如果数据量大于预设阈值,则建议以物理数据表类型建立第四数据表,以提高数据访问性能,如果数据量小于等于预设阈值,则建议以对象数据表类型建立第四数据表,以提高数据访问的灵活性。这样,根据不同的数据量可以建立不同类型的数据表,使得数据库中的存储方式更为合理,尽量提高数据访问性能。
第二方面,提供一种数据访问装置,包括:
存储器,用于存储指令;
接收器,用于接收数据访问请求;
处理器,用于执行所述指令,确定所述数据访问请求所访问的数据表的存取类型;其中,数据表的存取类型包括物理数据表类型及以元数据形式存储在数据库中的对象数据表类型;根据确定的数据表的存取类型,从所访问的数据表中获取所访问的数据。
结合第二方面,在第二方面的第一种可能的实现方式中,所述处理器用于:
获取所述数据访问请求所携带的待访问的第一数据表的信息及第二数据表的信息;
根据存储的数据表的信息与数据表的存取类型之间的对应关系确定所述第一数据表的存取类型为所述物理数据表类型,及所述第二数据表的存取类型为所述对象数据表类型。
结合第二方面的第一种可能的实现方式,在第二方面的第二种可能的实现方式中,所述处理器用于:
根据所述数据访问请求携带的针对所述第一数据表的第一访问条件,从所述第一数据表中获取符合所述第一访问条件的M个第一数据;
根据所述数据访问请求携带的针对所述第二数据表的第二访问条件,从所述第二数据表中获取符合所述第二访问条件的N个第二数据;M、N均为正整数;
在获取所述N个第二数据的过程中,每获取一个第二数据,将获取的第二数据与所述M个第一数据进行关联操作,在进行N次关联操作后,得到所访问的数据。
结合第二方面的第二种可能的实现方式,在第二方面的第三种可能的实现方式中,所述处理器用于:
获取所述数据访问请求中携带的关联条件;所述关联条件用于将所述M个第一数据及所述N个第二数据进行关联操作;
确定所述获取的第二数据是否与所述M个第一数据中的至少一个第一数据满足所述关联条件;
若所述获取的第二数据与所述至少一个第一数据满足所述关联条件,则得到包括所述获取的第二数据与所述至少一个第一数据的一组关联数据。
结合第二方面或第二方面的第一种可能的实现方式至第三种可能的实现方式中的任一种可能的实现方式,在第二方面的第四种可能的实现方式中,所述装置还包括发送器;所述处理器还用于:
若确定所述数据库中存储的第三数据表存储的数据量大于预设阈值,且所 述第三数据表的类型为所述对象数据表类型,则通过所述发送器输出第一提示信息;所述第一提示信息用于指示将所述第三数据表的类型转换为所述物理数据表类型。
结合第二方面或第二方面的第一种可能的实现方式至第四种可能的实现方式中的任一种可能的实现方式,在第二方面的第五种可能的实现方式中,所述装置还包括发送器;
所述接收器还用于:接收用于请求建立第四数据表的请求消息;所述请求消息中携带所述第四数据表包括的数据量;
所述处理器还用于:若确定所述第四数据表包括的数据量大于预设阈值,通过所述发送器输出第二提示信息,所述第二提示信息用于指示以所述物理数据表类型建立所述第四数据表;或,若确定所述第四数据表包括的数据量小于等于预设阈值,通过所述发送器输出第二提示信息,所述第二提示信息用于指示以所述对象数据表类型建立所述第四数据表。
第三方面,提供一种数据访问系统,包括:
数据库,用于存储数据表;其中,数据表的存取类型包括物理数据表类型及以元数据形式存储在所述数据库中的对象数据表类型;
还包括如第二方面或第二方面的第一种可能的实现方式至第五种可能的实现方式中的任一种可能的实现方式所述的数据访问装置,用于根据接收的数据访问请求访问所述数据库,以从所访问的数据表中获取所访问的数据。
第四方面,提供另一种数据访问装置,该数据访问装置包括用于执行第一方面的方法的模块。
本发明实施例中的数据库同时支持如上的两种数据存储方式,这样针对不同的数据可以选择不同的存储方式,而在访问数据时只需根据访问请求确定待访问的数据所在的数据表的类型就知道该如何访问数据,实现方式简单,便于推广利用。
附图说明
为了更清楚地说明本发明实施例的技术方案,下面将对本发明实施例中所需要使用的附图作简单地介绍,显而易见地,下面所介绍的附图仅仅是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。
图1A-图1B为数据库中的第一种存储方式的两种示意图;
图2为数据库中的第二种存储方式示意图;
图3为本发明实施例中数据库中的存储方式示意图;
图4A-图4B为本发明实施例中数据访问装置的结构示意图;
图5为本发明实施例中数据访问系统的结构示意图;
图6为本发明实施例中的数据访问方法的流程图;
图7为本发明实施例中数据访问装置的结构框图。
具体实施方式
为使本发明实施例的目的、技术方案和优点更加清楚,下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。
首先简单介绍数据库的两种数据存储方式。
第一种存储方式:以物理数据表类型的数据表存储数据。
在建立物理数据表类型的数据表时,是用户通过APP直接在数据库中建立,例如用户在数据库中建立了几个物理数据表类型的数据表,请参见图1A,分别为数据表1、数据表2和数据表3,当然,在建立一个数据表后,还要建立该数据表对应的索引,索引一般跟数据表存储在一起。以及,在建立一个数据表后,还要对该数据表中的表结构、字段等进行定义,这些定义可以放在数据表的可扩展标记语言(XML)信息中,XML信息也可以跟数据表存储在一起。
APP比如要访问数据表1,则可以通过应用服务层的JDBC接口直接访问 数据表1,比如在访问时可以先获取数据表1的索引,从而根据索引定位待访问的数据。或者,APP也可以不经过应用服务层而直接访问数据库,请参见图1B,例如用户在数据库中建立了几个物理数据表类型的数据表,分别为数据表1、数据表2和数据表3,用户可以通过操作APP直接访问这些数据表,而无需经过应用服务层。
其中,APP和应用服务层可以看做两个功能模块,这两个功能模块一般通过软件方式实现,这两个功能模块可以位于同一设备中,或者也可以位于不同的设备中。JDBC接口一般是应用服务层提供的接口,供APP访问数据库。
另外,数据库也可以看做功能模块,一般可以通过设备中的存储器件来实现。APP、应用服务层和数据库这三个功能模块可以位于同一设备中,或者也可以分别位于不同的设备中,或者也可以其中的任意两个功能模块位于同一设备中,等等。
第二种存储方式:以对象数据表类型的数据表存储数据。
在建立对象数据表时,首先需建立元数据表,比如系统可以提供专门用于建立元数据表的界面,用户可以直接在该界面中建立元数据表。用户输入完毕后可以选择提交,例如请参见图2,位于应用服务层的元数据驱动引擎可以根据用户输入的内容在数据库中建立元数据表,并根据用户输入的内容生成元数据表中的元数据,例如元数据可以包括即将建立的对象数据表中的表结构的定义、字段结构的定义、索引定义、表对象之间的关系的定义等,元数据驱动引擎还可以在数据库中建立对应的对象数据表,以存储数据。另外,元数据驱动引擎还可以在数据库中建立用于查询对象数据表中的数据的索引表。
其中,一个对象数据表中可以存储各种互不相关的数据,因此,数据库中可以只需建立一个对象数据表即可,当然建立多个对象数据表的方案也在本发明实施例的保护范围之内。
其中,如果数据库中已经建立了元数据表,那么元数据驱动引擎无需再建立新的元数据表,而直接根据用户提交的内容生成元数据,并将元数据放入已生成的元数据表即可。如果数据库中已经建立了对象数据表,则元数据驱动引 擎无需建立新的对象数据表,而将要存储的数据放入已建立的对象数据表即可。如果数据库中已经建立了索引表,那么元数据驱动引擎无需再建立新的索引表,而直接将新的数据的索引加入已建立的索引表即可。
APP比如要访问对象数据表,则可以通过元数据驱动引擎从元数据表中获取对象数据表的表结构等定义,再通过元数据驱动引擎根据索引表进行查询,获得对象数据表中的数据。
本发明实施例中的数据库同时支持如上的两种数据存储方式,这样针对不同的数据可以选择不同的存储方式,而在访问数据时只需根据访问请求确定待访问的数据所在的数据表的类型就知道该如何访问数据,实现方式简单,便于推广利用。
请参见图3,为本发明实施例中数据库的存储方式示意图。
图3中,数据表1为物理数据表类型的数据表,数据表2为对象数据表类型的数据表,另外数据库中还存储了与数据表2对应的元数据表及索引表,其中数据表1的索引与数据表1存储在一起,图3中未画出。另外,图3中是以一个物理数据表类型的数据表为例,在实际应用中,数据库中可能存储多个物理数据表类型的数据表。
另外,本发明实施例提供同样位于应用服务层的混合引擎,混合引擎能够分别与用于访问对象数据表的元数据驱动引擎以及用于访问物理数据表的物理数据表访问引擎通信,混合引擎可以接收通过APP输入的访问请求,在确定待访问的数据所在的数据表究竟是哪种类型的数据表后,混合引擎可以调用相应的引擎(元数据驱动引擎或物理数据表访问引擎)来响应访问请求,元数据驱动引擎或物理数据表访问引擎获得待访问的数据后,可以直接反馈给APP,不通过混合引擎,或者也可以将待访问的数据反馈给混合引擎,由混合引擎反馈给APP,从而实现对不同类型的数据表的访问。
可选的,元数据驱动引擎和物理数据表访问引擎可以位于混合引擎中,即混合引擎可以包括元数据驱动引擎和物理数据表访问引擎,当然混合引擎还可以包括其他的功能模块,或者混合引擎、元数据驱动引擎和物理数据表访问引 擎也可以是三个独立的模块,混合引擎能够分别与元数据驱动引擎和物理数据表访问引擎进行通信(图3以此为例)。
其中,本发明实施例提供物理数据表访问引擎,用于访问物理数据表类型的数据表,物理数据表访问引擎可以是JDBC接口,或者也可以是其他的用于访问物理数据表类型的数据表的接口或引擎。
下面结合附图介绍本发明实施例提供的技术方案。
请参见图4A,本发明实施例提供一种数据访问装置,该数据访问装置可以包括存储器401、处理器402和接收器403。
其中,处理器402可以是中央处理器(CPU)或特定应用集成电路(Application Specific Integrated Circuit,ASIC),可以是一个或多个用于控制程序执行的集成电路,可以是使用现场可编程门阵列(Field Programmable Gate Array,FPGA)开发的硬件电路,可以是基带芯片。
存储器401的数量可以是一个或多个。存储器401可以包括只读存储器(Read Only Memory,ROM)、随机存取存储器(Random Access Memory,RAM)和磁盘存储器。
接收器403可以用于与外部设备进行通信,例如接收器403可以与APP进行通信。
可选的,请参见图4B,该装置还可以包括发送器404,可以用于与外部设备进行通信,例如发送器404也可以与APP进行通信。
发送器404和接收器403可以是同一实体模块,例如可以是能够实现收发功能的实体模块,比如可以称为收发器,或者发送器404和接收器403也可以是单独的实体模块。
这些存储器401、发送器404和接收器403可以通过总线与处理器402相连接(图4A-图4B以此为例),或者也可以通过专门的连接线分别与处理器402连接。
通过对处理器402进行设计编程,将下面所示的方法所对应的代码固化到芯片内,从而使芯片在运行时能够执行下面图5所示的方法。如何对处理器 402进行设计编程为本领域技术人员所公知的技术,这里不再赘述。
其中,该数据访问装置可以实现如图3中的混合引擎的功能。该数据访问装置可以通过软件方式实现,比如可以是固化在设备中的一套软件程序,或者也可以通过硬件方式实现,比如可以是在设备中新增的硬件模块,或者也可以利用设备中原有的硬件模块实现,比如处理器402可以由设备中的数据处理系统实现,存储器401可以由设备中的存储器件实现,或者存储器401也可以由设备中的数据处理系统的内部缓存实现,发送器404和接收器403可以由设备中的数据收发系统实现。
请参见图5,基于同一发明构思,本发明实施例还提供一种数据访问系统,该数据访问系统可以包括数据库,还可以包括如图4A或图4B所示的数据访问装置。其中,该系统中的数据库和数据访问装置可以位于同一设备中(图5以此为例),比如可以位于同一服务器中,或者也可以位于不同的设备中,比如可以位于不同的服务器中,或者也可以位于不同的其他类型的设备中。
下面介绍本发明实施例提供的方法。
请参见图6,本发明实施例提供一种数据访问方法,该方法可以由如前所述的数据访问装置来执行,该方法的流程介绍如下。
步骤601:接收数据访问请求;
步骤602:确定数据访问请求所访问的数据表的存取类型;其中,数据表的存取类型包括物理数据表类型及以元数据形式存储在数据库中的对象数据表类型;
步骤603:根据确定的数据表的存取类型,从所访问的数据表中获取所访问的数据。
接收器403可以接收APP输入的数据访问请求,例如,APP输入的数据访问请求可以是结构化查询语言(Structured Query Language,SQL)语句。可选的,数据访问请求中可以携带所访问的数据表的信息,数据表的信息例如可以包括数据表的存取类型、名称或身份标识号(identity,ID)等。
处理器402可以确定数据访问请求所访问的数据表的存取类型。可选的, 如果数据访问请求中直接携带了所访问的数据表的存取类型,则处理器402可以直接根据数据访问请求确定所访问的数据表的存取类型,如果数据访问请求中携带的是数据表的其他信息,例如携带的是数据表的ID或数据表的名称等,则处理器402还需确定所访问的数据表的存取类型。因此,存储器401中可以预先存储数据表的信息与数据表的存取类型之间的对应关系,这样处理器402接收数据访问请求后,可以获取数据访问请求中携带的数据表的信息,再根据存储的数据表的信息与数据表的存取类型之间的对应关系确定待访问的数据表的类型。例如,存储器401中预先存储的是数据表的ID与数据表的存取类型之间的对应关系,那么,APP发送的数据访问请求中携带的也应该是数据表的ID,这样处理器402接收数据访问请求后,可以获取数据访问请求中携带的数据表的ID,再根据存储的数据表的ID与数据表的存取类型之间的对应关系确定待访问的数据表的存取类型。
以下通过两个例子来介绍本发明实施例中的数据存储及访问方法。
例1:
例如,需要在数据库中增加两个数据表,分别为综合账单表(例如称为BILL_SUM)和细节账单表(例如称为BILL_DETAIL),用于记录客户产生的账单记录。
例如BILL_SUM的数据规模为6千万条,BILL_SUM的表结构请参考表1:
表1
Figure PCTCN2016103414-appb-000001
Figure PCTCN2016103414-appb-000002
例如BILL_DETAIL的数据规模是BILL_SUM的10倍,估计是6亿条数据,BILL_DETAIL的表结构请参考表2:
表2
Figure PCTCN2016103414-appb-000003
物理数据表类型的数据表较为灵活,访问速度较快,但经常需改造APP,比较麻烦,对象数据表类型的数据表在访问时基本无需改造APP,但因为包括的数据过多,访问速度相较于物理数据表类型的数据表来说较慢,因此,本发明实施例中,针对不同的数据可以采用不同的存储方式,针对数据量较小的数据可以采用对象数据表类型的数据表存储,因为数据量较小,访问速度也不是太慢,还可以尽量利用对象数据表类型的数据表无需改造APP的优势,针对数 据量较大的数据,如果采用对象数据表类型的数据表进行存储的话可能访问速度会受到影响,因此可以考虑采用物理数据表类型的数据表存储,以尽量提升访问速度,避免系统性能受损。
可选的,可以预先设置预设阈值,并将设置的预设阈值存储在存储器401中,如果需存储的数据量小于等于该预设阈值,则可以将这些数据存储在对象数据表类型的数据表中,如果需存储的数据量大于该预设阈值,则可以将这些数据存储在物理数据表类型的数据表中。预设阈值可以由处理器402自行设定,比如处理器402可以根据存储经验进行设定,或者也可以由用户设定。
例如在例1中,该预设阈值为8千万,那么显然,BILL_SUM的类型可以是对象数据表类型,BILL_DETAIL的类型可以是物理数据表类型。
例如,存储器401中可以存储数据表的其他信息与数据表的存取类型之间的对应关系(例如将该对应关系存储在一个名为对象类型表的数据表中),比如例1中存储的是数据表的名称与数据表的存取类型之间的对应关系,请参见表3:
表3
数据表名称 存取类型 数据规模 数据表结构信息
BILL_SUM Metadata 6千万 元数据
BILL_DETAIL 物理数据表类型 6亿 XML表结构信息
对象类型表中除了存储数据表的名称与数据表的存取类型之间的对应关系外,还可以存储不同的数据表的数据规模、数据表结构信息等信息,可继续参考表3,对象类型表只要能够用于令处理器402确定数据访问请求所请求访问的数据表的存取类型即可,对于对象类型表中存储的其他信息本发明实施例不作限制。
在App需要访问BILL_DETAIL或BILL_SUM中的数据时,可以向数据访问装置发送数据访问请求,该数据访问请求可以是通用的SQL访问请求,例1中,数据访问请求中可以携带待访问的数据表的名称,接收器403接收访问请 求后,处理器402可以根据对象类型表确定待访问的数据表的存取类型。
如果数据访问请求中携带的数据表的名称为BILL_DETAIL,则处理器402确定待访问的数据表的存取类型为物理数据表类型,处理器402可以调用物理数据表访问引擎。物理数据表访问引擎获取该数据访问请求,获取该数据访问请求所请求访问的表结构、字段等信息,根据BILL_DETAIL的XML信息确定根据获取的表结构、字段等信息的定义,再通过BILL_DETAIL的索引在BILL_DETAIL中访问所需的数据。其中,如果数据访问请求中未携带表结构、字段等信息,则物理数据表访问引擎可能认为需访问所有表结构、字段等对应的数据,那么物理数据表访问引擎可以根据BILL_DETAIL的XML信息对该数据访问请求进行重新拼装,在该数据访问请求中添加BILL_DETAIL的所有的表结构、字段等信息,再通过BILL_DETAIL的索引在BILL_DETAIL中访问所需的数据。之后,物理数据表访问引擎可以直接将所访问的数据反馈给APP,或者,物理数据表访问引擎也可以将所访问的数据反馈给数据访问装置,由处理器402通过发送器404反馈给APP。
如果数据访问请求中携带的数据表的名称为BILL_SUM,则处理器402确定待访问的数据表的存取类型为对象数据表类型,处理器402可以调用元数据驱动引擎。元数据驱动引擎获取该数据访问请求,获取该数据访问请求所请求访问的表结构、字段等信息,根据元数据表确定根据获取的表结构、字段等信息的定义,再通过索引表在BILL_SUM中访问所需的数据。之后,元数据驱动引擎可以直接将所访问的数据反馈给APP,或者,元数据驱动引擎也可以将所访问的数据反馈给数据访问装置,由处理器402通过发送器404反馈给APP。
例2:
例如,需要在数据库中新增账单类型表(例如称为Bill_TYPE)和细节账单表(例如称为BILL_DETAIL),其中,建立BILL_DETAIL的方式可参考例1的描述。
例如Bill_TYPE的数据量不大,小于预设阈值(例如预设阈值为8千万),因此可以考虑采用对象数据表类型的数据表进行存储。因为数据库中已经存储了 元数据表、对象数据表类型的数据表及索引,那么可以直接将Bill_TYPE的元数据放入元数据表、将Bill_TYPE中的数据放入对象数据表、及将Bill_TYPE中的数据的索引信息放入索引表即可。例如Bill_TYPE的表结构可参考表4:
表4
字段名称 编码 数据类型 长度 必选字段
帐目标识 BILL_ITEM_CODE NUMBER(5) 5 TRUE
帐目类型 ITEM_TYPE NUMBER(5) 5 TRUE
帐目名称 BILL_ITEM_NAME VARCHAR2(32) 32 FALSE
存储器401存储的对象类型表可参考表5::
表5
数据表名称 存取类型 数据规模 数据表结构信息
BILL_TYPE Metadata 1千 元数据
BILL_DETAIL 物理数据表类型 6亿 XML表结构信息
在App需要访问BILL_DETAIL或BILL_TYPE中的数据时,可以向数据访问装置发送数据访问请求,该数据访问请求可以是通用的SQL访问请求,数据访问请求中可以携带待访问的数据表的名称,接收器403接收访问请求后,处理器402根据对象类型表确定待访问的数据表的存取类型。例如APP发送的数据访问请求为SQL查询请求,该SQL查询请求例如为:select A.*,B.BILL_ITEM_NAME FROM BILL_DETAIL A、Bill_TYPE B WHERE A.ACCT_ID=11332AND A.BILL_ITEM_CODE=B.BILL_ITEM_CODE(+)。很明显,这个SQL查询请求需查询两种不同存取类型的数据表中的数据。那么可选的,对于两个数据表中的数据可以进行关联(join)操作,将关联操作的结果作为反馈给APP的数据访问结果。在进行关联操作时,首先可以根据数据访问请求确定所访问的数据表中哪个是主表哪个是从表,比如根据上面的数据访问请求,处理器402可以确定BILL_DETAIL为主表,BILL_TYPE为从表,则处理 器402可以将从表中获取的数据分别与主表中获取的数据进行关联操作。下面介绍关联过程。
处理器402调用物理数据表访问引擎,通过物理数据表访问引擎获得BILL_DETAIL中的待访问的数据,例如获得M个第一数据,处理器402可以将M个第一数据先存储在缓存中,缓存可以由存储器401提供,或者也可以由处理器402提供。处理器402还需要调用元数据驱动引擎,以通过元数据驱动引擎获得BILL_TYPE中的待访问的数据,那么,如果处理器402直接通过元数据驱动引擎一次性获得BILL_TYPE中的待访问的全部数据(例如将从BILL_TYPE中获取的待访问数据称为第二数据,比如共可以获得N个第二数据)之后再进行关联操作,就需要将M个第一数据和N个第二数据一起存储在缓存中,这样需要占用较大的空间,比较浪费资源,也需要数据访问装置具有较好的性能,因此,可选的,在获得M个第一数据后,处理器402可以调用元数据驱动引擎从BILL_TYPE中依次获得第二数据,比如,每获得一个第二数据,处理器402就可以按照关联条件将获得的第二数据与M个第一数据进行关联,看获得的第二数据是否能与M个第一数据中的至少一个第一数据关联起来,如果获得的第二数据能与至少一个第一数据关联,即获得的第二数据与至少一个第一数据能够满足关联条件,则处理器402就获得了一组关联数据,这组关联数据包括该获得的第二数据与至少一个第一数据,这组关联数据就是待访问的数据中的数据,相当于处理器402需进行N次关联操作,在从BILL_TYPE中获得最后一个第二数据(即第N个第二数据)后,处理器402进行第N次关联操作,在第N次关联操作完毕后,处理器402可以得到待访问的数据,待访问的数据可以包括K组关联数据,K为小于等于N且大于等于0的整数,这K组关联数据就是待访问的数据。
其中,从数据表中获得第一数据和第二数据的方式可参考如前实施例的描述,不多赘述。关联条件可以是数据访问请求中携带的,处理器402可以通过解析数据访问请求获得关联条件,从而对M个第一数据和N个第二数据进行关联。
下面再通过一个例子来介绍关联操作的过程。
比如数据访问请求为:select a.telnumber,a.name,a.productid,b.product_name from USER_ORDER A,PRODUCT B where A.telnumber=“13912345678”,b.product_type=“全球通”,A.productid=B.productid。其中A表(即USER_ORDER)包括1亿条数据,A表的存取类型为物理数据表类型,B表(即PRODUCT)包括5000条数据,B表的存取类型为对象数据表类型,A表中符合A.telnumber=“13912345678”条件的数据比如有200条,B表中符合product_type=“全球通”条件的数据比如有300条。处理器402首先可以根据数据访问请求确定数据表的主从关系,例如规则可以是将数据量大的数据表作为主表,将其他数据表作为从表,即将A表作为主表,将B表作为从表。在确定主从关系后,处理器402首先根据数据访问请求确定主表中的数据的获取条件,即确定数据访问请求中携带的针对主表的访问条件,例如按照上面的数据访问请求可知,A.telnumber=“13912345678”为针对主表的访问条件,处理器402调用物理数据表访问引擎,从主表中提取符合第一访问条件的数据,处理器402再根据数据访问请求确定从表中的数据的获取条件,即确定数据访问请求中携带的针对从表的访问条件,例如按照上面的数据访问请求可知,product_type=“全球通”为针对从表的访问条件。可选的,每从从表中提取一个数据,就可以将提取的数据与主表中的数据进行关联操作,关联条件可以携带在数据访问请求中,比如该例的数据访问请求中,A.productid=B.productid即为关联条件。其中,从表中获取的一个数据可能与主表中的至少一个数据具有关联关系,那么可以将从表中的该数据与主表中获取的至少一个数据作为一组关联数据,或者,从表中的某些数据也可能与主表中获取的任何数据都不具有关联关系,即都不满足关联条件,那么从表中获取的无法与主表中获取的任何数据关联的数据可能不是APP要访问的数据,可以丢弃这部分数据,这样也有利于节省存储空间。
可选的,在得到所有的关联数据后,可以仅将得到的关联数据作为所访问的数据进行反馈,而对于从表中获取的无法与主表中获取的任何数据关联的数 据,以及对于主表中获取的无法与从表中获取的任何数据关联的数据,都可以丢弃。或者,在得到所有的关联数据后,不仅可以将得到的关联数据作为所访问的数据进行反馈,还可以将主表中获取的无法与从表中获取的任何数据关联的数据也作为所访问的数据进行反馈,这样用户得到的数据更完整。
在得到所访问的数据后,处理器402可以通过发送器404将所访问的数据反馈给APP,或者在得到所访问的数据后,处理器402也可以对所访问的数据进行排序(比如例2中可以按照账单类型进行排序),之后再通过发送器404反馈给APP。
前面的几个例子介绍了分开访问以及关联访问,即本发明实施例提供的技术方案根据不同的数据访问请求能够提供不同的访问结果,以满足不同的需求。
可选的,处理器402还可以扫描数据库中存储的各种类型的数据表,比如可以定时或周期性扫描,或者也可以在用户的触发下进行扫描。比如扫描确定数据库中存储的第三数据表中包括的数据量大于预设阈值,处理器402可以确定第三数据表的存取类型,例如第三数据表的存取类型为对象数据表类型,那么为了提高数据库的访问性能,处理器402可以向APP发送消息,APP可以向用户输出第一提示信息,第一提示信息可以用于指示将第三数据表的存取类型转换为物理数据表类型。用户接收第一提示信息后,如果接受建议,则可以重新以物理数据表类型存储第三数据表中包括的数据。
可选的,用户在需建立数据表时,可以先通过APP向数据访问装置发送请求消息,例如用户需建立第四数据表,则用户通过APP向数据访问装置发送请求消息,该请求消息中可以携带第四数据表包括的数据量。接收器403接收APP发送的请求消息,处理器402可以确定第四数据表的数据量是否大于存储器401中存储的预设阈值,从而给出针对第四数据表的存储指示,例如如果第四数据表包括的数据量大于预设阈值,则处理器402可以指示以物理数据表类型的存储方式建立第四数据表,如果第四数据表包括的数据量小于等于预设阈值,则处理器402可以指示以对象数据表类型的存储方式建立第四数据表,发送器404可以将处理器402的指示发送给APP,APP可以输出第二提示信息。例如,如 果第四数据表包括的数据量大于预设阈值,则第二提示信息可以用于指示以物理数据表类型的存储方式建立第四数据表,如果第四数据表包括的数据量小于等于预设阈值,则第二提示信息可以用于指示以对象数据表类型的存储方式建立第四数据表,用户后续可以根据第二提示信息来建立第四数据表。
这样,根据不同的数据量可以建立不同类型的数据表,使得数据库中的存储方式更为合理,尽量提高访问性能。
请参见图7,基于同一发明构思,本发明实施例还提供一种数据访问装置,该装置可以包括接收模块701和处理模块702,可选的,该装置还可以包括发送模块703。
在实际应用中,该装置可以通过软件方式实现,或者也可以通过硬件方式实现,比如,该装置中的处理模块702对应的实体设备可以是图4A-图4B中的处理器402,接收模块701对应的实体设备可以是图4A-图4B中的接收器403,发送模块703对应的实体设备可以是图4B中的发送器404。
该装置可以用于执行上述图6所述的方法,因此,对于该装置中的各单元所实现的功能等,可参考如前方法部分的描述,不多赘述。
本发明实施例中,数据库可以同时支持两种存储方式,即数据库中的数据表的存取类型可以包括物理数据表类型及对象数据表类型,这样,针对不同的数据可以采用不同的存储方式,一方面可以考虑数据量较小的数据的存储灵活性,比如可以采用对象数据表类型的数据表存储数据量较小的数据,另一方面也可以考虑数据量较大的数据的高访问性能,比如可以采用物理数据表类型的数据表存储数据量较大的数据,等等,分别为不同的数据提供较为适合的存储方式,使得数据库中的存储方式更为合理。在访问数据时只需根据访问请求确定所访问的数据所在的数据表的类型即可实现对数据的访问,实现较为简单,便于推广使用。
在本发明中,应该理解到,所揭露的装置、系统和方法,可以通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如,所述单元或单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式, 例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,装置或单元的间接耦合或通信连接,可以是电性或其它的形式。
所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本发明实施例。
在本发明实施例中的各功能单元可以集成在一个处理单元中,或者各个单元也可以均是独立的物理模块。
所述集成的单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本发明的技术方案的全部或部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)或处理器(processor)执行本发明各个实施例所述方法的全部或部分步骤。而前述的存储介质包括:通用串行总线闪存盘(Universal Serial Bus flash drive)、移动硬盘、ROM、RAM、磁碟或者光盘等各种可以存储程序代码的介质。
以上所述,以上实施例仅用以对本发明的技术方案进行了详细介绍,但以上实施例的说明只是用于帮助理解本发明实施例的方法,不应理解为对本发明实施例的限制。本技术领域的技术人员可轻易想到的变化或替换,都应涵盖在本发明实施例的保护范围之内。

Claims (19)

  1. 一种数据访问方法,其特征在于,包括:
    接收数据访问请求;
    确定所述数据访问请求所访问的数据表的存取类型;其中,数据表的存取类型包括物理数据表类型及以元数据形式存储在数据库中的对象数据表类型;
    根据确定的数据表的存取类型,从所访问的数据表中获取所访问的数据。
  2. 如权利要求1所述的方法,其特征在于,所述确定所述数据访问请求所访问的数据表的存取类型,包括:
    获取所述数据访问请求所携带的待访问的第一数据表的信息及第二数据表的信息;
    根据存储的数据表的信息与数据表的存取类型之间的对应关系确定所述第一数据表的存取类型为所述物理数据表类型,及所述第二数据表的存取类型为所述对象数据表类型。
  3. 如权利要求2所述的方法,其特征在于,所述根据确定的数据表的存取类型,从所访问的数据表中获取所访问的数据,包括:
    根据所述数据访问请求携带的针对所述第一数据表的第一访问条件,从所述第一数据表中获取符合所述第一访问条件的M个第一数据;
    根据所述数据访问请求携带的针对所述第二数据表的第二访问条件,从所述第二数据表中获取符合所述第二访问条件的N个第二数据;M、N均为正整数;
    在获取所述N个第二数据的过程中,每获取一个第二数据,将获取的第二数据与所述M个第一数据进行关联操作,在进行N次关联操作后,得到所访问的数据。
  4. 如权利要求3所述的方法,其特征在于,所述将获取的第二数据与所述M个第一数据进行关联操作,包括:
    获取所述数据访问请求中携带的关联条件;所述关联条件用于将所述M个 第一数据及所述N个第二数据进行关联操作;
    确定所述获取的第二数据是否与所述M个第一数据中的至少一个第一数据满足所述关联条件;
    若所述获取的第二数据与所述至少一个第一数据满足所述关联条件,则得到包括所述获取的第二数据与所述至少一个第一数据的一组关联数据。
  5. 如权利要求1-4任一所述的方法,其特征在于,所述方法还包括:
    若所述数据库中存储的第三数据表包括的数据量大于预设阈值,且所述第三数据表的类型为所述对象数据表类型,则输出第一提示信息;所述第一提示信息用于指示将所述第三数据表的类型转换为所述物理数据表类型。
  6. 如权利要求1-5任一所述的方法,其特征在于,所述方法还包括:
    接收用于请求建立第四数据表的请求消息;所述请求消息中携带所述第四数据表包括的数据量;
    若所述第四数据表包括的数据量大于预设阈值,输出第二提示信息,所述第二提示信息用于指示以所述物理数据表类型建立所述第四数据表;或,若所述第四数据表包括的数据量小于等于预设阈值,输出第二提示信息,所述第二提示信息用于指示以所述对象数据表类型建立所述第四数据表。
  7. 一种数据访问装置,其特征在于,包括:
    接收模块,用于接收数据访问请求;
    处理模块,用于确定所述数据访问请求所访问的数据表的存取类型;其中,数据表的存取类型包括物理数据表类型及以元数据形式存储在数据库中的对象数据表类型;
    所述处理模块,还用于根据确定的数据表的存取类型,从所访问的数据表中获取所访问的数据。
  8. 如权利要求7所述的装置,其特征在于,所述处理模块用于:
    获取所述数据访问请求所携带的待访问的第一数据表的信息及第二数据表的信息;
    根据存储的数据表的信息与数据表的存取类型之间的对应关系确定所述第 一数据表的存取类型为所述物理数据表类型,及所述第二数据表的存取类型为所述对象数据表类型。
  9. 如权利要求8所述的装置,其特征在于,所述处理模块用于:
    根据所述数据访问请求携带的针对所述第一数据表的第一访问条件,从所述第一数据表中获取符合所述第一访问条件的M个第一数据;
    根据所述数据访问请求携带的针对所述第二数据表的第二访问条件,从所述第二数据表中获取符合所述第二访问条件的N个第二数据;M、N均为正整数;
    在获取所述N个第二数据的过程中,每获取一个第二数据,将获取的第二数据与所述M个第一数据进行关联操作,在进行N次关联操作后,得到所访问的数据。
  10. 如权利要求9所述的装置,其特征在于,所述处理模块用于:
    获取所述数据访问请求中携带的关联条件;所述关联条件用于将所述M个第一数据及所述N个第二数据进行关联操作;
    确定所述获取的第二数据是否与所述M个第一数据中的至少一个第一数据满足所述关联条件;
    若所述获取的第二数据与所述至少一个第一数据满足所述关联条件,则得到包括所述获取的第二数据与所述至少一个第一数据的一组关联数据。
  11. 如权利要求7-10任一所述的装置,其特征在于,所述装置还包括发送模块;
    所述处理模块,还用于确定所述数据库中存储的第三数据表包括的数据量大于预设阈值,且所述第三数据表的类型为所述对象数据表类型;
    所述发送模块,用于输出第一提示信息;所述第一提示信息用于指示将所述第三数据表的类型转换为所述物理数据表类型。
  12. 如权利要求7-11任一所述的装置,其特征在于,所述装置还包括发送模块;
    所述接收模块,还用于接收用于请求建立第四数据表的请求消息;所述请 求消息中携带所述第四数据表包括的数据量;
    所述处理模块,还用于确定所述第四数据表包括的数据量大于预设阈值,或确定所述第四数据表包括的数据量小于等于预设阈值;
    所述发送模块,用于:若所述处理模块确定所述第四数据表包括的数据量大于预设阈值,输出第二提示信息,所述第二提示信息用于指示以所述物理数据表类型建立所述第四数据表;或,若所述处理模块确定所述第四数据表包括的数据量小于等于预设阈值,输出第二提示信息,所述第二提示信息用于指示以所述对象数据表类型建立所述第四数据表。
  13. 一种数据访问装置,其特征在于,包括:
    存储器,用于存储指令;
    接收器,用于接收数据访问请求;
    处理器,用于执行所述指令,确定所述数据访问请求所访问的数据表的存取类型;其中,数据表的存取类型包括物理数据表类型及以元数据形式存储在数据库中的对象数据表类型;根据确定的数据表的存取类型,从所访问的数据表中获取所访问的数据。
  14. 如权利要求13所述的装置,其特征在于,所述处理器用于:
    获取所述数据访问请求所携带的待访问的第一数据表的信息及第二数据表的信息;
    根据存储的数据表的信息与数据表的存取类型之间的对应关系确定所述第一数据表的存取类型为所述物理数据表类型,及所述第二数据表的存取类型为所述对象数据表类型。
  15. 如权利要求14所述的装置,其特征在于,所述处理器用于:
    根据所述数据访问请求携带的针对所述第一数据表的第一访问条件,从所述第一数据表中获取符合所述第一访问条件的M个第一数据;
    根据所述数据访问请求携带的针对所述第二数据表的第二访问条件,从所述第二数据表中获取符合所述第二访问条件的N个第二数据;M、N均为正整数;
    在获取所述N个第二数据的过程中,每获取一个第二数据,将获取的第二数据与所述M个第一数据进行关联操作,在进行N次关联操作后,得到所访问的数据。
  16. 如权利要求15所述的装置,其特征在于,所述处理器用于:
    获取所述数据访问请求中携带的关联条件;所述关联条件用于将所述M个第一数据及所述N个第二数据进行关联操作;
    确定所述获取的第二数据是否与所述M个第一数据中的至少一个第一数据满足所述关联条件;
    若所述获取的第二数据与所述至少一个第一数据满足所述关联条件,则得到包括所述获取的第二数据与所述至少一个第一数据的一组关联数据。
  17. 如权利要求13-16任一所述的装置,其特征在于,所述装置还包括发送器;所述处理器还用于:
    若确定所述数据库中存储的第三数据表存储的数据量大于预设阈值,且所述第三数据表的类型为所述对象数据表类型,则通过所述发送器输出第一提示信息;所述第一提示信息用于指示将所述第三数据表的类型转换为所述物理数据表类型。
  18. 如权利要求13-17任一所述的装置,其特征在于,所述装置还包括发送器;
    所述接收器还用于:接收用于请求建立第四数据表的请求消息;所述请求消息中携带所述第四数据表包括的数据量;
    所述处理器还用于:若确定所述第四数据表包括的数据量大于预设阈值,通过所述发送器输出第二提示信息,所述第二提示信息用于指示以所述物理数据表类型建立所述第四数据表;或,若确定所述第四数据表包括的数据量小于等于预设阈值,通过所述发送器输出第二提示信息,所述第二提示信息用于指示以所述对象数据表类型建立所述第四数据表。
  19. 一种数据访问系统,其特征在于,包括:
    数据库,用于存储数据表;其中,数据表的存取类型包括物理数据表类型及以元数据形式存储在所述数据库中的对象数据表类型;
    还包括如权利要求13-18任一所述的数据访问装置,用于根据接收的数据访问请求访问所述数据库,以从所访问的数据表中获取所访问的数据。
PCT/CN2016/103414 2015-12-25 2016-10-26 一种数据访问方法、装置及系统 WO2017107652A1 (zh)

Priority Applications (2)

Application Number Priority Date Filing Date Title
EP16877463.6A EP3373159A4 (en) 2015-12-25 2016-10-26 Data access method, device and system
US16/016,059 US20180307716A1 (en) 2015-12-25 2018-06-22 Data Access Method, Apparatus, and System

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201510998317.3A CN106919607B (zh) 2015-12-25 2015-12-25 一种数据访问方法、装置及系统
CN201510998317.3 2015-12-25

Related Child Applications (1)

Application Number Title Priority Date Filing Date
US16/016,059 Continuation US20180307716A1 (en) 2015-12-25 2018-06-22 Data Access Method, Apparatus, and System

Publications (1)

Publication Number Publication Date
WO2017107652A1 true WO2017107652A1 (zh) 2017-06-29

Family

ID=59088955

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2016/103414 WO2017107652A1 (zh) 2015-12-25 2016-10-26 一种数据访问方法、装置及系统

Country Status (4)

Country Link
US (1) US20180307716A1 (zh)
EP (1) EP3373159A4 (zh)
CN (1) CN106919607B (zh)
WO (1) WO2017107652A1 (zh)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109815242B (zh) * 2019-02-02 2021-04-02 中国农业银行股份有限公司 一种数据处理方法及系统
US11947927B2 (en) * 2019-12-26 2024-04-02 Yahoo Assets Llc Sorting unsorted rows of a composite dataset after a join operation
CN113741889A (zh) * 2021-08-26 2021-12-03 北京深演智能科技股份有限公司 异构数据库智能存取数据的方法及设备
CN116846979B (zh) * 2023-08-29 2024-03-15 江苏睿鸿网络技术股份有限公司 一种云计算环境下资源的调度方法及调度系统

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1332877A (zh) * 1998-11-30 2002-01-23 联合想象计算机公司 关系数据库管理系统中用于支持动态运行时间对象定义的方法和装置
CN1647080A (zh) * 2002-04-25 2005-07-27 国际商业机器公司 多数据库环境中存取数据的方法、计算机程序和计算机
US20140028685A1 (en) * 2008-10-17 2014-01-30 Marcos Weskamp Generating customized effects for image presentation
CN104182487A (zh) * 2014-08-11 2014-12-03 浪潮软件股份有限公司 一种支持多种存储方式的统一存储方法
CN104462559A (zh) * 2014-12-25 2015-03-25 广东电子工业研究院有限公司 一种主流关系型数据库表模式对象化和虚拟化机制

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH11238188A (ja) * 1998-02-20 1999-08-31 Hitachi Ltd 設備の制御論理設定システム
US7571197B2 (en) * 2004-05-19 2009-08-04 Unisys Corporation Method and apparatus for synchronizing dataset object properties with underlying database structures
CN105045902A (zh) * 2015-08-07 2015-11-11 虎扑(上海)文化传播股份有限公司 一种数据查询的方法及系统

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1332877A (zh) * 1998-11-30 2002-01-23 联合想象计算机公司 关系数据库管理系统中用于支持动态运行时间对象定义的方法和装置
CN1647080A (zh) * 2002-04-25 2005-07-27 国际商业机器公司 多数据库环境中存取数据的方法、计算机程序和计算机
US20140028685A1 (en) * 2008-10-17 2014-01-30 Marcos Weskamp Generating customized effects for image presentation
CN104182487A (zh) * 2014-08-11 2014-12-03 浪潮软件股份有限公司 一种支持多种存储方式的统一存储方法
CN104462559A (zh) * 2014-12-25 2015-03-25 广东电子工业研究院有限公司 一种主流关系型数据库表模式对象化和虚拟化机制

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
See also references of EP3373159A4 *

Also Published As

Publication number Publication date
US20180307716A1 (en) 2018-10-25
EP3373159A1 (en) 2018-09-12
CN106919607A (zh) 2017-07-04
EP3373159A4 (en) 2018-09-12
CN106919607B (zh) 2020-09-08

Similar Documents

Publication Publication Date Title
US9916385B2 (en) Searching raw data from an external data system using a dual mode search system
WO2016165525A1 (zh) 在跨分区数据库中查询数据的方法及跨分区查询装置
US10311055B2 (en) Global query hint specification
US8793225B1 (en) Processing a system search request including external data sources and mixed modes
WO2017107652A1 (zh) 一种数据访问方法、装置及系统
KR101137147B1 (ko) 질의 강제 인덱싱
WO2019165665A1 (zh) 一种域名解析方法、服务器及系统
EP3173944B1 (en) Database access method and apparatus and database system
US10242051B2 (en) Efficient multi-tenant spatial and relational indexing
US20160217013A1 (en) Method and system for generating a virtual device resource accessible by an application
WO2018040722A1 (zh) 表数据查询方法及装置
US20120130973A1 (en) Virtual objects in an on-demand database environment
CN103064875A (zh) 一种服务化空间数据分布式查询方法
US11556536B2 (en) Autonomic caching for in memory data grid query processing
CN108228743A (zh) 一种实时大数据搜索引擎系统
TWI686705B (zh) 分頁查詢方法及裝置和電子設備
WO2012139474A1 (zh) 数据的获取方法、设备和系统
EP3188051B1 (en) Systems and methods for search template generation
EP3311313B1 (en) Network server, methods and computer program product for providing data as a service (daas) in real-time
CN111723161A (zh) 一种数据处理方法、装置及设备
WO2019205790A1 (zh) 一种数据操作方法及装置
US10592506B1 (en) Query hint specification
CN110674177B (zh) 数据查询方法、装置、电子设备和存储介质
US10599728B1 (en) Metadata agent for query management
US10296503B2 (en) System and method for efficient database transactions

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 16877463

Country of ref document: EP

Kind code of ref document: A1

WWE Wipo information: entry into national phase

Ref document number: 2016877463

Country of ref document: EP

NENP Non-entry into the national phase

Ref country code: DE