Oracle8i Spatial User's Guide and Reference
Release 8.1.5

A67295-01

Library

Product

Contents

Index

Prev Next

2
The Object-Relational Schema

The object-relational implementation of Oracle8i Spatial consists of a set of object data types, an index method type, and operators on these types. A geometry is stored as an object, in a single row, in a column of type SDO_GEOMETRY. Spatial index creation and maintenance is done using basic DDL (CREATE, ALTER, DROP) and DML (INSERT, UPDATE, DELETE) statements.

2.1 Object-Relational Data Structures

In the Spatial object-relational model, a single SDO_GEOMETRY object replaces the rows and columns in a <layername>_SDOGEOM table of the relational model.

The geometric description of a spatial object is stored in a single row, in a single column of object type SDO_GEOMETRY in a user-defined table. The table does not require the "_SDOGEOM" suffix anymore. Because the SDO_GEOMETRY type does not have an SDO_GID attribute, any table that has a column of type SDO_GEOMETRY must have another column, or set of columns, that defines a unique primary key for that table. Tables of this sort are sometimes referred to as geometry tables.

Oracle8i Spatial defines the object type SDO_GEOMETRY as:

CREATE TYPE sdo_geometry AS OBJECT (
 SDO_GTYPE NUMBER, 
 SDO_SRID NUMBER,
 SDO_POINT SDO_POINT_TYPE,
 SDO_ELEM_INFO MDSYS.SDO_ELEM_INFO_ARRAY,
 SDO_ORDINATES MDSYS.SDO_ORDINATE_ARRAY);

The attributes of the SDO_GEOMETRY object type have the following semantics:

2.2 Geometry Examples Using the Object-Relational Model

Figure 2-1 illustrates a geometry with two elements. The inner element in this example is treated as a void (a hole).

Figure 2-1 Geometry with a Hole

In Figure 2-2, consider a crescent-shaped object represented as a compound line string made up of one straight line segment and one circular arc. Four points are required to represent this shape. Points 1 and 2 describe the straight line segment and points 2, 3, and 4 describe the circular arc. The SDO_ELEM_INFO array contains 3 triplets for this compound line string. These are {(1,4,2), (1,2,1), (3,2,2)}. The SDO_ORDINATES array contains (X1,Y1, X2, Y2, X3, Y3, X4,Y4).

Figure 2-2

The first triplet indicates that this element is a compound line string made up of two line strings, which are described with the next two triplets.

The second triplet indicates that the line string is made up of straight line segments and that the ordinates for this line string start at offset 1. The end point of this line string is determined by the starting offset of the second line string, 3 in this instance. Assuming the vertices are 2-dimensional, the coordinates for the end point of the first line string are at ordinates 3 and 4.

The third triplet indicates that the second line string is made up of circular arcs with ordinates starting at offset 3. The end point of this line string is determined by the starting offset of the next element or the current length of the SDO_ORDINATES array, if this is the last element.

In Figure 2-3, consider an ice cream cone shaped object represented as a compound polygon made up of one straight line segment and one circular arc. Five points are required to represent this shape. Points 1, 2, and 3 describe one acute angle shaped line string, and points 3, 4, and 5 describe the circular arc. Points 1 and 5 are the same point. The SDO_ELEM_INFO array contains three triplets for this compound line string. These triplets are {(1,5,2), (1,2,1), (5,2,2)}.

The first triplet indicates that this element is a compound line string made up of two line strings, which are described using the next two triplets.

The second triplet indicates that the line string is made up of straight line segments and that the ordinates for this line string start at offset 1. The end point of this line string is determined by the starting offset of the second line string, 5 in this instance. Assuming the vertices are 2-dimensional, the coordinates for the end point of the first line string are at ordinates 5 and 6.

The third triplet indicates that the second line string is made up of circular arcs with ordinates starting at offset 5. The end point of this line string is determined by the starting offset of the next element or the current length of the SDO_ORDINATES array, if this is the last element.

