Caché Technology Guide

Chapter 1  
Kapitola 1:

Modelovanie Dát: Relačný alebo Objektový prístup Data Modeling: Relational or Object Access 

Early in the process of designing a new application, developers must decide upon their approach towards data modeling. For most, this comes down to a choice between the traditional modeling of data as relational tables and the newer approach of modeling as objects. Faced with the need to handle complex data, many developers believe that modeling with objects is a more effective approach.

V minulosti v procese návrhu novej aplikácie, vývojari museli prijať rozhodnutie ako pristúpovať k modelovaniu dát. Pre väčšinu to znamenalo vybrať si medzi tradičným spôsobom modelovania dát relačnými tabuľkami alebo novým spôsobom modelovania pomocou objektov. V konfrontácii s potrebou zaoberať sa celým komplexom dát, veľa vývojárov si myslí, že modelovanie dát s objektovým prístupom je  oveľa efektívnejšie. 

Caché supports both SQL and object data access, and at times each is appropriate. To understand the uses of each and why data modeling with objects is generally preferred by modern-day developers, it is useful to understand how and why each has developed.

Caché podporuje oba SQL ale aj objektový prístup, a tentoraz oba sú prijateľné.  Aby sme pochopili potrebu  každého z nich, a taktiež prečo je datové modelovanie pomocou objektov uprednosťnované modernými vývojármi, bude užitočné pochopiť ako a prečo bol každý z nich vyvinutý. 

 

Data Modeling

Relačná technológia Relational Technology 

In the early days of computing, information processing was done on huge mainframe systems and data access was, for the most part, limited to IT professionals. Databases tended to be home grown, and retrieving data effectively required a thorough knowledge of the database. If a user wanted a special report, he or she usually had to ask an overworked central staff to write it, and it usually wasn’t available in time to influence decisions.

V dávnych časoch komputerovej techniky, informačné systémy boli prevádzkované na mohutných sálových počítačoch a prístup k datám pre väčšinu strán (užívateľov aj poskytovateľov) limitovaný pre profesionálov z radov Informačných technológií. Databázy ktoré by mali byť vyvinuté v prostredí vlastnej spoločnosti a efektívne získavanie dát vyžadovalo veľmi dobré znalosti databáz.  Ak užívateľ chcel špeciálnu výstupnú zostavu, on alebo ona potrebovali požiadať pracovne zaťažených pracovníkov výpočtového centra aby program pre zostavu napísali, a to zvyčajne nebolo možné včas aby ste mohli ovplivniť rozhodnutia. (Pozn. prekladateľa: V tom čase boli informačné systémy vždy v pozadu - spätne ste mohli zizstiť čo sa udialo a aký stav bol v ďalekej a blízkej minulosti. Nemali ste však prehľad o tom aký stav je dnes a ako by sa situácia mohla vyvýjať do budúcnosti.  ) 

Although relational technology was originally developed in the 1970s on the mainframe, it remained largely a research project until it began to appear in the 1980s on mini-computers. With the advent of PCs the world entered a more “user-centric” era of computing with more user-friendly report writers based on SQL – the query language introduced by relational technology. Users could now produce their own reports and ad-hoc queries of the database, and relational usage exploded.

Aj keď relačná technológia bola vyvinuá v 70-tych rokoch minulého storočia na salových počítačoch (mainfremoch) to zostalo vždy len v rovine výskumného programu až kým sa neobjavili v 80-tych rokoch na minikomputeroch. S príchodom personálnych počítačov (PC) svet vsúpil do obdobia viac "uživateľsky orientovaného" obdobia počítačových aplikácií viac využívajúcich uživateľsky príjemné aplikácie na písanie výstupných zostavy založené na jazyku SQL - t.j. dotazovacieho jazyka, ktorý bol uvedený na známosť práve relačnými databázami. Užívatelia teraz mohli vytvárať vlastné výstupné zostavy a náhodné dotazy na databázu podľa potreby, a to spôsobilo explozívne šírenie využívania relačných technológií. 

SQL allows a consistent language to be used to ask questions of a wide variety of data. SQL works by viewing all data in a very simple and standardized format – a two-dimensional table with rows and columns. While this simple data model allowed the construction of an elegant query language with which to ask questions, it came with a severe price. The inherent complexity of real world data relationships doesn’t fit naturally into simple rows and columns, so data is often fragmented into multiple tables that must be “joined” in order to complete even simple tasks. This results in two problems: a) queries can become very difficult to write due to the need to “join” many tables (often with complex outer joins); and b) the processing overhead required when relational databases have to deal with complex data can be enormous.

