You are on page 1of 6

Notes prepared by K. Chandra Mouli (Lecturer), P.B.S.

2. The Basics of object-Relational Databases RDBMS (Relational Database Management System): A relational database is composed of many relations in the form of two-dimensional tables of rows and columns containing related tuples. A Relational Database Management System uses only its relational capabilities to manage the information stored in its database. ORDBMS (Object-Relational Database Management System) : The main objective of Object-Relational Database Management System was a to achieve the benefits of both the relational and the object model such as scalability and support for rich. The traditional oracle relational database, extended to include object oriented concepts and structures such as abstract data types, nested tables and varying arrays. OODBMS (Object-oriented Relational Database Management System): The main feature of OO programming languages are encapsulation, inheritance, and Polymorphism. An Object-oriented Relational Database whose design is based solely on object-oriented analysis and design. Why should I use objects: OO features: Object reuse: If you write OO code, you increase the chances of reusing previously written code modules. Similarly, if you create OO database objects, you increase the chances that the database objects can be reused. Standards adherence : If you create standard objects, then you increase the chance that they will be reused. For example, if you create standard data types to use for all address, then all of the address in your database will use the same internal format. Defined access paths : For each object you can define the procedures and functions that act upon it- you can unite the data and the methods that access it. Abstract Data types : 1. Abstract data types are data types that consist of one or more subtypes. Rather than being constrained to the standard ORACLE data types of number, date, and varchar2, abstract data types can more accurately describe your data. 3. For example, an abstract data type for address may consist of following columns: Street varchar2 (50) City varchar2 (25) State char (2) Zip Number

2.

Notes prepared by K. Chandra Mouli (Lecturer), P.B.S.C

4. 5.

When you create a table that uses address information, you could create a column that uses the abstract data type for address and thus contain the street, city, and zip columns that are part of that data type. Abstract data types can be nested; they can contain references to other abstract data types. You can use abstract data types to create object tables. In an object table, the columns of the table map to the columns of the abstract data type. Nested tables :

1. 2. 3.

A nested table is a table with in a table . A nested table is a collection of rows represented as a column with in the main table. For each record with in the main table, the nested table may contain multiple rows. In one sense, its a way of storing a one to many relationships with in one table. A more powerful use of object types in Oracle is the fact that the type of a column can be a table-type. That is, the value of an attribute in one tuple can be an entire relation, as suggested by the picture below, where a relation with schema (a, b) has bvalues that are relations with schema (x, y, z). a b x x y y z z -

Varying Arrays :

4.

1. A varying array is, like a nested table, a collection. 2. A varying array is a set of objects, each with the same data type. 3. The size of array is limited when it is created. When you create a varying array in a table, the array is treated as column in the main table. A varying array is a nested table with a limited set of rows. 5. Varying arrays also known as VARRAYS. Large objects: A large object or LOB is capable of storing large volumes of data. The LOB data types available are BLOB, CLOB, NLOB, and BFILE. BLOB: The BLOB data type is used for binary data, and can extend to 4 GB in length.. CLOB:

Notes prepared by K. Chandra Mouli (Lecturer), P.B.S.C

The CLOB data type stores character data and can extend to 4 GB in length. NCLOB: The NCLOB data type is used for store CLOB data for multi byte character sets. The data for BLOB, CLOB, and NCLOB data types is stored inside the database. Thus, you could have a single row is over 4 GB in length. BFILE: BFILE is a pointer to an external file. The files referenced by BFILES on exist on the operating system; the data base only maintains a pointer to the file. REFERENCES; 1. Nested tables and varying arrays are embedded objects - they are 2. Physically embedded within another object. 3. Referenced objects are physically separate from the objects that refer to them. References also Known as REFs are essentially pointers to row objects. A row object is different than a column object. Object Views: Object views allow you to add OO concepts on top of your existing relational tables. For example, you can create an abstract data type based on an existing tables definition. Thus, object vies give you the benefits of relational table storage and OO structures. A common object Example : Four attributes named street, city, state and zip Create type ADDRESS_TY as object (street VARCHAR2(50), city VARCHAR2(25), state CHAR(2), zip NUMBER);

4.

The create type command is the most important command in th Object-relational database

Create an abstract data type named ADDRESS_TY . PERSON_TY and identified as an object via the as object clause Create type PERSON_TY as object (Name VARCHAR2 (25), Address ADDRESS_TY); In above table two columns were defined. This line (Name VARCHAR2 (25), Defines the first column of PERSON_TYs representation The second line:

Notes prepared by K. Chandra Mouli (Lecturer), P.B.S.C

Address ADDRESS_TY); Defines the second column of PERSON_TYs representation The second column, Address uses the ADDRESS_TY abstract data type previously created. What are the columns within ADDRESS_TY according to the ADDRESS_TY definition, they are: Create type ADDRESS_TY as object (Street VARCHAR2 (50), City VARCHAR2 (25), State CHAR (2), Zip NUMBER); The Structure of a simple object : The following command creates a table named CUSTOMER. A customer has a Customer_ ID and all the attributes of a person (via the PERSON_TY data type) Create table CUSTOMER (Customer_ ID NUMBER, Person PERSON_TY); Use this query USER_TAB_COLUMNS data dictionary view to see the data types associated with each column in the CUSTOMER table: Select Column_ Name, Data_ Type From USER_TAB_COLUMNS Where Table_ Name = CUSTOMER; COLUMN_NAME -------------------------------Customer_ ID PERSON DATA_TYPE -----------------------------------------NUMBER PERSON_TY

Inserting Records into CUSTOMER Table: The following example, a record is inserted into CUSTOMER using the constructor methods for PERSON_TY and ADDRESS_TY data types. Insert into CUSTOMER values (1, PERSON_TY (NEIL MULLANE, ADDRESS_TY (57 MT PLEASANT ST, FINN,NH, 11111))); 1 row created Selecting from Abstract Data types: If you wanted to select the customer_ ID values from customer, you simply query that columns values from the table : >Select Customer_ ID from customer

Notes prepared by K. Chandra Mouli (Lecturer), P.B.S.C

CUSTOMER_ID ----------------------1 2 To select the street attribute of the address attribute within the person column,your query will be. >Select person .Address. street from customer; PERSON.ADDRESS.STREET ------------------------------------------57 MT PLEASANT ST 1 STEPAHEAD RD Object-Oriented Analysis and Design : When you consider adding in OO features such as abstract data types, you need to approach need to approach database design from a slightly different perspective. You try to relate each attribute to its primary key . In OO design, you go beyond normalization and seek groups of columns that define a common object representation. For example, in relational design , a CUSTOMER table may be created as :

Create type CUSTOMER (Customer_ ID NUMBER primary key, Name VARCHAR(25), street VARCHAR2(50), city VARCHAR2(25), state CHAR(2), zip NUMBER); Object-oriented databases employ a data model that supports object-oriented features discussed above and abstract data types. OO databases provide unique object identifiers (OIDs) so that the objects can be easily identified. This is similar to a primary key in the relational model. Object-oriented databases utilize the power of objectoriented programming languages to provide excellent database programming capability. The data in object-oriented database management systems (OODBMSs) is managed through two sets of relations, one describing the interrelations of data items and another describing the abstract relationships (inheritance). These systems employ both relation types to couple data items with procedural methods (encapsulation).

Notes prepared by K. Chandra Mouli (Lecturer), P.B.S.C

You might also like