Method, system and equipment for accessing data by adopting hypertype
By setting the super-type column in the database table and using the identification type OID matching, multiple types of data are realized in the same column, solving the complexity and space waste problems of existing database systems when storing multiple types of data, and improving storage efficiency and simplicity of data management.
Patent Information
- Application Number
- CN202411654213.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-19
- Publication Date
- 2025-02-25
AI Technical Summary
Existing database systems have complexity and space waste when dealing with multi-type data storage, resulting in complex database design, low storage efficiency and difficult data management.
The super-type access method is adopted to convert the data to be stored into super-type data by setting the super-type column in the table, and store and read it through identification type OID matching.
It realizes storing and reading different types of data in the same column, reducing the complexity of database design, avoiding waste of storage space, simplifying data management and maintenance, and ensuring data consistency and integrity.
Smart Images

Figure CN119513101A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of database management, and in particular to a method, system and device for accessing data using a supertype. Background Art
[0002] With the rapid development of Internet technology, database technology has also ushered in a period of vigorous development. As a core tool for information storage and management, databases have become an indispensable part of modern information technology architecture. In order to adapt to the ever-changing business needs and data types, database technology continues to evolve, and various types of database systems have emerged, such as relational databases, non-relational databases, time series databases, etc., to meet the data storage and management needs in different scenarios.
[0003] In practical applications, the types of data that users need to process are becoming increasingly diverse, including structured data, semi-structured data, and unstructured data. Each data type has its own unique characteristics and storage requirements. For example, structured data is usually stored in a relational database, while unstructured data may require a non-relational database to store. This diversity requires the database system to be able to flexibly handle different types of data. Although database technology provides a variety of solutions to deal with different data types, in practical applications, due to the differences between different data types, multiple types of data cannot be stored in the same column at the same time. This results in the need to use multiple columns or set up multiple tables to store different types of data separately when storing data. This practice not only increases the complexity of database design, but also causes a waste of storage space, affecting the efficiency and cost-effectiveness of data storage.
[0004] Existing database solutions have certain limitations when dealing with multi-type data storage. On the one hand, they often need to design specific storage solutions for each data type, which increases the complexity of database design; on the other hand, the storage method of multiple columns or multiple tables leads to a waste of data storage space, especially when the amount of data is huge. In addition, this decentralized storage method also increases the difficulty of data management and maintenance, affecting the consistency and integrity of the data.
[0005] Therefore, how to provide a database system that can efficiently and flexibly process and store multiple data types has become an urgent problem to be solved in the database field. Summary of the invention
[0006] In view of this, in order to overcome the deficiencies of the prior art, the present invention aims to provide a method, system and device for accessing data using a super type.
[0007] According to a first aspect of the present invention, there is provided a method for accessing data using a supertype, the method comprising: Set a super type column in the created table to convert the data to be stored into super type data; The super type data is converted and stored in the super type column through identification type OID matching; When reading data in a super type column, convert the super type data into identification type OID data; Parse the identification type OID data according to the identification type OID and return the display data to the user.
[0008] Preferably, in the method of accessing data using a super type of the present invention, a super type column is set in the created table, and the data to be stored is converted into super type data, including: when creating the table, the corresponding column in the table is set as a super type column, and when the user inserts the data to be stored, the data to be stored is converted into super type data through the CONVERT function.
[0009] Preferably, in the method of accessing data using supertype of the present invention, the data types stored in the supertype column include: char, varchar, varchar2, timestamp, timestamptz, date, nchar, nvarchar2, number, float and double data types.
[0010] Preferably, in the method for accessing data using a super type of the present invention, the super type data is converted and stored in a super type column by matching the identification type OID, including: Obtain the identification type OID of the super type data from the super type column through the identification type acquisition method; Matching the corresponding identification type OID for the converted super type data, calling the corresponding type input function according to the matched identification type OID, and converting the super type data into identification type OID data; The identification type OID obtained by the conversion is stored in the corresponding super type column.
[0011] Preferably, in the method of accessing data using a super type of the present invention, the identification type OID obtained by conversion is stored in a corresponding super type column, including: encapsulating the identification type OID and the identification type OID data obtained by conversion into data having a super type data format and storing them in the corresponding super type column in the created table.
[0012] Preferably, in the method for accessing data using a super type of the present invention, when reading data in a super type column, converting the super type data into identification type OID data includes: When the user reads the super type data in the super type column, the super type data is converted into identification type OID data through the ACCESS function; The identification type OID of the identification type OID data is obtained through the identification type obtaining method.
[0013] Preferably, in the method of accessing data using a super type of the present invention, the identification type OID data is parsed according to the identification type OID and the display data is returned to the user, including: calling the corresponding type output function according to the obtained identification type OID, using the called type output function to parse the identification type OID data according to the identification type OID, obtaining the display data and returning it to the user.
[0014] Preferably, in the method of accessing data using a super type of the present invention, the called type output function is used to parse the identification type OID data according to the identification type OID, including: the called type output function is used to parse the identification type OID data according to the storage format of the identification type OID.
[0015] According to a second aspect of the present invention, a system for accessing data using a supertype is provided, the system comprising an access server, the access server being used to: set a supertype column in a created table, convert the data to be stored into supertype data; convert and store the supertype data into the supertype column through identification type OID matching; when reading data in the supertype column, convert the supertype data into identification type OID data; parse the identification type OID data according to the identification type OID and return the display data to the user.
[0016] According to a third aspect of the present invention, a computer device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the method described in the first aspect of the present invention when executing the program.
[0017] The method, system and device for accessing data using super types of the present invention have the following beneficial technical effects: different types of data can be stored in the same column, and different types of data stored in the same column can be read, which significantly reduces the complexity of database design, avoids the waste of data storage space, reduces the difficulty of data management and maintenance, and ensures the consistency and integrity of data. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0019] Figure 1 This is a diagram showing an example of the architecture of a system using a supertype to access data according to an embodiment of the present invention; Figure 2 A flowchart of a method for accessing data using a supertype according to an embodiment of the present invention; Figure 3 A schematic diagram of the structure of the device provided by the present invention. DETAILED DESCRIPTION
[0020] The embodiments of the present invention are described in detail below with reference to the accompanying drawings.
[0021] It should be noted that the following embodiments and features in the embodiments may be combined with each other in the absence of conflict; and, based on the embodiments in the present disclosure, all other embodiments obtained by ordinary technicians in the field without making any creative work are within the scope of protection of the present disclosure.
[0022] It should be noted that various aspects of the embodiments within the scope of the appended claims are described below. It should be apparent that the aspects described herein may be embodied in a wide variety of forms, and any specific structure and / or function described herein is merely illustrative. Based on the present disclosure, it should be understood by those skilled in the art that an aspect described herein may be implemented independently of any other aspect, and two or more of these aspects may be combined in various ways. For example, any number of aspects described herein may be used to implement the device and / or practice the method. In addition, other structures and / or functionalities other than one or more of the aspects described herein may be used to implement this device and / or practice this method.
[0023] Figure 1 FIG. 4 is an exemplary diagram of the architecture of a system using supertypes to access data according to an embodiment of the present invention. Figure 1 As shown, the system may include an access server 101, a communication network 102 and / or one or more access clients 103. Figure 1 The example shown is a plurality of access clients 103 .
[0024] The access server 101 may be any suitable server for storing information, data, programs and / or any other suitable type of content. In some embodiments, the access server 101 may perform appropriate functions. For example, in some embodiments, the access server 101 may be used to access data using a super type. As an optional example, in some embodiments, the access server 101 may be used to: set a super type column in a created table, convert the data to be stored into super type data; convert and store the super type data into the super type column through identification type OID matching; when reading data in the super type column, convert the super type data into identification type OID data; parse the identification type OID data according to the identification type OID and return the display data to the user.
[0025] As another example, in some embodiments, the access server 101 may send a method for accessing data using a super type to the access client 103 for the user to use according to a request of the access client 103 .
[0026] As an optional example, in some embodiments, the access client 103 is used to provide a visual access interface, which is used to receive a user's selection input operation using super-type access data, and, in response to the selection input operation, obtain an access interface corresponding to the option selected by the selection input operation from the access server 101 and display the access interface, wherein at least information on using super-type access data and operation options for the information on using super-type access data are displayed in the access interface.
[0027] In some embodiments, the communication network 102 can be any suitable combination of one or more wired and / or wireless networks. For example, the communication network 102 can include any one or more of the following: the Internet, an intranet, a wide area network (WAN), a local area network (LAN), a wireless network, a digital subscriber line (DSL) network, a frame relay network, an asynchronous transfer mode (ATM) network, a virtual private network (VPN), and / or any other suitable communication network. The access client 103 can be connected to the communication network 102 via one or more communication links (e.g., communication link 104), and the communication network 102 can be linked to the access server 101 via one or more communication links (e.g., communication link 105). The communication link can be any communication link suitable for transmitting data between the access client 103 and the access server 101, such as a network link, a dial-up link, a wireless link, a hard-wired link, any other suitable communication link, or any suitable combination of such links.
[0028] The access client 103 may include any one or more clients that present an interface related to accessing data using a super type in an appropriate form for use and operation by a user. In some embodiments, the access client 103 may include any suitable type of device. For example, in some embodiments, the access client 103 may include a mobile device, a tablet computer, a laptop computer, a desktop computer, and / or any other suitable type of client device.
[0029] Although the access server 101 is illustrated as one device, in some embodiments, any suitable number of devices may be used to perform the functions performed by the access server 101. For example, in some embodiments, multiple devices may be used to implement the functions performed by the access server 101. Alternatively, the functions of the access server 101 may be implemented using a cloud service.
[0030] Based on the above system, an embodiment of the present invention provides a method for accessing data using a super type, which is described below through the following embodiments.
[0031] Figure 2 The method for accessing data using a supertype in this embodiment can be executed at the access server end, such as Figure 2 As shown, the method of accessing data using a super type includes the following steps: Step S201: setting a super type column in the created table to convert the data to be stored into super type data.
[0032] When creating a table, the corresponding column in the table is set as a super type column. When the user inserts data to be stored, the data to be stored is converted into super type data through the CONVERT function.
[0033] It should be noted that the supertype column in this embodiment can store different types of data according to the needs of the user, that is, different types of data can be stored in one column. For example, the data types stored in the supertype column include: char, varchar, varchar2, timestamp, timestamptz, date, nchar, nvarchar2, number, float, and double data types. For example, when creating a table, specify a column as the supertype anydata, such as CREATE TABLE t(a ANYDATA), then column a can store different types of data, including char, varchar, varchar2, timestamp, timestamptz, date, nchar, nvarchar2, number, float, double, etc. Users can also store other types of data according to actual scenario needs, and this embodiment does not limit this.
[0034] Step S202: converting the super type data through identification type OID matching and storing it in the super type column.
[0035] As an optional example, this embodiment obtains the identification type OID of the super type data from the super type column through the identification type acquisition method; matches the corresponding identification type OID to the converted super type data, calls the corresponding type input function according to the matched identification type OID, and converts the super type data into identification type OID data; and stores the identification type OID obtained by the conversion into the corresponding super type column. The identification type OID of this embodiment is a 32-bit integer that uniquely identifies the data type of the OpenGauss database.
[0036] The type input function of this embodiment is used to encapsulate the data according to the storage format of the type when inserting data, and generate data that is finally stored in the disk.
[0037] It should be noted that, in this embodiment, the identification type OID and the identification type OID data obtained by conversion are encapsulated into data having a super type data format and stored in the corresponding super type column in the created table.
[0038] For example, when storing data, this embodiment calls the CONVERT* function to convert the data to be stored into data of the supertype anydata type and stores it in table t. Taking the number type data 123 as an example: INSERT INTO tVALUES (CONVERTNUMBER(123)), where the CONVERT* function is responsible for converting the data to be stored into the storage format of the supertype anydata type data.
[0039] Step S203: when reading the data in the super type column, convert the super type data into identification type OID data.
[0040] When the user reads the super type data in the super type column, the super type data is converted into the identification type OID data through the ACCESS function; the identification type OID of the identification type OID data is obtained through the identification type acquisition method. For example, when reading data, the super type anydata type data is converted into identification type data and output by calling the ACCESS* function, for example: SELECT ACCESSNUMBER(a)FROM t, where the ACCESS* function is responsible for converting the anydata data into identification type data and returning it to the user. At the same time, the identification type acquisition method GETTYPENAME can be used to obtain the identification type in anydata, for example: SELECT GETTYPENAME(a) FROM t, which will return the identification type of the anydata data in the a column.
[0041] Step S204: Parse the identification type OID data according to the identification type OID and return the display data to the user.
[0042] As an optional example, this embodiment calls the corresponding type output function according to the obtained identification type OID, and uses the called type output function to parse the identification type OID data according to the identification type OID to obtain display data and return it to the user. The type output function of this embodiment is used to parse the data according to the storage format of the type when reading the data to obtain the final display data.
[0043] It should be noted that this embodiment uses the called type output function to parse the identification type OID data according to the storage format of the identification type OID.
[0044] This embodiment adopts a super-type data access method and system, which can store different types of data in the same column and read different types of stored data in the same column, significantly reducing the complexity of database design, avoiding the waste of data storage space, reducing the difficulty of data management and maintenance, and ensuring data consistency and integrity.
[0045] It should be noted that the method and system for accessing data using super types in this embodiment are not only applicable to the openGauss database, but also to other open source relational databases.
[0046] like Figure 3 As shown, the present invention further provides a device, including a processor 310, a communication interface 320, a memory 330 for storing a computer program executable by the processor, and a communication bus 340. The processor 310, the communication interface 320, and the memory 330 communicate with each other through the communication bus 340. The processor 310 implements the above-mentioned method of accessing data using a super type by running the executable computer program.
[0047] Among them, the computer program in the memory 330 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on this understanding, the technical solution of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the various embodiments of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc. Various media that can store program codes.
[0048] The system embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, i.e., they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected based on actual needs to achieve the purpose of the solution of this embodiment. Those of ordinary skill in the art may understand and implement it without creative effort.
[0049] Through the description of the above implementation modes, those skilled in the art can clearly understand that each implementation mode can be implemented by means of software plus a necessary general hardware platform, or of course by hardware. Based on such an understanding, the above technical solution can essentially or in other words be embodied in the form of a software product that contributes to the prior art. The computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a magnetic disk, an optical disk, etc., and includes a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods of each embodiment or some parts of the embodiment.
[0050] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions that can be easily thought of by a person skilled in the art within the technical scope disclosed by the present invention should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.
Claims
1. A method for accessing data using a supertype, characterized in that: The method comprises: Set a super type column in the created table to convert the data to be stored into super type data; The super type data is converted and stored in the super type column through identification type OID matching; When reading data in a super type column, convert the super type data into identification type OID data; Parse the identification type OID data according to the identification type OID and return the display data to the user.
2. The method for accessing data using a supertype according to claim 1, characterized in that: A super type column is set in the created table to convert the data to be stored into the super type data, including: when creating the table, the corresponding column in the table is set as the super type column, and when the user inserts the data to be stored, the data to be stored is converted into the super type data through the CONVERT function.
3. The method for accessing data using a supertype according to claim 2, characterized in that: The data types stored in supertype columns include: char, varchar, varchar2, timestamp, timestamptz, date, nchar, nvarchar2, number, float, and double data types.
4. The method for accessing data using a supertype according to claim 1, characterized in that: Super type data is converted and stored in super type columns through identification type OID matching, including: Obtain the identification type OID of the super type data from the super type column through the identification type acquisition method; Matching the corresponding identification type OID for the converted super type data, calling the corresponding type input function according to the matched identification type OID, and converting the super type data into identification type OID data; The identification type OID obtained by the conversion is stored in the corresponding super type column.
5. The method for accessing data using a supertype according to claim 4, characterized in that: Storing the identification type OID obtained by conversion in the corresponding super type column includes: encapsulating the identification type OID and the identification type OID data obtained by conversion into data with a super type data format and storing them in the corresponding super type column in the created table.
6. The method for accessing data using a supertype according to claim 1, characterized in that: When reading data in a supertype column, convert the supertype data into identification type OID data, including: When the user reads the super type data in the super type column, the super type data is converted into identification type OID data through the ACCESS function; The identification type OID of the identification type OID data is obtained through the identification type obtaining method.
7. The method for accessing data using a supertype according to claim 1, characterized in that: Parsing identification type OID data according to identification type OID and returning display data to the user includes: calling a corresponding type output function according to the acquired identification type OID, parsing the identification type OID data according to the identification type OID using the called type output function, obtaining display data and returning it to the user.
8. The method for accessing data using a supertype according to claim 7, characterized in that: The called type output function is used to parse the identification type OID data according to the identification type OID, including: the called type output function is used to parse the identification type OID data according to the storage format of the identification type OID.
9. A system for accessing data using supertypes, characterized in that: The system includes an access server, which is used to: set a super type column in a created table, convert the data to be stored into super type data; convert the super type data into and store it in the super type column through identification type OID matching; when reading the data in the super type column, convert the super type data into identification type OID data; parse the identification type OID data according to the identification type OID and return the display data to the user.
10. A computer device, characterized in that: The computer device comprises a memory, a processor and a computer program stored in the memory and executable on the processor, and the processor implements the steps of the method according to any one of claims 1 to 8 when executing the program.