SQL umožnil aby jeho čistý logický jazyk bol používaný na výber rôznych variácií dát.  SQL zobrazuje dáta vo veľmi jednoduchom a standardizovanom formáte - ako dvojdimenzionálnu tabuľku s riadkami a stĺpcami. Pokiaľ tento jednoduchý datový model umožňuje vytvoriť elegantný dotazovací jazyk na druhej strane musíme trvdo platiť za niečo iné. Komplexnosť vzťahov dát reálneho sveta sa nedá jednoducho vtesnať do jednoduchých riadkov a stĺpcov, a preto sú dáta rozbité do mnohých tabuliek, ktoré musia byť pospájané   za účelom riešenia len jednoduchých úloh. Toto ústi do dvoch problémov: a) napísanie dotazov sa može stávať veľmi komplikovaný procesom pretože je potrebné pospájať veľa tabuliek.; a b) ak reačná databáza pracuje s enormne velkým komplexom dát je potrebný dostatočná rezerva v technológii (výkon počítačov, pamäte, ...)

SQL has become a standard for database interoperability and reporting tools. However, it is important to understand that while SQL grew out of relational databases, it need not be constrained by them. Caché supports standard SQL as a query and update language using a much stronger multidimensional database technology, and it is extended to include object capabilities.

SQL sa stal štandardom pre databázovú interoperabilitu (súčinnosť databáz) a nástroje pre tvorbu výstupných zostáv. Aj keď je dôležité pochopiť že SQL vyrástlo z prostredia relačných databáz, nie je nutné ho viazať výhradne na ne. Caché podporuje štandard SQL ako dotazovací jazyk a jazyk umožňujúci  modifikáciu dát, ktorý používa oveľa silnejšiu viacdimenzionálnu databázovú technológiu, rozširujúce SQL o objektové schopnosti.  

Objektová technológia a Objektové databázy. Object Technology and Object Databases

Object programming and object databases are a practical result of work to simulate complex activities of the brain. It was observed that the brain is able to store very complex and different types of data and yet still manipulate such seemingly different information in common ways. Also, very complex behavior needed to be implemented in programs while hiding that complexity. Clearly both of these characteristics are true of today’s leading edge applications.

Objektové programovanie a objektové databázy sú praktickým výsledkom simulovania komplexných aktivít mozgu. Bolo zistené, že mozog je schopný ukladať veľmi komplexné a rozdielne typy dát a napriek tomu stále manipulovať s evidentne rozdielnymi informáciami rovnakým spôsobom. Taktiež veľmi ... Samozrejme obe z týchto charakteristík platia pre dnešné špičkové aplikácie.  

Objektový versus Relačný prístup. Object Versus Relational Access

In object technology, the complexity of the data is contained within the object, and the data is accessed by a simple consistent interface. In contrast, relational technology also provides a simple consistent interface, but, because it does nothing to manage real-world data complexity, the user or programmer is responsible for constantly dealing with that complexity.

V objektovej technológii spletitosť dát je obsiahnutá vo vnútri objektov, a dáta sú prístupné cez jednoduchý konzistentný interface. Na porovnanie aj relačné technológie poskytujú jednoduchý konzistentný interface, ale pretože ten nič nerobí pre menežovanie komplexnoti dát reálneho sveta, uživateľ alebo programátor je zodpovedný za  ...

Because objects can model complex data simply, object programming is the best choice for programming complex applications. Similarly, object access of the database is the best choice for inserting and updating the database (i.e., for transaction processing).

Caché complements object access with an object-extended SQL query language. SQL is a powerful language for searching a database and is widely used by reporting tools. However, we believe SQL is best suited for that purpose – queries and reports – rather than for transaction processing (for which it is cumbersome and often inefficient). Caché SQL’s object extensions eliminate much of the cumbersome join syntax, making SQL even easier to use.

Overview of the Caché Object Data Model and Object Programming

The Caché object model is based upon the ODMG (Object Database Management Group) standard and supports many advanced features, including multiple inheritance.

Object technology attempts to mirror the way that humans actually think about and use informa-tion. Unlike relational tables, objects bundle together both data and code. For example, an Invoice object might have data, such as an invoice number and a total amount, and code, such as Print().

Conceptually, an object is a package that includes that object’s data values (“properties”) and a copy of all of its code (“methods”). An object’s methods send messages to communicate with other methods. To reduce storage, it is common for objects of the same class to share the same copy of code (e.g., it would be unrealistic for each Invoice object to have its own private copy of code). Also, in Caché, method calls typically result in efficient function calls rather than enduring the overhead of passing messages. However, these implementation techniques are hidden from the programmer; it is always accurate to think in terms of objects passing messages.

What is the difference between an object and a class? A class is the definitional structure and code provided by the programmer. It includes a description of the nature of data and how it is stored as well as all of the code, but it does not contain any data. An object is a particular “instance” of a class. For example, invoice #123456 is an object of the Invoice class.

Object technology also promotes a natural view of data by not restricting properties to simple, computer-centric data types. Objects may contain other objects, or references to other objects, which makes it easy to build useful and meaningful data models. Here’s a simple example of a Customer object:

[Customer object diagram artwork]

Name: Data is stored using a Name datatype.

SSN: Data might be a simple datatype, such as an integer, or a more complex programmer-defined data type such as a 9 digit string that matches the pattern: NNN-NN-NNNN.

Address: This is an example of how objects can be embedded within other objects. In this example, Address is an embedded object that contains the properties Street and City.

