Chapter 8. Object-relational database, Types of structures...

Chapter 8. The Object-Relational Database

The transition to object-oriented data models is related to the "pumping" process. in them huge volumes of the information which is now stored mainly in relational databases. To simplify this process, we have created an object-relational data model in which two varieties are distinguished: hybrid and extended.

In hybrid object-relational databases, the object-oriented approach is used to create a user interface and an application algorithm. At the same time, the system of tables is formed within the framework of the relational data model.

In extended object-relational databases, the object-oriented approach is used primarily in the construction of a table system. For this, a modification of the SQL2 language was developed, called the SQL3 programming language.

Types of structures

Intermediate The model of data between relational and object-oriented databases is the object-relational model (ORDB).

Its appearance is due to two reasons.

1. The difficulty of building a new data model is from the sheet & quot ;. It is more convenient to do this on the basis of available proven developments.

2. Accounting for continuity with widely used relational models that can not be instantly replaced with object-oriented databases.

Distinguish, as noted earlier, two varieties of the ORDB - hybrid and extended.

1. In the hybrid ORDB [1-3], the user interface and the application algorithm are implemented taking into account the object-oriented approach, while the database itself is relational. Examples include Paradox and InterBase as part of the Delphi software. In a sense, a hybrid can be considered an Access DBMS using the Visual Basic for Application programming language (VBA).

2. In extended (post-relational) DBMS, object-oriented construction of the database itself is assumed, using known and introducing new types of data, interconnected. This relationship is most often accomplished by creating methods using triggers and stored procedures. In the extended object-relational model [1-3], unlike the relational data model, non-atomicity of data in the field is allowed. In such fields, another table or array may reside. Such DBMSs include Informix Universal Server, Oracle 8, UniSQL. In such a DBMS, the SQL3 language is widely used.

Note that post-relational [1] is called DB, in which the denormalization of data is partially carried out, while the non-regularity of records is allowed.

Let's consider in more detail both varieties.

Hybrid LBD

This version of the ORDB is considered using the example of Delphi software.

The Delphi application was originally intended for automation of programming (object-oriented programming), because it allowed to dramatically increase the productivity of programmers by using ready-made "dice-programs". It was only necessary to properly connect these cubes & quot ;.

Later it became clear that the object-oriented approach applied in Delphi can be used in the design of databases. In Delphi, the use of object-oriented design (see Figure 7.2) and programming does not cause difficulties in the user interface and application algorithm. Let's show it.

When Delphi is running, the picture (Figure 8.1). The component classes are divided into groups, defined by the corresponding tabs (pages).

The Delphii form, itself an object, serves as a "collector" for objects. Once a component is placed in a form (and gets a sequence number), it becomes an object.

Note that the components TPanel, TBevel are also containers (in the form) used for formatting, design (separation of objects and their alignment). Other mini containers are the components of the DataModule and TQuickRep (report).

Screen for working with the Delphi application

Fig. 8.1. Screen for working with Delphi application

For an active object in a form when building programs in the Object Inspector you can use properties (the properties page) and events (the events tab) that typically invoke program methods.

All components are divided into the following main groups: Standard, Additional, Dialogs, Win32, System, VCL, Internet, DataAccess, DataControl, QReport, Decision Cube, ActiveX. In the process of automated programming, the first four pages are most often used.

From the positions of the knowledge bases and databases proper, you should pay special attention to the pages DataAccess and DataControI. They are adjoined by the pages of QReport, Decision Cube.

The composition of the components of some tabs DataAccess and DataControI is shown in Figure 8.2. In Fig. 8.3 and 8.4 show the properties and events of the TT-block.

Consider the description of Delphi's software capabilities.

The Delphi application can work with three relational DBMSs: dBase, Paradox - in local mode (Figure 8.3); InterBase, which is installed separately, is in client-server mode.

Note that InterBase can be used in two versions: local (server and client on one computer, usually used during debugging) and remote (server and client on different computers).

Composition of some Delphi component pages

Fig. 8.2. The composition of some pages of the Delphi component

Regardless of the DBMS used, the user interface and application algorithm are built using an object-oriented approach. Let us confirm this statement briefly.

A. This will initially be about implementing the database itself.

A1. The database name is initially set. Using this name, a link to the database is made. However, in this case it is required to specify sometimes a long access path (address), which is inconvenient when the database is repeatedly accessed. Because of this, the alias ( synonym ) is often used, the DB is the name that replaces the long path. Alias ​​creation is carried out with the help of Delphi-utilities BDE Administrator and SQL Explorer.