2.3 Geometry Metadata Structure

The geometry metadata describing the dimensions, lower and upper bounds, and tolerance in each dimension must be stored as a single entry in a table named SDO_GEOM_METADATA created in your schema and defined as follows:

Create Table SDO_GEOM_METADATA (
  TABLE_NAME   VARCHAR2(30),
  COLUMN_NAME  VARCHAR2(30),
  DIMINFO      MDSYS.SDO_DIM_ARRAY);

There should be one table with the previous name and layout created in the schema of each user having tables with a column, or columns, of type SDO_GEOMETRY. For example, if user Herman has tables named Roads, Parks, and Rivers, each with a column named theGeometry of type SDO_GEOMETRY, then there must be three entries in the table herman.sdo_geom_metadata. The user, or application, is responsible for populating and maintaining the data in this table.

The SDO_GEOM_METADATA.TABLE_NAME column contains the name of a feature table, such as Roads or Parks, that has a column of type SDO_GEOMETRY. The name of this column, of type SDO_GEOMETRY, is stored in the feature table in the SDO_GEOM_METADATA.COLUMN_NAME column. For the tables Roads and Parks, this column is called theGeometry, and therefore the SDO_GEOM_METADATA table should contain rows (Roads, theGeometry, SomeDimInfo1) and (Parks, theGeometry, SomeDimInfo2). The SDO_GEOM_METADATA.DIMINFO row is a varying length array of an object type, ordered by dimension, and has one entry per dimension. The row is defined as follows:

Create Type SDO_DIM_ARRAY as VARRAY(4) of SDO_DIM_ELEMENT; 

where SDO_DIM_ELEMENT is defined as:

Create Type SDO_DIM_ELEMENT as OBJECT (
  SDO_DIMNAME VARCHAR2(64),
  SDO_LB NUMBER NOT NULL,
  SDO_UB NUMBER NOT NULL,
  SDO_TOLERANCE NUMBER NOT NULL);

The SDO_DIM_ARRAY instance is of size N if there are N-dimensions. That is, SDO_GEOM_METADATA.DIMINFO contains 2 SDO_DIM_ELEMENT instances for 2-dimensional geometries, or 3 for 3-dimensional geometries, and so on. Each SDO_DIM_ELEMENT instance in the array must have valid (not NULL) values for the SDO_LB, SDO_UB, and SDO_TOLERANCE attributes.

Spatial assumes that the varying length array is ordered by dimension, and therefore, in the Roads and Parks tables, SomeDimInfo1 is the SDO_DIM_ELEMENT for the first dimension and SomeDimInfo2 is the SDO_DIM_ELEMENT for the second dimension. It is imperative that the DIMINFO varying length array is ordered by dimension in the same way the ordinates for the points in SDO_ORDINATES varying length array are ordered. That is, if the SDO_ORDINATES varying length array contains {X1, Y1, ..., Xn, Yn}, then SomeDimInfo1 must define the X dimension and SomeDimInfo2 must define the Y dimension.

Section 3.1.2 contains examples that show the use of the SDO_GEOMETRY and SDO_DIM_ARRAY types. These examples demonstrate how various geometry objects are represented, and how a feature table and the SDO_GEOM_METADATA table are populated with the data for those objects.

2.4 Spatial Index-Related Structure

This section describes the structure of the tables containing the spatial index data and metadata. Concepts and usage notes for spatial indexing are explained in Section 1.6. Both the spatial index data and metadata are stored in tables created and maintained by the spatial indexing routines. These tables are created in the same schema as the owner of the feature (underlying) table with a spatial index created on a column of type SDO_GEOMETRY.

2.4.1 Spatial Index Tables

There is one metadata view per schema (user), named SDO_INDEX_METADATA, and one index data table per spatially indexed column in that schema. Thus if user Herman has five feature tables, each with a spatial index on their respective SDO_GEOMETRY typed column, then Herman's schema has one SDO_INDEX_METADATA view and five tables containing spatial index data. The index data table names are not created by adding the " _SDOINDEX" suffix to the layer name. Instead, the index data table is named using the user-specified index name and a suffix that indicates the spatial index type (fixed or hybrid, as defined in Section 1.6) and the values of the relevant index parameters.

