473,416 Members | 1,859 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes and contribute your articles to a community of 473,416 developers and data experts.

AntDB’s custom data type: object-oriented features

26 16bit
AntDB extends the relational data model by providing a richer type system, including complex data types and object-oriented, and extends support for the Object-Relational Data Model on the basis of the Relational Query Language to handle a richer type system.

1.Foreword

Many database applications are written in object-oriented programming languages (java, c++), but they need to store data in and fetch data from databases. Because of the type differences between the native type system of object-oriented programming languages and the relational model supported by the database, conversions between the two models are required when fetching or storing data. Extending the database-supported type system alone is not enough to solve this problem completely, because a different language than the programming language must be used to express database access, which makes the programmer's job harder.

In practice, this problem can be solved by integrating object-oriented features with the database system, that is, building an object-relational database system and adding object-oriented features to the relational database system.

AntDB provides a variety of object-oriented features, one of which is custom types, whose usage is described below.

2.Syntax


Figure 1: syntax structure

3.Detailed Description of Functions

You can register a new data type in the database using the CREATE TYPE statement. However, when defining a data type, it is important to note:
  • The creator of a datatype is the owner of the datatype.
  • The schema can be specified at creation time by prefixing the type name with the schema name, otherwise it will be created in the default schema.
  • The name of the new type must not be the same as the existing type name, domain name, or table name in the schema it is in.

As can be seen from the above syntax, a total of five types can be created, namely, combination type, enumeration type, range type, base type, and shell type. The following section focuses on the first four types. Shell type is mainly used as forward references for subsequent definitions when declaring range type and base type, and play the role of type placeholders.

Combination Type

The first form in the syntax description is created as a combination type. A combination type is represented by a list of attribute names and data types. If the data type of the attribute is sortable, you can also specify a sorting rule (collation) for the attribute. A combination type is essentially the same as a table row type, but if you just want to define a type, you can use CREATE TYPE instead of creating a table.

To create a combination type, you must have the USAGE permission on all its attribute types.

Table 1: Syntax Options of Combination Type



Example: *


Figure 2: create a combination type

3.2 Enumeration Type

The second form in the syntax description is created as a enumeration type. An enumeration type is represented by a list of tags with quoted labels, each of which must be no longer than NAMEDATALEN bytes (64 bytes, determined at compile time). It is possible to create enumeration type with zero labels, but such type cannot be used to hold specific values until the labels are added to the enumeration type.

Table 2: Syntax Options of Enumeration Type



Example:


Figure 3 :create a enumeration type

3.3 Range Type

The third form in the syntax description is created as a range type. The range type expresses the range of values of an element type (subtype of range).

Table 3: Syntax Options of Range Type



Example:


Figure 4: create a range type

3.4 Base Type

The forth form in the syntax description is created as a base type. To create a new basic type, you must have superuser privileges (the reason for this restriction is that incorrect type definitions can cause database crashes). The order of the arguments in the above syntax definitions is arbitrary and non-fixed, and many arguments are optional. Usually the function specified in the argument must be defined in C or a lower-level language.

Table 4: Syntax Options of Base Type



Example:


Figure 5 :create a base type

4.Array Type

When a custom type is created, the system automatically creates an associated array type for it. The array type name is prefixed by an underscore to the name of its element type. If the name length exceeds the NAMEDATALEN byte limit it is truncated (if the generated name conflicts with the name of an existing type, the process is repeated until a non-conflicting name is found). This implicitly created array type is variable-length and uses the built-in input and output functions (array_in and array_out). The system also uses this array type when building ARRAY[] on top of user-defined types. This array type changes as the owner or schema of its element type changes, and is deleted when its element type is deleted.

At this point, the reader may have questions, since the system has automatically created the correct array type, why there is still ELEMENT option. This is because ELEMENT works when you create a fixed-length type that happens to be an array of a fixed type and you want to be able to index the data items by subscript. For example, the point type is represented by two floating-point numbers that can be accessed by point[0] and point[1]. This approach is limited to the fact that internally it is an explicit series of fixed-length fields. For historical reasons (which are now unmodifiable), fixed-length arrays start with a subscript of 0, rather than 1 as variable-length arrays do.

5.Compatibility

The above syntax for creating combination types conforms to the SQL standard, the other forms are extended syntax.

6.Conclusion

Custom types provide the most basic object-oriented capabilities. Based on similar ideas, database systems can implement more object-oriented features. More object-oriented features of AntDB will be introduced in the future, so stay tuned.
Jan 12 '23 #1
0 486

Sign in to post your reply or Sign up for a free account.

Similar topics

24
by: Batista, Facundo | last post by:
Here I send it. Suggestions and all kinds of recomendations are more than welcomed. If it all goes ok, it'll be a PEP when I finish writing the code. Thank you. .. Facundo
21
by: Batista, Facundo | last post by:
Here I send it. Suggestions and all kinds of recomendations are more than welcomed. If it all goes ok, it'll be a PEP when I finish writing/modifying the code. Thank you. .. Facundo
7
by: Luc Tremblay | last post by:
Given the typical following code: void Listener::HandleEvent(const Event& event) { // handling code } In a "clean" fashion, how is it possible to add custom data (to be subsequently...
13
by: dawatson833 | last post by:
I have several stored procedures with parameters that are defined with user defined data types. The time it takes to run the procedures can take 10 - 50 seconds depending on the procedure. If I...
1
by: deko | last post by:
Okay, so I figured out how to pull Outlook Appointments into an Access Table (see below). But the data comes in the wrong Data Type - how do I convert it from Text to Long Integer? For...
21
by: Angel Lopez | last post by:
Sorry if I am too naive, but this is my first post... I have a binary variable (it can contain either a 0 or a 1). Is there any way I can define a data type that uses only 1 bit. So far I have...
13
by: Alan M Dunsmuir | last post by:
I need to specify a new data type, almost entirely a 'clone' of the existing DateTime type, with the following specific difference, and all the consequent differences in properties and methods...
6
by: Gaz | last post by:
Hi guys. I've been lookig for this in the numpy pdf manual, in this group and on google, but i could not get an answer... Is there a way to create a custom data type (eg: Name: string(30), Age:...
12
by: Just D | last post by:
All, It was possible before in Pascal, C++, etc. to define our custom data type or redefine the existing type, like in Turbo Pascal we could assume that shortint is int and use all references to...
1
by: jehugaleahsa | last post by:
Hello: I am experiencing performance related issues when my custom data structures work with value types. I use generics to prevent boxing wherever I can. For instance, I use IEqualityComparer,...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.