A2. Creating database tables for Paradox (local mode) and InterBase (client-server mode), as well as populating the database with data, is specific for each case. It is easy to see that when creating the database itself, the object-oriented approach is not used.

B. Interface. There are no clear formal rules for building an interface. However, some recommendations can be formulated.

The interface is made according to the wishes of the user. The form of the interface depends on the tools provided by the DBMS or software application.

As a tool for the interface can be a system of forms (Form), a system of buttons, a system of controls (list, combo box, etc.).

Table component properties

Fig. 8.3. Table component properties

For Delphi, the source tool is more often a form system called from the main menu or by using a control system and a menu in the main form.

B1. Delphi Forms.

Table component events

Fig. 8.4. Table component events

B1.1. The forms of Delphi are often called windows. The window is called modal (M), if access to the previous open window is possible only after the M-window is closed. Otherwise, the window is called non-modal.

Let's have two forms - Form1 and Form2, while Form2 is called from Form1.

In the case of a modeless window for the form Forml, the program module uniti is written

procedure TForml. Button 1 Click (Senser: Tobject);

begin

Form2.Show;

end;

In order to work with the second window (form), in the uniti program (section implementation), a link to the program module unit2 (forms Form2) is added

implementation

uses unit2;

Now from uniti, you can run a modeless form2 window.

To make Form2 a modal window, you set its BorderStyle = bsDialog property. At the same time, you need to make changes to uniti: instead of Forml.Show write Form2.ShowModal.

B1.2. Instead of the manual creating a multi-window interface it is possible to use templates in which two variants are highlighted:

• Multiple Document Interface (M DI);

• a single-document interface (Simple Document Interface - SDI).

When using MDI, child windows do not exceed the parent window in size and can be mosaic (Title) or cascade (Cascade). The parent window contains the main application menu. MDI is organized in the same way as the modal window, with the FormStyle = fsMDIFomi property for the parent window and FormStyle = fsMDIChild for the child windows. When you create an MDI, you can use a template or build MD1 with a "zero".

In the latter case, the File/New of the Delphi main menu is selected, and in the New Items dialog box on the New page, select the Application icon by entering the parent and child windows in turn.

SDI can also contain several windows, with child windows not limited by the size of the parent window, sometimes called the main window.

Links to all child unit-modules are included in the module module of the main window:

implementation

uses SDIWdw;

In unit-programs of child windows, there should be a link to the unit-program of the main window:

imlementation

uses SDIMain;

Before minimizing the main window, the child windows are initially minimized.

It's better to use SOI templates (MDI). To do this, access the Delphi main menu (File/New), enter the New Items dialog box, and select the required template on the Projects tab (page): SDI (one form and one software module) or MDI (two forms and three modules).

B2 The user's workflow can be defined using a menu or button system.

B2.1. The creation of the menu is quite simple and therefore is not considered in detail here. Ordering menu items (actually - objects), writing programs for them, do not differ from bindings programs to such control elements as a button, a combo box, etc. We only note that there are two types of menu - the main (TMainMenu Standard page) and the popup menu (TPopuMenu), which is called by the right mouse button.

B2.2 . Another possibility of specifying a sequence of operations of the user is to use the button system (TButton, TBitBtn). In Delphi, menus are usually used, and buttons are more likely to play an auxiliary role and are used, for example, to close forms, change access to menu items.

The properties of the menu, as well as the button systems most commonly used, are Enabled and Visible.

B3 . The flexibility of the menu is provided by the use of controls.

B3.1 . Universal controls are placed on the Standard, Additional, Dialog pages of the component palette. Such elements include TLabel, TEdit, TMemo, TComboBox. TButton, TBitBtn.

Specific use of TLabel. The Caption property is used to set the headers of database tables, names to components such as TEdit, TMemo.

In turn, the properties Editl.Text and Memol.Line are used to specify parameters (single and multi-line), for example, in queries. Perhaps most often the listed controls use the properties Enabled, Visible.

B3.2 . Specialized control elements associated directly with the database are the components of the DataControl page. These should be attributed primarily to DBGrid, DBEEdit, DBNavigator, DBMemo.

The DBEdit components allow you to create a database form in a column. Such forms are often used when working in DBMS Access to fill the database.

B4 . Message. It can be made ordinary, using, for example,

MessageDlg (Query1 ['Name'], mtlnformation, [mbOk], О);

However, it is preferable to apply the exception schema try ... except