The SDO_INDEX_METADATA view contains the following columns whose type and purpose are shown in Table 2-3.

Table 2-3 Columns in an SDO_INDEX_METADATA View
Column Name  Data Type  Purpose 

SDO_LEVEL  

NUMBER  

The fixed tiling level at which to tile all objects in the feature table.  

SDO_NUMTILES  

NUMBER  

Suggested number of tiles per object that should be used to approximate the shape.  

SDO_MAXLEVEL  

NUMBER  

The maximum level for any tile for any object. It will always be greater than the SDO_LEVEL value.  

SDO_COMMIT_INTERVAL  

NUMBER  

The number of geometries (rows) to process, during index creation, before committing the insertion of spatial index entries into the SDOINDEX table. See Appendix A for a discussion of the use of this parameter.  

SDO_INDEX_TABLE  

VARCHAR2  

Name of the SDOINDEX table.  

SDO_TABLESPACE  

VARCHAR2  

Same as in the basic SQL CREATE TABLE statement. Tablespace in which to create the SDOINDEX table.  

SDO_INITIAL_EXTENT  

NUMBER  

Same as in SQL CREATE TABLE statement.  

SDO_NEXT_EXTENT  

NUMBER  

Same as in SQL CREATE TABLE statement.  

SDO_PCTINCREASE  

NUMBER  

Same as in SQL CREATE TABLE statement.  

SDO_MIN_EXTENTS  

NUMBER  

Same as in SQL CREATE TABLE statement.  

SDO_MAX_EXTENTS  

NUMBER  

Same as in SQL CREATE TABLE statement.  

SDO_FIXED_METADATA  

RAW  

If applicable, this column contains the metadata portion of the SDO_GROUPCODE or SDO_CODE for a fixed-level index.  

SDO_INDEX_COORDSYS  

VARCHAR2  

Reserved for future use.  

SDO_INDEX_PRIMARY  

NUMBER  

Indicates if this is a primary or secondary index. 1 = primary, 2 = secondary.  

SDO_INDEX_OWNER  

VARCHAR2  

The owner of the index.  

SDO_INDEX_NAME  

VARCHAR2  

The name of the index.  

SDO_TSNAME  

VARCHAR2  

The schema name of the SDO_INDEX_TABLE.  

SDO_COLUMN_NAME  

VARCHAR2  

The column name on which this index is built.  

2.4.2 Spatial Index Data Dictionary View

The index data table will have some or all of the columns shown in Table 2-4.

Table 2-4 Columns in a Spatial Index Data Table
Column Name  Data Type  Purpose 

SDO_ROWID  

RAW  

Row ID of a row in a feature table containing the indexed object.  

SDO_CODE  

RAW  

Index entry for the object in the row identified by SDO_ROWID.  

SDO_MAXCODE  

RAW  

Padded SDO_CODE column.  

SDO_GROUPCODE  

RAW  

Index entry at level SDO_LEVEL.  

SDO_META  

RAW  

Metadata portion of the SDO_CODE for a hybrid index.  

The columns, SDO_ROWID and SDO_CODE, are always present. The remaining columns are present only when the selected index type is HYBRID, which is the recommended indexing for the object-relational model.

2.5 Usage Notes

Stored procedures, provided with Spatial release 8.1, assume the existence of the following schema objects: instances of SDO_GEOMETRY and SDO_DIM_ARRAY objects and the metadata table SDO_GEOM_METADATA in the user's schema. While specific instances of the SDO_GEOM_METADATA view may contain additional columns, they are required to contain the columns described in Table 2-3 with the same column names and data types.




Prev

Next
Oracle
Copyright © 1999 Oracle Corporation.

All Rights Reserved.

Library

Product

Contents

Index