Data types

The sample DataBlade® module defines four spatial data types that allow you to create table columns that contain two-dimensional objects such as points, circles, and boxes. The four new data types are called MyShape, MyPoint, MyCircle, and MyBox. The MyShape data type is the supertype in the type hierarchy and the MyPoint, MyCircle, and MyBox data types are the subtypes.

The following example creates a table called box_tab that has a column called boxes of data type MyBox:
CREATE TABLE box_tab
(
    id      INTEGER,
    boxes   MyBox
);    
The following INSERT statements show how to insert two different boxes into the box_tab table:
INSERT INTO box_tab 
VALUES (1, 'box(10,10,40,40)' );

INSERT INTO box_tab 
VALUES (2, 'box(-10,-20,5,9)' );

A box is described by its lower-left and upper-right coordinates. For example, the first INSERT statement inserts a box whose lower-left coordinate is (10,10) and upper-right coordinate is (40,40).

Similarly, the following examples show how to create and insert into tables that have MyCircle and MyPoint columns:
CREATE TABLE circle_point_tab
(
    id        INTEGER,
    circles   MyCircle,
    points    MyPoint
);    
INSERT INTO circle_point_tab 
VALUES (1, 'circle(20,30,15)', 'point(10,15)' );

INSERT INTO circle_point_tab 
VALUES (2, 'circle(-30,-10,25)', 'point(-20,-5)' );