begin

try

Query1 ['Plan'] & lt; Queryl ['Fakt']

except

ShowMessage ('Number of vacancies is less than the number of accepted ones. Change the rules or posts of accepted');

Exit;

end;

The program will work if there is an exception. The user interface is also formed by the end object of the chains access. Let's illuminate them in the application algorithm (AP), because the remaining objects of the chains participate in the AP.

Q. Algorithm of the application. Application programs can be written in one or a combination of three languages: interface SQL, nested SQL, Object Pascal (OP).

B.l . There are three chains access (Figure 8.5):

TTable - TDataSource - TDBGrid (more often used in Paradox);

TQuery - TDataSource - TDBGrid (more often used for DBMS InterBase);

TStoredProc - TDataSource - TDBGrid (used only for DBMS InterBase).

Object-oriented user interface (Delphi application)

Fig. 8.5. Object-oriented user interface (Delphi application):

BDE - Borland Database Engine (the Delphi kernel)

We will continue to refer to them as chains Table, Query, and StoredProc, respectively.

In these chains The TDBGrid component is visual, and the rest are nonvisual. The components TTable, TQuery, TStoredProc provide direct access to the database (on the alias), whereas the TDataSource component plays the role of the "multiplier": it can connect the visual components TDBNavigator, TDBText, TDBEdit, TDBMemo, TDBListBox, TDBComboBox and others. These plug-in components (if hide the TDBGrid component using the Visible property or, better, Enabled) can form an analogue forms Access (to fill the database). The concept of form in the sense of Access in Delphi is missing.

Links in chains are installed in static mode (access building), or in a dynamic mode when the program is executed.

Chain StoredProc is specific and is used only in client-server mode, and even rarely.

B.2 . Along with the chains can also be used truncated chains composed of non-visual objects, the container for which is the DataModule module (s).

Such a container is organized via the Delphi menu (File/NewDataModule). The connection between the components TTable - TDataSource and TQuery - TDataSource is set in the same way as it is done in the form when using it as a container for the previously considered "chains".

The DataModule is stored under some name, and a unit program is created for it, the name of which is added to the texts of the program modules of other application forms (File/Use Unit). When referring to such a module (objects), you must first specify its name, for example, DataModule.DataSourcel.

Until now, it was about accessing data without changing it. However, when working with the database, update operations are performed (insert, modify, destroy). They can be performed manually or automatically (when running programs).

In the first case, this occurs when creating a database (filling the database with data). The update can be carried out directly in tables or through specific forms made up of the TDBEdit component. Such updates do not cause difficulties.

B3 . Embedded SQL is used only in client-server mode.

B4 . Interface SQL is used in local mode and client-server mode.

Note that the SQL interface language is flexible enough when working with databases, but it does not have the concept of cycles and transitions. In addition, in the SQL property of the TQuery component (or the property of any component, for example, Memo.Text, from which the SQL operator is borrowed), only one operator can be written and started, after which it should be deleted and enter new. Thus, to execute several operators, they should be entered one at a time, which requires a complicated software solution, or "embed" in the operators of Object Pascal.

In view of the above, the scope of the SQL interface language is limited. Its operators in its pure form are most often used in single queries both in local mode and in client-server mode.

In the local mode, the language of Object Pascal is more often used, the constituent operators of which can be SQL statements.

B5 . The main role in the local mode is played by the programming language Object Pascal. In client-server mode, it, together with the interface language SQL, is used in the client part.

It should be noted that there are two types of programs in Object Pascal:

1) tethered directly to events;

2) not directly associated with the event (usually tied to the form ) and called from other programs.

The construction of the first programs is widely described in the literature, while the second is practically not mentioned. The latter are written completely manually.

With the help of relational databases and this kind of ORDB, they tried to solve the problem of creating a database for storing graphic data and data with a large volume of fields. In this case, the data itself was stored in files, and in the database there were only links to these files. However, this path turned out to be unproductive due to the numerous problems that arise.

Thus, in the hybrid DBMS, the user interface and application algorithm are built using the object-oriented approach, and the database itself is relational.

thematic pictures

Also We Can Offer!

Other services that we offer

If you don’t see the necessary subject, paper type, or topic in our list of available services and examples, don’t worry! We have a number of other academic disciplines to suit the needs of anyone who visits this website looking for help.

How to ...

We made your life easier with putting together a big number of articles and guidelines on how to plan and write different types of assignments (Essay, Research Paper, Dissertation etc)