AccountRep: AccountRep is a property that connects a Customer to a AccountRep object in a many-to-one relationship (many Customers to one AccountRep.) Unlike an embedded object, the related object has its own database ID and is stored separately using that ID. That ID can be used to directly access that AccountRep without accessing the Customer. In Caché the syntax for accessing an embedded or related object is the same (e.g.,Customer.Address.City and Customer.AccountRep.Name use the same “dot syntax”).

Invoices: A Customer has a collection of Invoices, each of which is a complex object stored separately with its own database ID. In this example there is a one-to-many relationship between Customers and Invoices (one Customer to many Invoices) using a parent-child relationship (Invoices cannot exist without a Customer, but a Customer can exist without Invoices.) A collection of embedded objects is also possible.

Key Object Concepts (Klúčové objektové komponenty)

Inheritance is the ability to derive one class of objects from another. The new class (a subclass) contains all of the properties and methods of its superclass, as well as additional properties and methods unique to it. Objects of the subclass can be thought of as having an “is a” relationship to its superclass. For example, a dog “is a” mammal, so it makes sense for the Dog class to inherit all the properties and methods of the Mammal class plus have additional properties and methods such as a DogTagNumber. A subclass may also override an inherited definition (e.g., the Print() method for a subclass of the Invoice class may be different from the Print() method of Invoice). Inheritance promotes reusability of code and makes it easier to introduce major improvements.

Dedičnosť je schopnosť odvodiť (derivovať) jednu triedu objektov z inej. Nová trieda ( podtrieda = a subclass) obsahuje vsetky vlastnosti a metódy jej nadriadenej triedy (superclass), ako aj ... as well as additional properties and methods unique to it. Objects of the subclass can be thought of as having an “is a” relationship to its superclass. For example, a dog “is a” mammal, so it makes sense for the Dog class to inherit all the properties and methods of the Mammal class plus have additional properties and methods such as a DogTagNumber. A subclass may also override an inherited definition (e.g., the Print() method for a subclass of the Invoice class may be different from the Print() method of Invoice). Inheritance promotes reusability of code and makes it easier to introduce major improvements.

Multiple inheritance means a subclass can be derived from more than one superclass. For example, a dog “is a” mammal and “is a” pet, so the object class “Dog” can inherit the attributes of both the “Mammal” class and the “Pet” class.

Encapsulation means that objects can be viewed as a sort of “black box”. Public properties and methods can be accessed by any method, whereas private properties and methods can only be accessed by methods of the same class. Thus the application doesn’t need to know the internal workings of an object – it deals only with the public properties and methods. The power of encapsulation is that programmers can improve the inner workings of a class without affecting the rest of the application.

Polymorphism refers to the fact that methods used in multiple classes can share a common interface, even if the underlying implementation is different. For example, suppose the classes Letter, Mailing Label, and ID Badge all contain a method called Print. To print, an application doesn’t need to know which type of object it is accessing – it merely calls the object’s Print method.

The Caché Advantage (Výhody Caché)

Caché is fully object-enabled, providing all the power of object technology to developers of high-performance transaction processing applications.

Caché je plno objektový, poskytuje všetok výkon objektovej technológie vývojárom, aby mohli vytvárať výkonné transakcie využívajúce aplikácie.

Intuitive Data Modeling Object technology lets developers think about and use information – even extremely complex information – in simple and realistic ways, thus speeding theapplication development process.

Intuitívne Datové  Modelovanie Objektové technológie umožňujú vývojárom uvažovať a používať informácie – dokonca extremne komplexné informácie – jednoduchými realite sa podobajúcimi spôsobmi, čím de fakto urýchľujú proces vývoja aplikácie.

Rapid Application Development The object concepts of encapsulation, inheritance, and polymorphism allow classes to be reused, re-purposed, and shared between applications, enabling developers to leverage their work over many projects.

Rýchly vývoj aplikácií Objektová koncepcia zapúzdrenia, dedenia a polymorfizmu umožňujú aby triedy mohli byť opakovane použité, zmenené na iný účel a aby mohli byť zdielané medzi aplikáciami, čo umožňuje vývojárom znižovať množstvo vykonanej práce nad mnohými pťrojetami.

Why Choose Objects For Your Data Model?

For new database applications, most developers choose to use object technology because they can develop complex applications more rapidly and more easily modify them later. Object technology provides many benefits:

Object Data Storage...

Unfortunately, although many applications are now being written with object programming languages, they often try to force object data into flat relational tables. This significantly impairs the advantages of object technology.

Caché provides a multidimensional data structure that naturally stores rich object data. The result is faster data access and faster programming.

...Plus Relational Access

Of course many tools (such as report writers) use SQL, not object technology, for accessing data.

A unique feature of Caché is that whenever a database object class is defined, Caché automatically provides full SQL access to that data. Thus, with no additional work, SQL-based tools will immedi-ately work with Caché data, and even they will experience the high performance advantage of the Caché Multidimensional Data Server.

The reverse is also true. When a DDL definition of a relational database is imported, Caché automatically generates an object description of the data, enabling immediate access as objects, as well as through SQL.

The Caché Unified Data Architecture keeps these access paths synchronized; there is only one data description to edit.