[ Pobierz całość w formacie PDF ]
.Object Databases Versus Relational DatabasesWith all the difficulty in trying to map between two such disparate models, it might seem better tosimply use one model for all your application development.If you were to use an object databasemanagement system (ODBMS) instead of a relational database management system (RDBMS), youcould avoid the muss and the fuss of mapping between the object model and the relational model.However, some applications lend themselves to object databases, and some do not.Your choice ofdatabase technology should depend on the particular requirements of your application.Object databases and relational databases each have specific characteristics, and each will provideparticular capabilities in your applications.As you learned in Day 1, "Choosing the Right Database Technology," C++ object databases directlysupport the type system of the C++ language.In other words, you can use a C++ object database tostore instances of C++ classes right in the database.Refer to Listing 1.5 to see how well and how easily C++ databases can integrate with C++ applications.By using simple overrides of a few C++ operators, you can easily persist and retrieve your C++ objectsin an object database.C++ object databases supportThe C++ type system, including classes that are defined by the application developerInheritance, where the database understands the class hierarchy and manages the object storeappropriatelyPolymorphism, where objects can be read from the database without knowing in advance theircomplete type informationObject identities, where the database assigns a unique ID to each object, can readily retrieveeach object by ID, and can determine whether the object has already been loaded into programmemoryReferences to other objects, where the database understands pointer references between objectsand can store and retrieve linked objects appropriatelyUsing an object database means that your database will directly mirror the objects in your application.The objects in the database will be the same as the objects in your C++ code.Having a database thatmirrors the objects in your C++ code is a two-edged sword with two potentially negative consequences.First, the only data that can be retrieved from your database is the data encapsulated in the objects inyour C++ source code.All the data, relationships, and uses of that data must be defined in the sourcecode for your application.You might not be able to foresee all the potential uses of this data duringyour application development.This means that your application and its database could missopportunities to be useful in the future.Second, the only applications that will be able to access the database will be C++ programs that havean intimate knowledge of the objects in your application source code.The database will be a closed,proprietary database.This means that your database could miss opportunities to be useful in the future.NOTEIf your data is important to you, it is probably important to others, also.Theywill want access to the data through more than just your application.It is important to remember what makes most database applications valuable is the information thatthey provide.Your application processes the data from the data source into useful information andpresents its view of the information.However, people will invariably want access to the data sourcethemselves so that they can perform additional analyses for use in different applications.TIPOver time, applications often depreciate, while databases appreciate.Thevalue of a given application will decline as business needs change, butinformation is always valuable.Because information is always valuable, its value often justifies the additional time and effort requiredto place it in a relational database and create an object-to-relational mapping layer for your application.Figure 13.2 illustrates the closed nature of a C++ object database and the openness and availability of arelational database.Figure 13.2 : The relative openness of object databases and relational databases.Some applications lend themselves to object databases, whereas other applications lend themselves torelational databases.Whether an application should use an object database or a relational database islargely determined by the need for flexibility in using the data.A relational database will be open to other uses and other applications.It will also be open to futureversions of your application that might need to apply new analyses to data from the database.Arelational database enables you to create new relationships and collections of data that you had notenvisioned at the time the database was first created.If your database conforms to the normal forms,you can simply write some new SQL code to create new relationships and to perform new analyses onthe data.Relational databases provide a high degree of flexibility in defining new uses for the data.Object databases lend themselves to applications in which the data model is complex and therelationships are well defined at the time the database is created.Some data models are too complex tobe molded into a relational database.For specialized applications like this, you will need to takeadvantage of the object-oriented features of C++ to model the complexities of the data.An objectdatabase will enable you to easily persist those C++ objects to a data store
[ Pobierz całość w formacie PDF ]